Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 50s1 days 16 hours 1 minutes 50 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 50s1 days 16 hours 1 minutes 50 seconds.

Sign in to watch this lesson
Algorithms - Graphs I · 4:45
A deadlock is a cycle in the wait-for graph, and a depth-first search with three colours finds one: in a directed graph, an edge into a gray vertex (one still on the current path) closes a cycle, while an edge into a black, finished vertex never does. Parent pointers then rebuild the cycle itself, 1 2 3 1 on our example. Undirected graphs need only a visited flag plus skipping the edge you arrived on (by edge id, for parallel edges), and functional graphs split into one cycle with trees flowing in.