DEV Community

loading...

Discussion on: Dijkstra's algorithm in python: algorithms for beginners

Collapse
mistertellini profile image
Aitor López

Hello Maria,

First of all, thank you for taking the time to share your knowledge with all of us! I am sure that your code will be of much use to many people, me amongst them!

I actually have two questions.

First: do you know -or do you have heard of- how to change the weights of your graph after each movement?
In my case, I would like to impede my graph to move through certain edges setting them to 'Inf' in each iteration (later, I would remove these 'Inf' values and set them to other ones.

Second: Do you know how to include restrictions to Dijkstra, so that the path between certain vertices goes through a fixed number of edges?

Many thanks in advance, and best regards!

Collapse
mistertellini profile image
Aitor López

Hello back,

I was finally able to find a solution to change the weights dynamically during the search process, however, I am still not sure about how to impose the condition of having a path of length >= N, being N the number of traversed edges. The only idea I have come up with would consist on turning to infinity the last edge towards my destination vertex if the overall distance lies below N. However, this would make this edge no longer available for use for the other paths that would arrive to destination vertex. Any ideas from your side folks? Many thanks in advance, and best regards!

Forem Open with the Forem app