previous | start | next

Longest Paths

How do you find longest paths from a source vertex in an edge weighted graph?

DijkstraSP doesn't help.

AcyclicSP does with a simple observation.

Switch to a copy of the graph, but with all the edge weights negated.

Find the shortest path in the copy.

The same sequence of vertices will be a longest path in the original graph!

AcyclicSP - finds shortest paths

AcyclicLP - finds longest paths



previous | start | next