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):
7
7
self .count = 0
8
8
9
9
def print_graph (self ):
10
+ ''' for printing the contents of the graph '''
10
11
for i in self .graph :
11
12
print (i ,'->' ,' -> ' .join ([str (j ) for j in self .graph [i ]]))
12
13
@@ -28,6 +29,7 @@ def get_code(self):
28
29
29
30
class TopologicalSort (Graph ):
30
31
def topological_sort (self ):
32
+ ''' function for sorting graph elements using topological sort '''
31
33
visited = [False ] * self .count # Marking all vertices as not visited
32
34
stack = [] # Stack for storing the vertex
33
35
for vertex in range (self .count ):
@@ -37,9 +39,8 @@ def topological_sort(self):
37
39
38
40
return stack
39
41
40
- # Recursive function for topological Sort
41
42
def topological_sort_rec (self , vertex , visited , stack ):
42
-
43
+ ''' Recursive function for topological Sort '''
43
44
# Mark the current node in visited
44
45
visited [vertex ] = True
45
46
You can’t perform that action at this time.
0 commit comments