Created
April 17, 2017 02:48
-
-
Save thbighead/e4fcd0b7f95d88e3fd5a0056648fc399 to your computer and use it in GitHub Desktop.
Calcular a transposicao de um digrafo feito com Python
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
def transpor_digrafo(digrafo): | |
digrafo_t = {} | |
for vertice in digrafo: | |
digrafo_t[vertice] = [] | |
for vertice in digrafo: | |
for vizinho in digrafo[vertice]: | |
digrafo_t[vizinho].append(vertice) | |
return digrafo_t | |
digrafo = { | |
'a': ['c', 'd', 'f'], | |
'b': ['a'], | |
'c': ['b'], | |
'd': ['e', 'f'], | |
'e': [], | |
'f': ['e'] | |
} | |
print transpor_digrafo(digrafo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment