for all v in V do num[v] = 0, stack[v]=false for all v in V do if num[v]==0 DFS(v) k = 0; DFS(v) { k++; num[v] = k; stack[v]=true for all w in adj(v) do if num[w]==0 DFS(w) tree edge else if num[w] > num[v] forward edge else if stack[w] back edge else cross edge stack [v]=false }