Exemplo n.º 1
0
     print("in edges: %s" % ', '.join([str(y[0]) for y in G.inboundEdges(x)]))
 elif command == '6':
     x = int(input("vertex: "))
     G.addNode(x)
 elif command == '7':
     x = int(input("vertex: "))
     G.removeVertex(x)
 elif command == '8':
     source = int(input("source: "))
     target = int(input("target: "))
     weight = int(input("weight: "))
     G.addEdge(source, target, weight)
 elif command == '9':
     source = int(input("source: "))
     target = int(input("target: "))
     G.removeEdge(source, target)
 elif command == '10':
     source = int(input("source: "))
     target = int(input("target: "))
     print(G.Dijkstra(source)[target])
 elif command == '11':
     components = G.connectedComponents()
     for comp in components:
         print(comp)
     print("There are %i connected components." % len(components))
 elif command == '12':
     components = G.scc()
     for comp in components:
         print(comp)
     print("There are %i strongly connected components." % len(components))
 elif command == '0':