Computing All-Pairs Shortest Paths by Leveraging Low Treewidth

Computing All-Pairs Shortest Paths by Leveraging Low Treewidth

Proceedings of the Twenty-First International Conference on Automated Planning and Scheduling Computing All-Pairs Shortest Paths by Leveraging Low Treewidth Leon´ Planken and Mathijs de Weerdt Roman van der Krogt Delft University of Technology Cork Constraint Computation Centre {l.r.planken,m.m.deweerdt}@tudelft.nl [email protected] Abstract Warshall algorithm. The state of the art for computing APSP is Johnson’s algorithm, which runs in O n2 log n + nm Considering directed graphs on n vertices and m edges time using a Fibonacci heap (Fredman and Tarjan 1987). with real (possibly negative) weights, we present two new, efficient algorithms for computing all-pairs shortest paths Recently there has been specific interest in STNs stem- (APSP). These algorithms make use of directed path consis- ming from hierarchical task networks (HTNs) (Castillo, tency (DPC) along a vertex ordering d. The algorithms run Fdez-Olivares, and Gonzalez´ 2006; Bui and Yorke-Smith 2 in O n wd time, where wd is the graph width induced by 2010). These graphs have the “sibling-restricted” property: this vertex ordering. For graphs of constant treewidth, this each task, represented by a pair of vertices, is connected only 2 yields O n time, which is optimal. On chordal graphs, the to its sibling tasks, its parent or its children. In these graphs algorithms run in O (nm) time. We show empirically that the number of children of a task is restricted by a constant also in many general cases, both constructed and from real- branching factor, and therefore the resulting STNs also have istic benchmarks, the algorithms often outperform Johnson’s a tree-like structure. algorithm, which represents the current state of the art with a run time of O nm + n2 log n. These algorithms can be In this paper we present two new algorithms for APSP in used for temporal and spatial reasoning, e.g. for the Simple Section 3. One algorithm is based on a point-to-point short- Temporal Problem (STP), which underlines its relevance to est path algorithm by Chleq (1995), and another is similar to the planning and scheduling community. Planken et al.’s (2008) algorithm for enforcing partial path consistency (P3C). These algorithms advance the state of the art in computing APSP. In graphs of constant treewidth, 1 Introduction such as the sibling-restricted STNs based on HTNs, the Finding shortest paths is an important and fundamental run time is bounded by O n2, which is optimal since problem in communication and transportation networks, cir- the output is Θ(n2). In addition to these STNs, examples cuit design, graph analysis—e.g. for computing the be- of such graphs are outerplanar graphs, graphs of bounded tweenness (Girvan and Newman 2002)—and is a sub- bandwidth, graphs of bounded cutwidth, and series-parallel problem of many combinatorial problems, such as those graphs. that can be represented as a network flow problem. In When the algorithms are applied to chordal graphs, they particular, in the context of planning and scheduling, find- have a run time of O (nm), which is a strict improvement ing shortest paths is important to solve the Simple Tempo- over the state of the art (Chaudhuri and Zaroliagis 2000, with ral Problem (STP) (Dechter, Meiri, and Pearl 1991), which 2 a run time of O nmwd ; wd is defined below). Chordal in turn appears as a sub-problem to the NP-hard Tempo- graphs are an important subset of general sparse graphs: in- ral Constraint Satisfaction Problem (TCSP) and Disjunc- terval graphs, trees, k-trees, directed path, and split graphs tive Temporal Problem (DTP) classes, powerful enough to are all special cases of chordal graphs (Golumbic 2004). model job-shop scheduling problems. The shortest path Moreover, any graph can be made chordal using a so-called computations in these applications can account for a sig- triangulation algorithm. Such an algorithm operates by nificant part of the total run time. These topics have re- eliminating vertices one by one, connecting the neighbours ceived substantial interest in the planning and schedul- of each eliminated vertex and thereby inducing cliques in the ing community (Satish Kumar 2005; Bresina et al. 2005; graph. The induced width wd of the elimination ordering d Shah and Williams 2008). is defined to be equal to the cardinality of the largest set of Instances of the STP, called Simple Temporal Net- neighbours thus connected. The upper bound of the run time works (STNs), have a natural representation as directed of both proposed algorithms on these general graphs, then, graphs with real edge weights. The canonical way of solv- 2 is O n wd ; this is better than the bound on Johnson’s al- ing an STP instance (Dechter et al.) is by computing all- gorithm if w 2 O (log n). pairs shortest paths (APSP) on its STN, e.g. with the Floyd– d Finding an elimination ordering of minimum induced Copyright c 2011, Association for the Advancement of Artificial width is an NP-hard problem. This minimum induced width Intelligence (www.aaai.org). All rights reserved. is the tree-likeness property of the graph mentioned above, 170 Algorithm 1: DPC (Dechter, Meiri, and Pearl 1991) induced width is exactly the highest number of neighbours Input: A weighted directed graph G = hV; Ei and a j < k encountered during the DPC algorithm. It is not a vertex ordering d : V ! f1; : : : ; ng property of the graph that forms DPC’s input per se; rather, Output: CONSISTENT if DPC could be enforced on G; it is dependent on both the graph and the vertex ordering INCONSISTENT if a negative cycle was found used. With a careful implementation, DPC’s time bound is 2 O nwd if this ordering is known beforehand. 1 for k n to 1 do The edges added by DPC are called fill edges and make 2 forall i < j < k such that fi; kg; fj; kg 2 E do the graph chordal (sometimes also called triangulated). In- 3 wi!j minfwi!j; wi!k + wk!jg deed, DPC differs from a triangulation procedure only by its 4 wj!i minfwj!i; wj!k + wk!ig manipulation of the arc weights. In a chordal graph, every 5 E E [ ffi; jgg cycle of length four or more has an edge joining two ver- 6 if wi!j + wj!i < 0 then tices that are not adjacent in the cycle. By definition of the 7 return INCONSISTENT induced width, the number of edges in such a chordal graph, denoted by mc ≥ m, is O (nwd). 8 return CONSISTENT Finding a Vertex Ordering i.e. the treewidth, denoted w∗. In contrast, the induced width is not a direct measure of the input (graph), so the bound of In principle, DPC can use any vertex ordering to make the 2 graph both chordal and directionally path-consistent. How- O n wd is not quite proper. Therefore, we experimen- tally establish the computational efficiency of the proposed ever, since the vertex ordering defines the induced width, it algorithms in Section 4 on a wide range of graphs, varying directly influences the run time and the number of edges mc from random scale-free networks, parts of the road network in the resulting graph. As mentioned above, finding an of New York City, to STNs generated from HTNs, and job- ordering of minimum induced width and determining the shop scheduling problems. However, we start by introduc- treewidth is an NP-hard problem in general. Still, the ing the concepts of induced width, treewidth, chordal graphs class of constant-treewidth graphs can be optimally triangu- and triangulation in more detail. lated in O (n) time (Bodlaender 1993); and if G is already chordal, we can find a perfect elimination ordering (result- 2 Preliminaries ing in no fill edges) in O (m) time, using maximal cardinal- ity search (MCS) (Tarjan and Yannakakis 1984). Both algorithms for all-pairs shortest paths presented in this For general graphs, various heuristics exist that often pro- paper rely on the fact that the graph has already been made duce good results. We mention here the minimum degree directionally path-consistent along a certain vertex ordering. heuristic (Rose 1972), which in each iteration chooses a ver- In this section, we therefore briefly discuss the algorithm for tex of lowest degree. Since the ordering produced by this directed path consistency (DPC) and how to find a vertex heuristic is not fully known before DPC starts but depends ordering required for DPC. on the fill edges added, an adjacency-list-based implemen- tation will require another O (log n) factor in DPC’s time Directed Path Consistency bound. However, for our purposes in this article, we can af- Dechter, Meiri, and Pearl (1991) proposed DPC, included ford the comfort of maintaining an adjacency matrix, which here as Algorithm 1, for checking whether an STP instance 2 2 2 yields bounds of O n + nwd time and O n space. is consistent (i.e. the graph contains no negative cycles). This algorithm takes as input a weighted directed graph 3 All-Pairs Shortest Paths G = hV; Ei and a vertex ordering d, which is a bijection between V and the natural numbers f1; : : : ; ng. In this pa- Even though, to the best of our knowledge, a DPC-based per, we simply represent the ith vertex in such an ordering APSP algorithm has not yet been proposed, algorithms for as the natural number i. The weight on the arc from i to j computing single-source shortest paths (SSSP) based on DPC can be obtained from known results in a relatively is represented as wi!j; further, our shorthand for the exis- tence of an arc between these vertices, in either direction, is straightforward manner.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us