### Question:
PrepareContractionHierarchies extends AbstractAlgoPreparation implements RoutingAlgorithmFactory { int addShortcuts( int v ) { shortcuts.clear(); findShortcuts(addScHandler.setNode(v)); int tmpNewShortcuts = 0; NEXT_SC: for (Shortcut sc : shortcuts.keySet()) { boolean updatedInGraph = false; CHEdgeIterator iter = vehicleOutExplorer.setBaseNode(sc.from); while (iter.next()) { if (iter.isShortcut() && iter.getAdjNode() == sc.to && iter.canBeOverwritten(sc.flags)) { if (sc.weight >= prepareWeighting.calcWeight(iter, false, EdgeIterator.NO_EDGE)) 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,
                                          FlagEncoder encoder, Weighting weighting, TraversalMode traversalMode ); PrepareContractionHierarchies setPeriodicUpdates( int periodicUpdates ); PrepareContractionHierarchies setLazyUpdates( int lazyUpdates ); PrepareContractionHierarchies setNeighborUpdates( int neighborUpdates ); PrepareContractionHierarchies setLogMessages( double logMessages ); PrepareContractionHierarchies setContractedNodes( double nodesContracted ); void setInitialCollectionSize( int initialCollectionSize ); @Override void doWork(); long getDijkstraCount(); double getLazyTime(); double getPeriodTime(); double getDijkstraTime(); double getNeighborTime(); 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, carEncoder, weighting, tMode); prepare.doWork(); assertEquals(old + 1, lg.getAllEdges().getMaxId()); }