Skip to content

Commit 2a552ca

Browse files
committed
Added docstrings
1 parent d83c2b9 commit 2a552ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pygorithm/data_structures/graph.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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

2930
class 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

0 commit comments

Comments
 (0)