File tree 3 files changed +27
-2
lines changed
3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def edges_print(self):
85
85
def outdegree (self , v ):
86
86
count = 0
87
87
for j in range (self ._vertices ):
88
- if self ._adjacent_matrix [v ][j ] != 0 :
88
+ if not self ._adjacent_matrix [v ][j ] != 0 :
89
89
count = count + 1
90
90
return count
91
91
Original file line number Diff line number Diff line change
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 )
9
+ G .insert_edge (0 ,2 )
10
+ G .insert_edge (1 ,2 )
11
+ G .insert_edge (2 ,3 )
12
+ G .display_adjacent_matrix ()
13
+ print ('Vertices:' , G .vertex_count ())
14
+ print ('Edges:' , G .edge_count ())
15
+ G .edges_print ()
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
+ G .display_adjacent_matrix ()
22
+ G .remove_edge (1 ,2 )
23
+ print ('Graph Adjacency Matrix' )
24
+ G .display_adjacent_matrix ()
25
+ print ('Edges between 1--2:' , G .exist_edge (1 ,2 ))
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def edges_print(self):
39
39
def outdegree (self , v ):
40
40
count = 0
41
41
for j in range (self ._vertices ):
42
- if self ._adjacent_matrix [v ][j ] != 0 :
42
+ if not self ._adjacent_matrix [v ][j ] != 0 :
43
43
count = count + 1
44
44
return count
45
45
You can’t perform that action at this time.
0 commit comments