Longest path problem

In graph theory and theoretical computer science, the longest path problem is the problem of finding a simple path of maximum length in a given graph. A path is called simple if it does not have any repeated vertices; the length of a path may either be measured by its number of edges, or (in weighted graphs) by the sum of the weights of its edges. In contrast to the shortest path problem, which can be solved in polynomial time in graphs without negative-weight cycles, the longest path problem is NP-hard, meaning that it cannot be solved in polynomial time for arbitrary graphs unless P = NP. Stronger hardness results are also known showing that it is difficult to approximate. However, it has a linear time solution for directed acyclic graphs, which has important applications in finding the critical path in scheduling problems.

NP-hardness

The NP-hardness of the unweighted longest path problem can be shown using a reduction from the Hamiltonian path problem: a graph G has a Hamiltonian path if and only if its longest path has length n  1, where n is the number of vertices in G. Because the Hamiltonian path problem is NP-complete, this reduction shows that the decision version of the longest path problem is also NP-complete. In this decision problem, the input is a graph G and a number k; the desired output is "yes" if G contains a path of k or more edges, and no otherwise.[1]

If the longest path problem could be solved in polynomial time, it could be used to solve this decision problem, by finding a longest path and then comparing its length to the number k. Therefore, the longest path problem is NP-hard. It is not NP-complete, because it is not a decision problem.[2]

In weighted complete graphs with non-negative edge weights, the weighted longest path problem is the same as the Travelling salesman path problem, because the longest path always includes all vertices.[3]

Acyclic graphs and critical paths

A longest path between two given vertices s and t in a weighted graph G is the same thing as a shortest path in a graph −G derived from G by changing every weight to its negation. Therefore, if shortest paths can be found in −G, then longest paths can also be found in G.[4]

For most graphs, this transformation is not useful because it creates cycles of negative length in −G. But if G is a directed acyclic graph, then no negative cycles can be created, and a longest path in G can be found in linear time by applying a linear time algorithm for shortest paths in −G, which is also a directed acyclic graph.[4] For instance, for each vertex v in a given DAG, the length of the longest path ending at v may be obtained by the following steps:

  1. Find a topological ordering of the given DAG.
  2. For each vertex v of the DAG, in the topological ordering, compute the length of the longest path ending at v by looking at its incoming neighbors and adding one to the maximum length recorded for those neighbors. If v has no incoming neighbors, set the length of the longest path ending at v to zero. In either case, record this number so that later steps of the algorithm can access it.

Once this has been done, the longest path in the whole DAG may be obtained by starting at the vertex v with the largest recorded value, then repeatedly stepping backwards to its incoming neighbor with the largest recorded value, and reversing the sequence of vertices found in this way.

The critical path method for scheduling a set of activities involves the construction of a directed acyclic graph in which the vertices represent project milestones and the edges represent activities that must be performed after one milestone and before another; each edge is weighted by an estimate of the amount of time the corresponding activity will take to complete. In such a graph, the longest path from the first milestone to the last one is the critical path, which describes the total time for completing the project.[4]

Longest paths of directed acyclic graphs may also be applied in layered graph drawing: assigning each vertex v of a directed acyclic graph G to the layer whose number is the length of the longest path ending at v results in a layer assignment for G with the minimum possible number of layers.[5]

Approximation

Björklund, Husfeldt & Khanna (2004) write that the longest path problem in unweighted undirected graphs "is notorious for the difficulty of understanding its approximation hardness".[6] The best polynomial time approximation algorithm known for this case achieves only a very weak approximation ratio, .[7] For all , it is not possible to approximate the longest path to within a factor of unless NP is contained within quasi-polynomial deterministic time; however, there is a big gap between this inapproximability result and the known approximation algorithms for this problem.[8]

In the case of unweighted but directed graphs, strong inapproximability results are known. For every the problem cannot be approximated to within a factor of unless P = NP, and with stronger complexity-theoretic assumptions it cannot be approximated to within a factor of .[6] The color-coding technique can be used to find paths of logarithmic length, if they exist, but this gives an approximation ratio of only .[9]

Parameterized complexity

The longest path problem is fixed-parameter tractable when parameterized by the length of the path. For instance, it can be solved in time linear in the size of the input graph (but exponential in the length of the path), by an algorithm that performs the following steps:

  1. Perform a depth-first search of the graph. Let be the depth of the resulting depth-first search tree.
  2. Use the sequence of root-to-leaf paths of the depth-first search tree, in the order in which they were traversed by the search, to construct a path decomposition of the graph, with pathwidth .
  3. Apply dynamic programming to this path decomposition to find a longest path in time , where is the number of vertices in the graph.

Since the output path has length at least as large as , the running time is also bounded by , where is the length of the longest path.[10] Using color-coding, the dependence on path length can be reduced to singly exponential.[9][11][12][13] A similar dynamic programming technique shows that the longest path problem is also fixed-parameter tractable when parameterized by the treewidth of the graph.

For graphs of bounded clique-width, the longest path can also be solved by a polynomial time dynamic programming algorithm. However, the exponent of the polynomial depends on the clique-width of the graph, so this algorithms is not fixed-parameter tractable. The longest path problem, parameterized by clique-width, is hard for the parameterized complexity class , showing that a fixed-parameter tractable algorithm is unlikely to exist.[14]

Special classes of graphs

The longest path problem may be solved in polynomial time on the complements of comparability graphs.[15] It may also be solved in polynomial time on any class of graphs with bounded treewidth or bounded clique-width, such as the distance-hereditary graphs. However, it is NP-hard even when restricted to split graphs, circle graphs, or planar graphs.[16]

