コード例 #1
0
      [4, 2, 1663], [4, 3, 599], [4, 5, 533], [4, 7, 1260],
        [4, 8, 864], [4, 10, 496],
      [5, 0, 2097], [5, 3, 1003], [5, 4, 533], 
        [5, 6, 983], [5, 7, 787],
      [6, 5, 983], [6, 7, 214],
      [7, 4, 1260], [7, 5, 787], [7, 6, 214], [7, 8, 888],
      [8, 4, 864], [8, 7, 888], [8, 9, 661], 
        [8, 10, 781], [8, 11, 810],
      [9, 8, 661], [9, 11, 1187],
      [10, 2, 1435], [10, 4, 496], [10, 8, 781], [10, 11, 239],
      [11, 8, 810], [11, 9, 1187], [11, 10, 239]
    ]

# Create a graph
graph1 = WeightedGraph(vertices, edges)
print("The number of vertices in graph1: " + str(graph1.getSize()))
print("The vertex with index 1 is " + graph1.getVertex(1))
print("The index for Miami is " + str(graph1.getIndex("Miami")))
print("The edges for graph1: ")
graph1.printWeightedEdges()

# Create vertices and edges
vertices = [x for x in range(5)]
edges = [
      [0, 1, 2], [0, 3, 8], 
      [1, 0, 2], [1, 2, 7], [1, 3, 3],
      [2, 1, 7], [2, 3, 4], [2, 4, 5],
      [3, 0, 8], [3, 1, 3], [3, 2, 4], [3, 4, 6],
      [4, 2, 5], [4, 3, 6]
    ]
graph2 = WeightedGraph(vertices, edges) # Create a graph