MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

graphs/breadth_first_search_shortest_path.py:19–27  ·  view source on GitHub ↗

Graph is implemented as dictionary of adjacency lists. Also, Source vertex have to be defined upon initialization.

(self, graph: dict[str, list[str]], source_vertex: str)

Source from the content-addressed store, hash-verified

17
18class Graph:
19 def __init__(self, graph: dict[str, list[str]], source_vertex: str) -> None:
20 """
21 Graph is implemented as dictionary of adjacency lists. Also,
22 Source vertex have to be defined upon initialization.
23 """
24 self.graph = graph
25 # mapping node to its parent in resulting breadth first tree
26 self.parent: dict[str, str | None] = {}
27 self.source_vertex = source_vertex
28
29 def breath_first_search(self) -> None:
30 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected