Category : adjacency-matrix

I have tried to implement the Dijkstra algorithm in python as: from collections import defaultdict class Graph: def minDistance(self,dist,queue): minimum = float("Inf") min_index = -1 for i in range(len(dist)): if dist[i] < minimum and i in queue: minimum = dist[i] min_index = i return min_index def printPath(self, parent, j): if parent[j] == -1 : print ..

Read more

I have tried to implement the Dijkstra algorithm in python as: from collections import defaultdict class Graph: def minDistance(self,dist,queue): minimum = float("Inf") min_index = -1 for i in range(len(dist)): if dist[i] < minimum and i in queue: minimum = dist[i] min_index = i return min_index def printPath(self, parent, j): if parent[j] == -1 : print ..

Read more