@Test public void testUnpackingOrder_Fastest() { LevelGraphStorage g = (LevelGraphStorage) createGraph(); PrepareContractionHierarchies prepare = new PrepareContractionHierarchies().graph(g); WeightCalculation calc = new FastestCalc(carEncoder); initUnpackingGraph(g, calc); RoutingAlgorithm algo = prepare.type(calc).vehicle(carEncoder).createAlgo(); Path p = algo.calcPath(10, 6); assertEquals(7, p.distance(), 1e-1); assertEquals(Helper.createTList(10, 0, 1, 2, 3, 4, 5, 6), p.calcNodes()); }
@Test public void testDirectedGraph2() { LevelGraph g = createGraph(); initDirected2(g); int old = GHUtility.count(g.getAllEdges()); PrepareContractionHierarchies prepare = new PrepareContractionHierarchies().graph(g); prepare.doWork(); // PrepareTowerNodesShortcutsTest.printEdges(g); assertEquals(old + 15, GHUtility.count(g.getAllEdges())); RoutingAlgorithm algo = prepare.createAlgo(); Path p = algo.calcPath(0, 10); assertEquals(10, p.distance(), 1e-6); assertEquals(Helper.createTList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), p.calcNodes()); }
@Test public void testDirectedGraph() { LevelGraph g = createGraph(); g.edge(5, 4, 3, false); g.edge(4, 5, 10, false); g.edge(2, 4, 1, false); g.edge(5, 2, 1, false); g.edge(3, 5, 1, false); g.edge(4, 3, 1, false); int old = GHUtility.count(g.getAllEdges()); PrepareContractionHierarchies prepare = new PrepareContractionHierarchies().graph(g); prepare.doWork(); // PrepareTowerNodesShortcutsTest.printEdges(g); assertEquals(old + 3, GHUtility.count(g.getAllEdges())); RoutingAlgorithm algo = prepare.createAlgo(); Path p = algo.calcPath(4, 2); assertEquals(3, p.distance(), 1e-6); assertEquals(Helper.createTList(4, 3, 5, 2), p.calcNodes()); }