Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- g = { "a" : {"d":2},
- "b" : {"c":2},
- "c" : {"b":5, "d":3, "e":5}
- }
- graph = Graph(g)
- print("Vertices of graph:")
- print(graph.vertices())
- print("Edges of graph:")
- print(graph.edges())
- print("Add vertex:")
- graph.add_vertex("z")
- print("Vertices of graph:")
- print(graph.vertices())
- print("Add an edge:")
- graph.add_edge({"a","z"})
- print("Vertices of graph:")
- print(graph.vertices())
- print("Edges of graph:")
- print(graph.edges())
- print('Adding an edge {"x","y"} with new vertices:')
- graph.add_edge({"x","y"})
- print("Vertices of graph:")
- print(graph.vertices())
- print("Edges of graph:")
- print(graph.edges())
Add Comment
Please, Sign In to add comment