Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions graphs/breadth_first_search_shortest_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class Graph:
def __init__(self, graph: Dict[str, str], source_vertex: str) -> None:
"""Graph is implemented as dictionary of adjancency lists. Also,
"""Graph is implemented as dictionary of adjacency lists. Also,
Source vertex have to be defined upon initialization.
"""
self.graph = graph
Expand All @@ -37,11 +37,11 @@ def breath_first_search(self) -> None:

while queue:
vertex = queue.pop(0)
for adjancent_vertex in self.graph[vertex]:
if adjancent_vertex not in visited:
visited.add(adjancent_vertex)
self.parent[adjancent_vertex] = vertex
queue.append(adjancent_vertex)
for adjacent_vertex in self.graph[vertex]:
if adjacent_vertex not in visited:
visited.add(adjacent_vertex)
self.parent[adjacent_vertex] = vertex
queue.append(adjacent_vertex)

def shortest_path(self, target_vertex: str) -> str:
"""This shortest path function returns a string, describing the result:
Expand Down