Answer the question
In order to leave comments, you need to log in
Algorithm for finding the shortest path in a graph
There is an undirected unweighted graph in which it is required to find the shortest path between two given vertices. There is also a condition that when passing through some edges (known in advance), some certain edges, also known in advance, may appear or disappear. Tell me, is Dijkstra's algorithm suitable for this task?
Answer the question
In order to leave comments, you need to log in
If there are few moving bridges, each vertex can be multiplied in 2b copies (b is the number of bridges). Then not even Dijkstra will go, but the usual breadth-first search.
If two bridges are “linked” to each other and are brought in / out at the same time, then they go to b in one piece.
And if there are a lot of bridges and 2 b is an unacceptable waste, then it's interesting. I think nothing but heuristics will help. For example, it may happen that the shortest path from the switch to all the bridges it controls is dry. Or bridges (in the sense of controlled) are bridges (in the sense of graph theory). Or something else.
As a first approximation, it seems that either breadth-first search or the A* algorithm should be applied here. With trust states in both cases. I wrote about it here at the time.
At the university, I remember that they used the Traveling Salesman algorithm or the Ant algorithm for solving. Both work, a question in implementation. Given that they are logically similar, but not identical, I dare to suggest that it is quite possible to implement using this algorithm. The only difference is that the two previous algorithms are used to find the shortest path through the entire graph. Alternatively, you can try Levit's algorithm.
The question is, if you know the edges, then why is the graph not weighted? Maybe I misunderstood something, I apologize in advance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question