@@ -28,7 +28,7 @@ def get_vertex(self):
28
28
for v in self .adjacency_list :
29
29
yield v
30
30
31
- def get_edge (self , vertex ):
31
+ def get_neighbor (self , vertex ):
32
32
"""
33
33
Generator for returning the next vertex adjacent to the given vertex
34
34
:param vertex:
@@ -60,7 +60,7 @@ def dfs(self):
60
60
while to_visit :
61
61
v = to_visit .pop ()
62
62
63
- for neighbor in self .get_edge (v ):
63
+ for neighbor in self .get_neighbor (v ):
64
64
if neighbor not in parents :
65
65
parents [neighbor ] = v
66
66
to_visit .append (neighbor )
@@ -82,7 +82,7 @@ def bfs(self):
82
82
while not to_visit .empty ():
83
83
v = to_visit .get ()
84
84
85
- for neighbor in self .get_edge (v ):
85
+ for neighbor in self .get_neighbor (v ):
86
86
if neighbor not in parents :
87
87
parents [neighbor ] = v
88
88
to_visit .put (neighbor )
@@ -113,7 +113,7 @@ def contains_cycle(self):
113
113
statuses [v ] = STATUS_STARTED
114
114
to_visit .append (v ) # add to stack again to signal vertex has finished DFS
115
115
116
- for u in self .get_edge (v ):
116
+ for u in self .get_neighbor (v ):
117
117
if u in statuses :
118
118
if statuses [u ] == STATUS_STARTED :
119
119
contains_cycle = True
@@ -152,7 +152,7 @@ def topological_sort(self):
152
152
statuses [v ] = STATUS_STARTED
153
153
to_visit .append (v ) # add to stack again to signal vertex has finished DFS
154
154
155
- for u in self .get_edge (v ):
155
+ for u in self .get_neighbor (v ):
156
156
if u not in statuses :
157
157
to_visit .append (u )
158
158
0 commit comments