Guest User

Untitled

a guest
Jan 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. g = { "a" : {"d":2},
  2. "b" : {"c":2},
  3. "c" : {"b":5, "d":3, "e":5}
  4. }
  5. graph = Graph(g)
  6. print("Vertices of graph:")
  7. print(graph.vertices())
  8. print("Edges of graph:")
  9. print(graph.edges())
  10. print("Add vertex:")
  11. graph.add_vertex("z")
  12. print("Vertices of graph:")
  13. print(graph.vertices())
  14. print("Add an edge:")
  15. graph.add_edge({"a","z"})
  16. print("Vertices of graph:")
  17. print(graph.vertices())
  18. print("Edges of graph:")
  19. print(graph.edges())
  20. print('Adding an edge {"x","y"} with new vertices:')
  21. graph.add_edge({"x","y"})
  22. print("Vertices of graph:")
  23. print(graph.vertices())
  24. print("Edges of graph:")
  25. print(graph.edges())
Add Comment
Please, Sign In to add comment