We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f31a3a5 commit 9f8973dCopy full SHA for 9f8973d
Section_12(Graphs)/weighted-directed-graph-demo.py
@@ -0,0 +1,25 @@
1
+from graph import Graph
2
+
3
+G = Graph(4)
4
+G.display_adjacent_matrix()
5
+print('Vertices:', G.vertex_count())
6
+print('Edges:', G.edge_count())
7
+G.edges_print()
8
+G.insert_edge(0,1, 26)
9
+G.insert_edge(0,2, 16)
10
+G.insert_edge(1,2, 12)
11
+G.insert_edge(2,3, 8)
12
13
14
15
16
+print('Edge 1 - 3', G.exist_edge(1,3))
17
+print('Edge 1 - 2', G.exist_edge(1,2))
18
+print('Indegree 2', G.indegree(2))
19
+print('Outdegree 2', G.outdegree(2))
20
+print('Graph Adjacency Matrix')
21
22
+G.remove_edge(1,2)
23
24
25
+print('Edges between 1--2:', G.exist_edge(1,2))
0 commit comments