Last active
June 13, 2019 15:24
-
-
Save MLWhiz/a8bfb10a3101c45493934d8c1bd8c662 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
graph = Graph (g)
in this line I get that it is not defined and I do not execute
I am new at this