コード例 #1
0
ファイル: main.py プロジェクト: harababurel/homework
 elif command == '3':
     x = int(input("vertex: "))
     print("inDegree: %i" % G.inDegree(x))
     print("outDegree: %i" % G.outDegree(x))
 elif command == '4':
     x = int(input("vertex: "))
     print("out edges: %s" % ', '.join([str(y[0]) for y in G.outboundEdges(x)]))
 elif command == '5':
     x = int(input("vertex: "))
     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()