Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. def __caminhos_incidentes_no_grafo(self):
  2. '''
  3. A partir do grafo dado, cria todos os caminhos dentro desse grafo.
  4. :return: Uma lista com todas os caminhos no formato V + '-' + V
  5. '''
  6. caminhos = []
  7. for i in range(len(self.N)):
  8. for j in range(len(self.N)):
  9. if self.M[i][j] != '-':
  10. if self.M[i][j] >= self.M[i][j]:
  11. if self.M[i][j] != 0:
  12. for k in range(self.M[i][j]):
  13. caminhos.append(self.N[i] + self.SEPARADOR_ARESTA + self.N[j])
  14. return caminhos
  15.  
  16. def arestas_sobre_vertice(self, vertice):
  17. caminhos = self.__caminhos_incidentes_no_grafo()
  18. final = []
  19. for i in caminhos:
  20. v = i.split(Grafo.SEPARADOR_ARESTA)
  21. if v[0] == vertice or v[1] == vertice:
  22. final.append(v[0] + self.SEPARADOR_ARESTA + v[1])
  23. return final
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement