Advertisement
dtung

Pseudo code of topological sort

May 16th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. procedure DFS(G, v) is
  2. label v as discovered
  3. for all directed edges from v to w that are in G.adjacentEdges(v) do
  4. if vertex w is not labeled as discovered then
  5. recursively call DFS(G, w)
  6. inverse_topo[i++] = v // post-processing, i start with 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement