Created
June 17, 2013 23:18
-
-
Save lyaotian/5801382 to your computer and use it in GitHub Desktop.
Depth-first Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| procedure DFS(G,v): | |
| label v as explored | |
| for all edges e in G.adjacentEdges(v) do | |
| if edge e is unexplored then | |
| w ← G.adjacentVertex(v,e) | |
| if vertex w is unexplored then | |
| label e as a discovery edge | |
| recursively call DFS(G,w) | |
| else | |
| label e as a back edge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment