Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dijkstra (G,inicio):
- dicc={inicio:0}
- parent={}
- queue=[]
- queue.append(inicio)
- while len(queue) >0:
- v=queue.pop(0)
- for s,t,w in G.outgoing_edge_iterator(v):
- weight=dicc[v]+w
- if not t in dicc:
- parent[t]=v
- dicc[t]=weight
- queue.append(t)
- else:
- if weight<dicc[t]:
- parent[t]=v
- dicc[t]=weight
- return dicc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement