Closed ZhengZhongyuan11 closed 3 years ago
There can be two paths with the same length. When you try to find the path in the opposite direction, it will not always give the same path (if there are more than one path with the same length).
But you don't need to find the path going the other direction... You can reverse the order of the nodes.
There can be two paths with the same length. When you try to find the path in the opposite direction, it will not always give the same path (if there are more than one path with the same length).
But you don't need to find the path going the other direction... You can reverse the order of the nodes.
Hi dschult,
Thanks for your reply, but I have checked the length, it is not exactly same, the length of reverse order is 24 and the length of in-order sequence is 17. Do you know why this happens?
Would you mind sharing the example where you see the problem? Thanks!
It sounds like you might have a directed graph. In that case, the direction of the path will impact the shortest path. You can't go the opposite direction along the path.
If not, then I agree with @jarrodmillman . We need more information. Please share a small graph which shows the problem.
Thanks for your reply! I think it is because of my fault, and I have figured it out.
Hi guys,
Recently when I used networkx library to build a undirected graph, and then used astar to search for the shortest path, I found that if I switch the start and the end point, astar_path will return different sequence. I wonder why this happens and can anybody help me?
Thanks!