Module dsa.dijkstras
Module to access functions for Dijkstra's Algorithm.
Functions
def find_path(graph: AdjacencyListWeightedGraph, start: str, end: str, debug: bool = False) ‑> list
-
Return the shortest path of two vertices using Dijkstra's Algorithm.
Args
graph
:AdjacencyListWeighted Graph
- The graph to search.
start
:str
- The starting vertex label.
end
:str
- The ending vertex label.
debug
:bool
- If True, display the weight table.
Returns
A list of vertices that form a shortest path.
def shortest_path(graph: AdjacencyListWeightedGraph, start: str, end: str, debug: bool = False) ‑> tuple
-
Helper function that returns a weight table and a predecessor table using Dijkstra's Algorithm.
Args
graph
:AdjacencyListWeighted Graph
- The graph to search.
start
:str
- The starting vertex label.
end
:str
- The ending vertex label.
debug
:bool
- If True, display weight table as it is being built.
Returns
A tuple of a weight table hashtable and a predecesor hashtable.