See also

References

  1. Schrijver, Alexander (2003), Combinatorial Optimization: Polyhedra and Efficiency, Volume 1, Algorithms and Combinatorics, 24, Springer, p. 114, ISBN 9783540443896.
  2. Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford (2001), Introduction To Algorithms (2nd ed.), MIT Press, p. 978, ISBN 9780262032933.
  3. Lawler, Eugene L. (2001), Combinatorial Optimization: Networks and Matroids, Courier Dover Publications, p. 64, ISBN 9780486414539.
  4. 1 2 3 Sedgewick, Robert; Wayne, Kevin Daniel (2011), Algorithms (4th ed.), Addison-Wesley Professional, pp. 661–666, ISBN 9780321573513.
  5. Di Battista, Giuseppe; Eades, Peter; Tamassia, Roberto; Tollis, Ioannis G. (1998), "Layered Drawings of Digraphs", Graph Drawing: Algorithms for the Visualization of Graphs, Prentice Hall, pp. 265–302, ISBN 978-0-13-301615-4.
  6. 1 2 Björklund, Andreas; Husfeldt, Thore; Khanna, Sanjeev (2004), "Approximating longest directed paths and cycles", Proc. Int. Coll. Automata, Languages and Programming (ICALP 2004), Lecture Notes in Computer Science, 3142, Berlin: Springer-Verlag, pp. 222–233, MR 2160935.
  7. Gabow, Harold N.; Nie, Shuxin (2008), "Finding long paths, cycles and circuits", International Symposium on Algorithms and Computation, Lecture Notes in Computer Science, 5369, Berlin: Springer, pp. 752–763, doi:10.1007/978-3-540-92182-0_66, MR 2539968. For earlier work with even weaker approximation bounds, see Gabow, Harold N. (2007), "Finding paths and cycles of superpolylogarithmic length" (PDF), SIAM Journal on Computing, 36 (6): 1648–1671, doi:10.1137/S0097539704445366, MR 2299418 and Björklund, Andreas; Husfeldt, Thore (2003), "Finding a path of superlogarithmic length", SIAM Journal on Computing, 32 (6): 1395–1402, doi:10.1137/S0097539702416761, MR 2034242.
  8. Karger, David; Motwani, Rajeev; Ramkumar, G. D. S. (1997), "On approximating the longest path in a graph", Algorithmica, 18 (1): 82–98, doi:10.1007/BF02523689, MR 1432030.
  9. 1 2 Alon, Noga; Yuster, Raphael; Zwick, Uri (1995), "Color-coding", Journal of the ACM, 42 (4): 844–856, doi:10.1145/210332.210337, MR 1411787.
  10. Bodlaender, Hans L. (1993), "On linear time minor tests with depth-first search", Journal of Algorithms, 14 (1): 1–23, doi:10.1006/jagm.1993.1001, MR 1199244. For an earlier FPT algorithm with slightly better dependence on the path length, but worse dependence on the size of the graph, see Monien, B. (1985), "How to find long paths efficiently", Analysis and design of algorithms for combinatorial problems (Udine, 1982), North-Holland Math. Stud., 109, Amsterdam: North-Holland, pp. 239–254, doi:10.1016/S0304-0208(08)73110-4, MR 808004.
  11. Chen, Jianer; Lu, Songjian; Sze, Sing-Hoi; Zhang, Fenghui (2007), "Improved algorithms for path, matching, and packing problems", Proc. 18th ACM-SIAM Symposium on Discrete algorithms (SODA '07) (PDF), pp. 298–307.
  12. Koutis, Ioannis (2008), "Faster algebraic algorithms for path and packing problems", International Colloquium on Automata, Languages and Programming (PDF), Lecture Notes in Computer Science, 5125, Berlin: Springer, pp. 575–586, doi:10.1007/978-3-540-70575-8_47, MR 2500302.
  13. Williams, Ryan (2009), "Finding paths of length k in O*(2k) time", Information Processing Letters, 109 (6): 315–318, arXiv:0807.3026Freely accessible, doi:10.1016/j.ipl.2008.11.004, MR 2493730.
  14. Fomin, Fedor V.; Golovach, Petr A.; Lokshtanov, Daniel; Saurabh, Saket (2009), "Clique-width: on the price of generality", Proc. 20th ACM-SIAM Symposium on Discrete Algorithms (SODA '09) (PDF), pp. 825–834.
  15. Ioannidou, Kyriaki; Nikolopoulos, Stavros D. (2011), "The longest path problem is polynomial on cocomparability graphs" (PDF), Algorithmica, doi:10.1007/s00453-011-9583-5. For earlier work on more restrictive subclasses of co-comparability graphs, see Ioannidou, Kyriaki; Mertzios, George B.; Nikolopoulos, Stavros D. (2011), "The longest path problem has a polynomial solution on interval graphs" (PDF), Algorithmica, 61 (2): 320–341, doi:10.1007/s00453-010-9411-3, MR 2822187 and Uehara, Ryuhei; Valiente, Gabriel (2007), "Linear structure of bipartite permutation graphs and the longest path problem", Information Processing Letters, 103 (2): 71–77, doi:10.1016/j.ipl.2007.02.010, MR 2322071.
  16. Ioannidou, Mertzios & Nikolopoulos (2011).

External links

This article is issued from Wikipedia - version of the 10/22/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.