I got the exercise to write a software in which a shortest path should be calculated. You have a specific start node A and a specific ending node Z. These nodes are always the same. Between this nodes there is an undefined amount of "intermediate" Nodes. Now is the question is there any algorithm or any modification of e.g. The dijkstra to calculate the best order of intermediate nodes on the way from A to Z. E.g. is it better to go A B C D Z or A D B C Z. For realizing the graph I use JGraphT. Thanks in advance.
Asked
Active
Viewed 953 times
1
-
Do you have to use all intermediate nodes? If not, this is just Dijkstra on the subgraph induced by `{A, B, C, D, Z}`... – md5 Dec 27 '16 at 13:10
-
Sorry I answered to fast I think this comment was not clear enough. you do not have to use all nodes that are included in the graph and are not A or Z but if you have given e.g. 5 intermediate nodes you have to use this 5 nodes. – M.Friedrich Dec 27 '16 at 13:20
-
Possible duplicate of [Find the shortest path in a graph which visits certain nodes](http://stackoverflow.com/questions/222413/find-the-shortest-path-in-a-graph-which-visits-certain-nodes) – beaker Dec 27 '16 at 15:36
-
That's right thanks – M.Friedrich Dec 27 '16 at 15:43