### Question:
PrepareContractionHierarchies extends AbstractAlgoPreparation implements RoutingAlgorithmFactory { int addShortcuts(Collection<Shortcut> tmpShortcuts) { int tmpNewShortcuts = 0; NEXT_SC: for (Shortcut sc : tmpShortcuts) { boolean updatedInGraph = false; CHEdgeIterator iter = vehicleOutExplorer.setBaseNode(sc.from); while (iter.next()) { if (iter.isShortcut() && iter.getAdjNode() == sc.to) { int status = iter.getMergeStatus(sc.flags); if (status == 0) continue; if (sc.weight >= prepareWeighting.calcWeight(iter, false, EdgeIterator.NO_EDGE)) { if (status == 2) break; continue NEXT_SC; } if (iter.getEdge() == sc.skippedEdge1 || iter.getEdge() == sc.skippedEdge2) { throw new IllegalStateException("Shortcut cannot update itself! " + iter.getEdge() + ", skipEdge1:" + sc.skippedEdge1 + ", skipEdge2:" + sc.skippedEdge2 + ", edge " + iter + ":" + getCoords(iter, prepareGraph) + ", sc:" + sc + ", skippedEdge1: " + getCoords(prepareGraph.getEdgeIteratorState(sc.skippedEdge1, sc.from), prepareGraph) + ", skippedEdge2: " + getCoords(prepareGraph.getEdgeIteratorState(sc.skippedEdge2, sc.to), prepareGraph) + ", neighbors:" + GHUtility.getNeighbors(iter)); } iter.setFlags(sc.flags); iter.setWeight(sc.weight); iter.setDistance(sc.dist); iter.setSkippedEdges(sc.skippedEdge1, sc.skippedEdge2); setOrigEdgeCount(iter.getEdge(), sc.originalEdges); updatedInGraph = true; break; } } if (!updatedInGraph) { CHEdgeIteratorState edgeState = prepareGraph.shortcut(sc.from, sc.to); edgeState.setFlags(sc.flags); edgeState.setWeight(sc.weight); edgeState.setDistance(sc.dist); edgeState.setSkippedEdges(sc.skippedEdge1, sc.skippedEdge2); setOrigEdgeCount(edgeState.getEdge(), sc.originalEdges); tmpNewShortcuts++; } } return tmpNewShortcuts; } 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 testAddShortcuts() { GraphHopperStorage g = createExampleGraph(); CHGraph lg = g.getGraph(CHGraph.class); int old = lg.getAllEdges().getMaxId(); PrepareContractionHierarchies prepare = new PrepareContractionHierarchies(dir, g, lg, weighting, tMode); prepare.doWork(); assertEquals(old + 1, lg.getAllEdges().getMaxId()); }