A negative-cost directed cycle matters to a particular destination precisely when it is reachable from and can itself reach .[ref] Repeating it times adds times its negative total cost to a route. Thus the infimum of directed walk costs is , rather than the cost of a finite shortest directed walk. The distinction is about reachability, not simply the presence of a negative edge or a negative-cost directed cycle anywhere in the graph.
Add of weight to the worked example. Now has total weight . Add also an isolated vertex with a self-loop of weight . From , the distances of are , because all four are reachable from the first negative-cost directed cycle. The source retains distance : no directed edge leads back to . The unreachable retains distance , despite its negative-cost self-loop.
Figure 1.
Relevant negative-cost directed cycles: descendants from a source become ancestors when every directed edge is reversed
. Details.
For example, extra laps before proceeding to give costs . This construction also shows why requiring a directed path with no repeated vertices would change the problem: only directed walks permit arbitrarily many laps. Merely finding one reachable negative-cost directed cycle does not justify setting every reachable label to ; in the figure is a counterexample.
To detect and classify, perform full passes without clamping any label, then test all directed edges against a fixed copy of the resulting labels. Collect heads of edges satisfying and . An empty collection certifies that no negative-cost directed cycle is reachable from . Otherwise run graph search forwards from all collected vertices: precisely the reached vertices have distance . A vertex unreachable from still has distance ; each remaining vertex has its finite shortest distance.
Why is this classification exact? Every unaffected reachable vertex already has its shortest distance after passes, since any route ending there avoids reachable negative-cost directed cycles. Thus it cannot be the head of a strict improvement, or be reached from such a head. Conversely, all vertices on a reachable negative-cost directed cycle have finite labels by that time. If none of its edges could improve a label, summing around it would imply . At least one of its heads is therefore collected, and the forward graph search reaches the entire directed cycle and every affected descendant. Detecting a directed cycle alone and marking its descendants are separate tasks; finite intermediate labels in the affected region are not answers.

Articles by others on the same topic (0)

There are currently no matching articles.