Computing a shortest path in a polyhedral domain in Euclidean space is a fundamental and important algorithmic problem, which is intensively studied in computational geometry . This problem is relatively easy to solve in the two-dimensional case; it can generally be reduced to a discrete graph searching problem where some combinatorial approaches can be applied. In three or more dimensions, however, the problem becomes much harder; it is not even discrete. In fact, it was proved by Canny and Reif  that the shortest path problem in a polyhedral domain is NP-hard. Mitchell and Sharir  have shown that the problem of finding a shortest obstacle-avoiding path is NP-hard even for the case of a region with obstacles that are disjoint axis-aligned boxes. On the other hand, there are some cases where one can obtain polynomial time complexity. For instance, it was shown by Sharir  that a shortest obstacle-avoiding path among disjoint convex polyhedra having altogether vertices, can be found in time, which implies that this problem is polynomially solvable if is a small constant.
What determines the tractability of the shortest path problem in geometric domains? One of promising answers to this challenging question is global non-positive curvature, or CAT(0) property . CAT(0) spaces are metric spaces in which geodesic triangles are “not thicker” than those in the Euclidean plane, and enjoy various fascinating properties generalizing those in Euclidean and hyperbolic spaces. As Ghrist and LaValle  observed, no NP-hard example in  is a CAT(0) space. One of the significant properties of CAT(0) spaces is the uniqueness of geodesics: Every pair of points can be joined by a unique geodesic. Computational and algorithmic theory on CAT(0) spaces is itself a challenging research field .
One of fundamental and familiar CAT(0) spaces is a CAT(0) cubical complex. A cubical complex is a polyhedral complex where each cell is isometric to a unit cube of some dimension and the intersection of any two cells is empty or a single face. Gromov  gave a purely combinatorial characterization of cubical complexes of non-positive curvature as cubical complexes in which the link of each vertex is a flag simplicial complex. Chepoi  and Roller  established that the -skeletons of CAT(0) cubical complexes are exactly median graphs, i.e., graphs in which any three vertices admit a unique median vertex. It is also shown by Barthélemy and Constantin  that median graphs are exactly the domains of event structures . These nice combinatorial characterizations are one of the main reasons why CAT(0) cubical complexes frequently appear in mathematics, for instance, in geometric group theory [24, 25], metric graph theory , concurrency theory in computer science , theory of reconfigurable systems [1, 14], and phylogenetics .
There has been several polynomial time algorithms to find shortest paths in some CAT(0) cubical complexes. A noteworthy example is for a tree space, introduced by Billera, Holmes and Vogtmann  as a continuous space of phylogenetic trees. This space is shown to be CAT(0), and consequently provides a powerful tool for comparing two phylogenetic trees through the unique geodesic. Owen and Provan [21, 22] gave a polynomial time algorithm for finding geodesics in tree spaces, which was generalized by Miller et al.  to CAT(0) orthant spaces, i.e., complexes of Euclidean orthants that are CAT(0). Chepoi and Maftuleac  gave an efficient polynomial time algorithm to compute geodesics in a two dimensional CAT(0) cubical complex. These meaningful polynomiality results naturally lead to a question: What about arbitrary CAT(0) cubical complexes?
Ardila, Owen and Sullivant  gave a combinatorial description of CAT(0) cubical complexes, employing a poset endowed with an additional relation, called a poset with inconsistent pairs (PIP). This can be viewed as a generalization of Birkhoff’s theorem that gives a compact representation of distributive lattices by posets. In fact, they showed that there is a bijection between CAT(0) cubical complexes and PIPs. (Through the above-mentioned equivalence, this can be viewed as a rediscovery of the result of Barthélemy and Constantin , who found a bijection between PIPs and pointed median graphs.) This relationship enables us to express an input CAT(0) cubical complex as a PIP: For a poset with inconsistent pairs , the corresponding CAT(0) cubical complex is realized as a subcomplex of the -dimensional cube in which the cells of are specified by structures of . Adopting this embedding as an input, they gave the first algorithm to compute geodesics in an arbitrary CAT(0) cubical complex. Their algorithm is based on an iterative method to update a sequence of cubes that may contain the geodesic, where at each iteration it solves a touring problem using second order cone programming . They also showed that the touring problem for general CAT(0) cubical complexes has intrinsic algebraic complexity, and geodesics can have breakpoints whose coordinates have nonsolvable Galois group. This implies that there is no exact simple formula for the geodesic and therefore in general, one can only obtain an approximate one. Unfortunately, even if the touring problem could be solved exactly, it is not known whether or not their algorithm is a polynomial one; that is, no polynomial time algorithm has been known for the shortest path problem in a CAT(0) cubical complex in general dimension.
In this paper, we present the first polynomial time algorithm to compute geodesics in a CAT(0) cubical complex in general dimension, answering the open question suggested by these previous work; namely we show that:
Given a CAT(0) cubical complex represented by a poset with inconsistent pairs and two points in , one can find a path joining and of length at most in time polynomial in and .
The algorithm is quite simple, without depending on any involved techniques such as semidefinite programming. To put it briefly, our algorithm first gives a polygonal path joining and with a fixed number (, say) of breakpoints, and then iteratively updates the breakpoints of the path until it becomes a desired one. To update them, we compute the midpoints of the two close breakpoints by using Miller, Owen and Provan’s algorithm. The resulting number of iterations is bounded by a polynomial in . Key tools that lead to this bound are linear algebraic techniques and the convexity of the metric of CAT(0) spaces, rather than inherent properties of cubical complexes. Due to its simplicity, our algorithm is applicable to any CAT(0) space where geodesics between two close points can be found, not limited to CAT(0) cubical complexes. We believe that our result will be an important step toward developing computational geometry in CAT(0) spaces.
A reconfigurable system [1, 14] is a collection of states which change according to local and reversible moves that affect global positions of the system. Examples include robot motion planning, non-collision particles moving around a graph, and protein folding; see . Abrams, Ghrist and Peterson [1, 14] considered a continuous space of all possible positions of a reconfigurable system, called a state complex. Any state complex is a cubical complex of non-positively curved , and it becomes CAT(0) in many situations. In the robotics literature, geodesics (in the -metric) in the CAT(0) state complex corresponds to the motion planning to get the robot from one position to another one with minimal power consumption. Our algorithm enables us to find such an optimal movement of the robot in polynomial time.
The rest of this paper is organized as follows. In Section 2, we devise an algorithm to compute geodesics in general CAT(0) spaces. In Section 3, we present a polynomial time algorithm to compute geodesics in CAT(0) cubical complexes, using the result of Section 2. Section 2.1 and Section 3.1 to 3.4 are preliminary sections, where CAT(0) metric spaces, CAT(0) cubical complexes, median graphs, PIPs and CAT(0) orthant spaces are introduced.
2 Computing geodesics in CAT(0) spaces
In this section we devise an algorithm to compute geodesics in general CAT(0) spaces, not limited to CAT(0) cubical complexes.
2.1 CAT(0) space
Let be a metric space. A geodesic joining two points is a map such that and for all . The image of is called a geodesic segment joining and . A metric space is called (uniquely) geodesic if every pair of points is joined by a (unique) geodesic.
For any triple of points in a metric space , there exists a triple of points in the Euclidean plane such that for . The Euclidean triangle whose vertices are and is called a comparison triangle for . (Note that such a triangle is unique up to isometry.) A geodesic metric space is called a CAT(0) space if for any and any belonging to a geodesic segment joining and , the inequality holds, where is the unique point in satisfying for . See Figure 1.
This simple definition yields various significant properties of CAT(0) spaces; see  for details. One of the most basic properties of CAT(0) spaces is the convexity of the metric. A geodesic metric space is said to be Busemann convex if for any two geodesics , the function given by is convex.
Lemma 2.1 ([8, Proposition II.2.2]).
Every CAT(0) space is Busemann convex.
A Busemann convex space is uniquely geodesic. Indeed, for any two geodesics with and , one can easily see that and coincide, since for all . This implies that:
Theorem 2.2 ([8, Proposition II.1.4]).
Every CAT(0) space is uniquely geodesic.
Let be a CAT(0) space. We shall refer to an element in the product space as a chain, and write to denote the -th component of , i.e., . For any chain , we define the length of by and denote it by . We consider the following problem:
|Given two points , a chain with and , and a positive parameter , find a chain such that , and ,||(2.1)|
under the situation where we are given an oracle to perform the following operation for some :
|Given two points with , compute the geodesic joining and in arbitrary precision.||(2.2)|
To explain our algorithm to solve this problem, we need some definitions. Since is uniquely geodesic, every pair of points has a unique midpoint satisfying . For a nonnegative real number , a -midpoint of and is a point satisfying , where is the midpoint of and .
Definition 2.3 (-halved chain).
Let be a nonnegative real number. For any chain , a chain is called a -halved chain of if it satisfies the following:
, and is a -midpoint of and for .
For an integer , we say that is a -th -halved chain of if there exists a sequence of chains in such that and is a -halved chain of for .
Our algorithm can be described as follows. To put it briefly, the algorithm just finds a -th -halved chain of a given chain for some large and small ; see Figure 2 for an illustration. In the algorithm the local optimization is done alternatively “from left to right” and “from right to left” so that the analysis will be easier.
Input. Two points , a chain with and , and parameters .
For , do the following:
Set and .
For , do the following:
For any chain , define the gap of by and denote it by . The following theorem states that Algorithm 1 solves problem (2.1).
We give an example of CAT(0) spaces to which our algorithm is applicable. A -complex is a two dimensional piecewise Euclidean complex in which each 2-cell is isomorphic to an isosceles right triangle with short side of length one . A CAT(0) -complex is called a folder complex ; see Figure 3 for an example.
One can show that for a folder complex , computing the geodesic between two points with can be reduced to an easy calculation on a subcomplex of having a few cells. This implies that our algorithm enables us to find geodesics between two points in a folder complex in time bounded by a polynomial in the size of .
For any chain , we define the reference chain of as follows: and for , where is the geodesic with and . Reference chains are designed not to be equally spaced but to have a double gap in the beginning so that the analysis of the algorithm will be easier. Note that the reference chain of is determined just by its end components , and therefore for any chain and any even -halved chain of their reference chains coincide: . A key observation that leads to Theorem 2.4 is that: For any chain and any -th -halved chain of with sufficiently large and sufficiently small, the distance between and its reference chain is small enough for its length to approximate well ; moreover, the value of such a can be bounded by a polynomial in . The next lemma states this fact.
Let . Any -th -halved chain of satisfies
for , where is the base of the natural logarithm.
Let be a sequence of chains in such that and is a -halved chain of for . Fix an integer and an integer . Note that by definition is a -midpoint of and and that is the midpoint of and . Hence, by Lemma 2.1 and the triangle inequality, we have
where is the midpoint of and . See Figure 4 for intuition.
be a column vector of dimensionwhose -th entry equals for . Let be a square matrix of order whose entry equals if and otherwise. Let be a square matrix of order whose entry equals if and otherwise. Then, by (2.4) we have for each , where is a column vector with all entries equal to . Let be a square matrix of order whose entry equals if and otherwise. Then one can easily see that . Hence we have
for each . We show that
for any integer . The inequality (2.5) inductively yields that . Here, the inequality comes from the triangle inequality. Indeed, we have
Let us now prove Theorem 2.4.
Proof of Theorem 2.4.
for . This implies that , and therefore completes the proof of (i).
To prove (ii), we first show
by induction on . The case being trivial, suppose that . Since is a -midpoint of and , the triangle inequality and the induction yield , which completes the induction. See Figure 5 for intuition.
Case 1: . Note that and that
. However roughly one estimates an upper bound of, one can get
where the last inequality comes from the fact that for any . It is easy to see that , provided .
Case 2: . Recall (2.7). Since , we have
It is easy to see that , provided .
We end this section by showing the lemma used in the proof of Lemma 2.6. Let be an matrix whose entry is defined by
for . Since is a nonnegative matrix, its spectral radius is at most the maximum row sum of , which immediately yields that . This inequality, however, is not tight unless . In fact, one can obtain a more useful upper bound of .
Let be an integer, and let be an matrix defined by (2.9). Then its spectral radius is at most . In addition, one has and for any integer .
Let for simplicity. Let be a positive column vector of dimension whose -th entry is defined by for . By the Collatz–Wielandt inequality, in order to show it suffices to show that . The -th entry of the vector is
Hence, using the general formulas
It is easy to see that for and one has
which implies that
This completes the proof of the inequality .
Let us show the latter part of the lemma. Note that . Since and is a nonnegative matrix (as ), we have .
Since , we have for any integer . Hence, . ∎
In proving Theorem 2.4, we utilized only the convexity of the metric of . Hence our algorithm works even when is a Busemann convex space.
3 Computing geodesics in CAT(0) cubical complexes
In this section we give an algorithm to compute geodesics in CAT(0) cubical complexes, with an aid of the result of the preceding section. In Section 3.1 to 3.4, we recall CAT(0) cubical complexes, median graphs, PIPs and CAT(0) orthant spaces. Section 3.5 is devoted to proving our main theorem.
3.1 CAT(0) cubical complex
A cubical complex is a polyhedral complex where each -dimensional cell is isometric to the unit cube and the intersection of any two cells is empty or a single face. The underlying graph of is the graph , where denotes the set of vertices (-dimensional faces) of and denotes the set of edges (-dimensional faces) of .
A cubical complex has an intrinsic metric induced by the -metric on each cell. For two points , a string in from to is a sequence of points in such that for each there exists a cell containing and , and its length is defined to be , where is measured inside by the -metric. The distance between two points is defined to be the infimum of the lengths of strings from to .
Gromov  gave a combinatorial criterion which allows us to easily decide whether or not a cubical complex is non-positively curved. The link of a vertex of is the abstract simplicial complex whose vertices are the edges of containing and where edges span a simplex if and only if they are contained in a common -dimensional cell of . An abstract simplicial complex is called flag if any set of vertices is a simplex of whenever each pair of its vertices spans a simplex.
Theorem 3.1 (Gromov ).
A cubical complex is CAT(0) if and only if is simply connected and the link of each vertex is flag.
3.2 Median graph
Let be a simple undirected graph. The distance between two vertices and is the length of a shortest path between and . The interval between and is the set of vertices with . A vertex subset is said to be gated if for every vertex , there exists a unique vertex , called the gate of in , such that for all . Every gated subset is convex, where a vertex subset is said to be convex if is contained in for all . A vertex subset is called a halfspace of if both and its complement are convex. A graph is called a median graph if for all the set contains exactly one element, called the median of . Median graphs are connected and bipartite. In median graphs , every convex set of is gated. (Indeed, for each one can take a vertex such that . Then for any the median of should be , as and . This implies that is the gate of in .) Thus, in median graphs gated sets and convex sets coincide. A median complex is a cubical complex derived from a median graph by replacing all cube-subgraphs of by solid cubes. It has been shown independently by Chepoi  and Roller  that median complexes and CAT(0) cubical complexes constitute the same objects:
The underlying graph of every CAT(0) cubical complex is a median graph, and conversely, every median complex is a CAT(0) cubical complex.
For a cubical complex and any , we denote by the subcomplex of induced by . The following property of CAT(0) cubical complexes is particularly important for us.
Theorem 3.3 ([11, Proposition 1]).
Let be a CAT(0) cubical complex. For any convex set of the underlying graph , the subcomplex induced by is convex in .
3.3 Poset with inconsistent pairs (PIP)
Barthélemy and Constantin  established a Birkhoff-type representation theorem for median semilattices, i.e., pointed median graphs, by employing a poset with an additional relation. This structure was rediscovered by Ardila et al.  in the context of CAT(0) cubical complexes. An antichain of a poset is a subset of that contains no two comparable elements. A subset of is called an order ideal of if and imply . A poset is locally finite if every interval is finite, and it has finite width if every antichain is finite.
A poset with inconsistent pairs (or, briefly, a PIP) is a locally finite poset of finite width, endowed with a symmetric binary relation satisfying:
If , then and are incomparable.
If , and , then .
A pair with is called an inconsistent pair. An order ideal of is called consistent if it contains no inconsistent pairs.
For a CAT(0) cubical complex and a vertex of , the pair is called a rooted CAT(0) cubical complex. Given a poset with inconsistent pairs , one can construct a cubical complex as follows: The underlying graph is a graph whose vertices are consistent order ideals of and where two consistent order ideals are adjacent if and only if ; replace all cube-subgraphs (i.e., subgraphs isomorphic to cubes of some dimensions) of by solid cubes. See Figure 6 for an example.
In fact, the resulting cubical complex is CAT(0), and moreover:
Theorem 3.5 (Ardila et al. ).
The map is a bijection between posets with inconsistent pairs and rooted CAT(0) cubical complexes.
Given a poset with inconsistent pairs , one can embed into a unit cube in the Euclidean space as follows, which we call the standard embedding of :
For each pair of a consistent order ideal of and a subset , where is the set of maximal elements of , the subspace
corresponds to a unique -dimensional cell of .
3.4 CAT(0) orthant space
Let denote the set of nonnegative real numbers. Let be an abstract simplicial complex on a finite set . The orthant space for is a subspace of -dimensional orthant constructed by taking a union of all subcones associated with simplices of , where is defined by for each simplex ; namely, . The distance between two points is defined in a similar way as in the case of cubical complexes. An orthant space is a special instance of cubical complexes.
Theorem 3.6 (Gromov ).
The orthant space for an abstract simplicial complex is a CAT(0) space if and only if is a flag complex.
A typical example of CAT(0) orthant spaces is a tree space . Owen and Provan [21, 22] gave a polynomial time algorithm to compute geodesics in tree spaces, which was generalized to CAT(0) orthant spaces by Miller et al. .
Let be a flag abstract simplicial complex on a finite set and be the CAT(0) orthant space for . Let , and let and be the inclusion-wise minimal simplices such that and . Then one can find the explicit description of the geodesic joining and in time.
An interesting thing about their algorithm is that it solves as a subproblem a combinatorial optimization problem: a Maximum Weight Stable Set problem on a bipartite graph whose color classes have at mostvertices, respectively. We should note that the above explicit descriptions of geodesics are radical expressions. Computationally, for a point on a geodesic, one can compute a rational point