File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 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):
8585 def  outdegree (self , v ):
8686 count  =  0 
8787 for  j  in  range (self ._vertices ):
88-  if  self ._adjacent_matrix [v ][j ] !=  0 :
88+  if  not   self ._adjacent_matrix [v ][j ] !=  0 :
8989 count  =  count  +  1 
9090 return  count 
9191
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):
3939 def  outdegree (self , v ):
4040 count  =  0 
4141 for  j  in  range (self ._vertices ):
42-  if  self ._adjacent_matrix [v ][j ] !=  0 :
42+  if  not   self ._adjacent_matrix [v ][j ] !=  0 :
4343 count  =  count  +  1 
4444 return  count 
4545
                         You can’t perform that action at this time. 
           
                  
0 commit comments