graphs.dijkstra_alternate

Attributes

graph

Classes

Graph

Module Contents

class graphs.dijkstra_alternate.Graph(vertices: int)
dijkstra(source: int) None

Function that implements Dijkstra’s single source shortest path algorithm for a graph represented using adjacency matrix representation.

>>> Graph(4).dijkstra(1)  
Vertex  Distance from Source
0                10000000
1                0
2                10000000
3                10000000
minimum_distance(distances_from_source: list[int], visited: list[bool]) int

A utility function to find the vertex with minimum distance value, from the set of vertices not yet included in shortest path tree.

>>> Graph(3).minimum_distance([1, 2, 3], [False, False, True])
0
print_solution(distances_from_source: list[int]) None
>>> Graph(0).print_solution([])  
Vertex   Distance from Source
graph
vertices
graphs.dijkstra_alternate.graph