File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
pygorithm/data_structures Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ def __init__(self):
77 self .count = 0
88
99 def print_graph (self ):
10+ ''' for printing the contents of the graph '''
1011 for i in self .graph :
1112 print (i ,'->' ,' -> ' .join ([str (j ) for j in self .graph [i ]]))
1213
@@ -28,6 +29,7 @@ def get_code(self):
2829
2930class TopologicalSort (Graph ):
3031 def topological_sort (self ):
32+ ''' function for sorting graph elements using topological sort '''
3133 visited = [False ] * self .count # Marking all vertices as not visited
3234 stack = [] # Stack for storing the vertex
3335 for vertex in range (self .count ):
@@ -37,9 +39,8 @@ def topological_sort(self):
3739
3840 return stack
3941
40- # Recursive function for topological Sort
4142 def topological_sort_rec (self , vertex , visited , stack ):
42-
43+ ''' Recursive function for topological Sort '''
4344 # Mark the current node in visited
4445 visited [vertex ] = True
4546
You can’t perform that action at this time.
0 commit comments