@@ -14,22 +14,22 @@ def __init__(self) -> None:
14
14
self .graph : dict [str , list [tuple [str , int ]]] = {}
15
15
16
16
# add vertices for a graph
17
- def add_vertices (self , u :int ) -> None :
17
+ def add_vertices (self , u : int ) -> None :
18
18
"""
19
19
Adds a vertex `u` to the graph with an empty adjacency list.
20
20
"""
21
21
self .graph [u ] = []
22
22
23
23
# assign weights for each edges formed of the directed graph
24
- def add_edge (self , u :str , v :str , w :int ) -> None :
24
+ def add_edge (self , u : str , v : str , w : int ) -> None :
25
25
"""
26
26
Adds a directed edge from vertex `u` to vertex `v` with weight `w`.
27
27
"""
28
28
self .edges .append ((u , v , w ))
29
29
self .graph [u ].append ((v , w ))
30
30
31
31
# perform a dijkstra algorithm on a directed graph
32
- def dijkstra (self , s :str ) -> dict :
32
+ def dijkstra (self , s : str ) -> dict :
33
33
"""
34
34
Computes the shortest path from vertex `s` to all other vertices using Dijkstra's algorithm.
35
35
"""
@@ -49,7 +49,7 @@ def dijkstra(self, s:str) -> dict:
49
49
return distances
50
50
51
51
# carry out the bellman ford algorithm for a node and estimate its distance vector
52
- def bellman_ford (self , s :str ) -> dict :
52
+ def bellman_ford (self , s : str ) -> dict :
53
53
"""
54
54
Computes the shortest path from vertex `s` to all other vertices using the Bellman-Ford algorithm.
55
55
"""
0 commit comments