⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 22s17 days 22 hours 20 minutes 22 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 22s17 days 22 hours 20 minutes 22 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.