def dijkstra1(successors, other_node):
vertices : length = successors
n = len(successors)
S = []
S.append(0)
L = dict()
L[0] = 0
P = dict()
P[0] = '-'
for vertex in vertices:
L[vertex] = float("inf")
P[vertex] = None
dist[source] = 0
Q = set(vertices)
while len(Q) > 0:
u = minimum_distance(dist, Q)
print('Currently considering', u, 'with a distance of', dist[u])
Q.remove(u)
if L[u] == float('inf'):
break
n = get_neighbours(graph, u)
for vertex in n:
alt = dist[u] + dist_between(graph, u, vertex)
if alt < L[vertex]:
L[vertex] = alt
P[vertex] = u
return L[other_node]says that the L[vertex]=float["inf"] is a unhashable type 'dict'. What does that mean and how do I fix it?
Whats wrong with this code?
Users browsing this thread: 1 Guest(s)
