@Test
public void testCalcAlternatives() throws Exception {
Weighting weighting = new FastestWeighting(carFE);
GraphHopperStorage g = createTestGraph(true, em);
AlternativeRoute altDijkstra = new AlternativeRoute(g, weighting, traversalMode);
altDijkstra.setMaxShareFactor(0.5);
altDijkstra.setMaxWeightFactor(2);
List<AlternativeRoute.AlternativeInfo> pathInfos = altDijkstra.calcAlternatives(5, 4);
checkAlternatives(pathInfos);
assertEquals(2, pathInfos.size());
DijkstraBidirectionRef dijkstra = new DijkstraBidirectionRef(g, weighting, traversalMode);
Path bestPath = dijkstra.calcPath(5, 4);
Path bestAlt = pathInfos.get(0).getPath();
Path secondAlt = pathInfos.get(1).getPath();
assertEquals(bestPath.calcNodes(), bestAlt.calcNodes());
assertEquals(bestPath.getWeight(), bestAlt.getWeight(), 1e-3);
assertEquals(IntArrayList.from(new int[]{5, 6, 3, 4}), bestAlt.calcNodes());
assertEquals(IntArrayList.from(new int[]{5, 6, 7, 8, 4}), secondAlt.calcNodes());
assertEquals(1667.9, secondAlt.getWeight(), .1);
}