MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / Dijkstra

Function Dijkstra

Graphs/dijkstra_2.py:21–36  ·  view source on GitHub ↗
(graph, V, src)

Source from the content-addressed store, hash-verified

19 return minInd
20
21def Dijkstra(graph, V, src):
22 mdist=[float('inf') for i in range(V)]
23 vset = [False for i in range(V)]
24 mdist[src] = 0.0
25
26 for i in range(V-1):
27 u = minDist(mdist, vset, V)
28 vset[u] = True
29
30 for v in range(V):
31 if (not vset[v]) and graph[u][v]!=float('inf') and mdist[u] + graph[u][v] < mdist[v]:
32 mdist[v] = mdist[u] + graph[u][v]
33
34
35
36 printDist(mdist, V)
37
38
39

Callers 1

dijkstra_2.pyFile · 0.85

Calls 2

minDistFunction · 0.85
printDistFunction · 0.70

Tested by

no test coverage detected