AlgoMaster Logo

Detect Cycle in Directed Graph (DFS)

n=5,edges=[[0,1],[1,2],[2,3],[3,1],[4,0]]
0 / 14
01234Legend:WHITEGRAYBLACKCycle
algomaster.io
Step:Start: Detect cycle in directed graph using DFS 3-color marking (WHITE/GRAY/BLACK)