Graph Theory37 sections · 1633 units
Open in Course

Negative Cycles: The Trap

(Not always infinite)

A negative cycle does not guarantee distance = -∞ to all nodes. If the cycle is not reachable on the path to a target, the distance stays finite.

Example: Node 11 → Node 55 has distance 1010. A negative cycle exists between nodes 22, 33, 44, but they are not on the 1155 path. Distance to 55 is still 1010.

Check which nodes are affected before concluding -∞. Run BFS from each node in a negative cycle to mark all reachable nodes as having distance -\infty.