Skip to content

Instantly share code, notes, and snippets.

@luccasiau
Created May 5, 2015 20:20
Show Gist options
  • Save luccasiau/edd0b6efe259b9621681 to your computer and use it in GitHub Desktop.
Save luccasiau/edd0b6efe259b9621681 to your computer and use it in GitHub Desktop.
// componente[i] se trata da componente do vértice i
// inicialmente, componente[i] = -1 para todo vértice
// faremos a DFS como sendo uma função recursiva
// antes de chamar a DFS no primeiro nó, definimos sua componente
DFS(vértice X):
para todo V vizinho a X:
se (componente[V] == -1):
componente[V] = componente[X]
DFS(V)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment