Skip to content

Commit 78cbb85

Browse files
committed
Added comment to dijsktra algorithm
1 parent 0ec1912 commit 78cbb85

File tree

1 file changed

+3
-1
lines changed
  • Algorithms/Graph Algorithms/Shortest Path Algorithm/Dijkstra's Algorithm/Python

1 file changed

+3
-1
lines changed

Algorithms/Graph Algorithms/Shortest Path Algorithm/Dijkstra's Algorithm/Python/dijkstra.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def dijsktra(adj, vert):
4141
distance = [0] * len(adj[vert])
4242
processed = [False] * len(adj[vert])
4343

44+
# Initializes the distance array of initial vertex with values from the adjacency matrix
45+
# if the edge is unexistent (-1), sets the distance as maxsize
4446
for i in range(len(adj[vert])):
4547
if adj[vert][i] == -1:
4648
distance[i] = sys.maxsize
@@ -114,4 +116,4 @@ def test_directed():
114116
printSolution(shortest)
115117

116118
test_undirect()
117-
test_directed()
119+
test_directed()

0 commit comments

Comments
 (0)