Skip to content

Instantly share code, notes, and snippets.

@luccasiau
Created May 9, 2015 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luccasiau/de9f253d790b7c768dd6 to your computer and use it in GitHub Desktop.
Save luccasiau/de9f253d790b7c768dd6 to your computer and use it in GitHub Desktop.
// inicializamos o nível de cada vertice como sendo igual a -1
// antes de chamar a DFS em 1 (a raiz), colocamos seu nivel igual a 0
DFS(vértice U):
para todo vértice V vizinho de U:
se (nivel[V] == -1):
pai[V] := U
nivel[V] := nivel[U] + 1
DFS(V)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment