Created
November 19, 2011 18:17
-
-
Save juanplopes/1379161 to your computer and use it in GitHub Desktop.
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
T = {} | |
T[1] = (2,3,4) | |
T[2] = (3,) | |
T[4] = (2,) | |
visitei = [0] * 10 | |
ordenacao = [] | |
def visitar(tarefa): | |
visitei[tarefa] = 1 | |
if tarefa in T: | |
for outra_tarefa in T[tarefa]: | |
if visitei[outra_tarefa] == 1: | |
raise "ciclo" | |
if not visitei[outra_tarefa]: | |
visitar(outra_tarefa) | |
visitei[tarefa] = 2 | |
ordenacao.append(tarefa) | |
visitar(1) | |
print ordenacao |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment