mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Fix typo: Adjancent -> Adjacent (#2184)
This commit is contained in:
parent
367f8ceddd
commit
728c0df355
@ -16,7 +16,7 @@ graph = {
|
|||||||
|
|
||||||
class Graph:
|
class Graph:
|
||||||
def __init__(self, graph: Dict[str, str], source_vertex: str) -> None:
|
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.
|
Source vertex have to be defined upon initialization.
|
||||||
"""
|
"""
|
||||||
self.graph = graph
|
self.graph = graph
|
||||||
@ -37,11 +37,11 @@ class Graph:
|
|||||||
|
|
||||||
while queue:
|
while queue:
|
||||||
vertex = queue.pop(0)
|
vertex = queue.pop(0)
|
||||||
for adjancent_vertex in self.graph[vertex]:
|
for adjacent_vertex in self.graph[vertex]:
|
||||||
if adjancent_vertex not in visited:
|
if adjacent_vertex not in visited:
|
||||||
visited.add(adjancent_vertex)
|
visited.add(adjacent_vertex)
|
||||||
self.parent[adjancent_vertex] = vertex
|
self.parent[adjacent_vertex] = vertex
|
||||||
queue.append(adjancent_vertex)
|
queue.append(adjacent_vertex)
|
||||||
|
|
||||||
def shortest_path(self, target_vertex: str) -> str:
|
def shortest_path(self, target_vertex: str) -> str:
|
||||||
"""This shortest path function returns a string, describing the result:
|
"""This shortest path function returns a string, describing the result:
|
||||||
|
Loading…
Reference in New Issue
Block a user