Hi Peter,
Thanks for your response.
It seems the updateDistancesFor() calls are not necessary. For example, when I replace the graph.edge() calls in my code with those in your AlternativeRoute unit test (without the updateDistancesFor() calls), it can return the expected results (with the edge distance set in the graph.edge() calls of course).
It seems the feature manages to return multiple paths in some cases but not in some others.
case (1): the case I provided earlier is one example that it fails (only one path is returned).
case (2): below is an example when it successfully return two paths from node 1 to node 3:
graph.edge(1, 2, 10, false);
graph.edge(2, 3, 20, false);
graph.edge(1, 4, 20, false);
graph.edge(4, 3, 10, false);
case (3): and I am having trouble to get more than two alternative paths, for example, if I add two more edges to case 2:
graph.edge(1, 5, 15, false);
graph.edge(5, 3, 15, false);
and set
alternativeRoute.setMaxPaths(3);
I still get two paths, rather than three.
case (4): if I make a few changes to the edge distance in case 2, like below:
graph.edge(1, 2, 10, false);
graph.edge(2, 3, 10, false);
graph.edge(1, 4, 5, false);
graph.edge(4, 3, 15, false);
The returned path list contains two paths but they are the same: 1->4->3.
case (5): if I increase the edge distance of the last edge in case 2 by 1, that is:
graph.edge(4, 3, 11, false);
Then I will get only one path: 1->2->3.
I am just trying to test and understand when the feature works, when it does not, and why.
Best regards,
He