Created
May 5, 2015 20:19
-
-
Save luccasiau/9025683f44d7181f3f02 to your computer and use it in GitHub Desktop.
This file contains 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
// o código a seguir é uma BFS partindo do vértice X | |
// o array componente está inicializado para -1 em todas suas casas | |
fila.insere(X) | |
componente[X] := valor | |
enquanto (fila.tamanho > 0) faça: | |
//vamos trabalhar com o primeiro da fila | |
V = fila.frente | |
fila.remove_frente | |
para todo Y vizinho de V, faça: | |
se (componente[Y] = -1): | |
componente[Y] = componente[V] | |
fila.insere(Y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment