### Question:
PrepareContractionHierarchies extends AbstractAlgoPreparation implements RoutingAlgorithmFactory { @Override public RoutingAlgorithm createAlgo(Graph graph, AlgorithmOptions opts) { AbstractBidirAlgo algo; if (ASTAR_BI.equals(opts.getAlgorithm())) { AStarBidirection tmpAlgo = new AStarBidirectionCH(graph, prepareWeighting, traversalMode); tmpAlgo.setApproximation(RoutingAlgorithmFactorySimple.getApproximation(ASTAR_BI, opts, graph.getNodeAccess())); algo = tmpAlgo; } else if (DIJKSTRA_BI.equals(opts.getAlgorithm())) { algo = new DijkstraBidirectionCH(graph, prepareWeighting, traversalMode); } else { throw new IllegalArgumentException("Algorithm " + opts.getAlgorithm() + " not supported for Contraction Hierarchies. Try with ch.disable=true"); } algo.setMaxVisitedNodes(opts.getMaxVisitedNodes()); algo.setEdgeFilter(levelFilter); return algo; } PrepareContractionHierarchies(Directory dir, GraphHopperStorage ghStorage, CHGraph chGraph,
                                         Weighting weighting, TraversalMode traversalMode); PrepareContractionHierarchies setPeriodicUpdates(int periodicUpdates); PrepareContractionHierarchies setLazyUpdates(int lazyUpdates); PrepareContractionHierarchies setNeighborUpdates(int neighborUpdates); PrepareContractionHierarchies setLogMessages(double logMessages); PrepareContractionHierarchies setContractedNodes(double nodesContracted); @Override void doWork(); long getDijkstraCount(); double getLazyTime(); double getPeriodTime(); double getDijkstraTime(); double getNeighborTime(); Weighting getWeighting(); void close(); int getShortcuts(); @Override RoutingAlgorithm createAlgo(Graph graph, AlgorithmOptions opts); @Override String toString();  }### Answer:
@Test public void testUnpackingOrder() { GraphHopperStorage ghStorage = createGHStorage(); CHGraph lg = ghStorage.getGraph(CHGraph.class); initUnpackingGraph(ghStorage, lg, weighting); PrepareContractionHierarchies prepare = new PrepareContractionHierarchies(dir, ghStorage, lg, weighting, tMode); RoutingAlgorithm algo = prepare.createAlgo(lg, new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); Path p = algo.calcPath(10, 6); assertEquals(7, p.getDistance(), 1e-5); assertEquals(Helper.createTList(10, 0, 1, 2, 3, 4, 5, 6), p.calcNodes()); }
@Test public void testUnpackingOrder_Fastest() { GraphHopperStorage ghStorage = createGHStorage(); CHGraph lg = ghStorage.getGraph(CHGraph.class); Weighting w = new FastestWeighting(carEncoder); initUnpackingGraph(ghStorage, lg, w); PrepareContractionHierarchies prepare = new PrepareContractionHierarchies(dir, ghStorage, lg, weighting, tMode); RoutingAlgorithm algo = prepare.createAlgo(lg, new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); Path p = algo.calcPath(10, 6); assertEquals(7, p.getDistance(), 1e-1); assertEquals(Helper.createTList(10, 0, 1, 2, 3, 4, 5, 6), p.calcNodes()); }