Exemplo n.º 1
0
    if command == '1':
        print("There are %i vertices." % G.numberOfVertices())
    elif command == '2':
        source = int(input("source: "))
        target = int(input("target: "))

        G.isEdge(source, target)
        """
        if G.isEdge(source, target):
            print("Edge exists.")
        else:
            print("Edge doesn't exist.")
        """
    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: "))