/** Introduces the necessary shortcuts for endNode v in the graph. */ int addShortcuts(int v) { shortcuts.clear(); findShortcuts(addScHandler.setNode(v)); int tmpNewShortcuts = 0; for (Shortcut sc : shortcuts.keySet()) { boolean updatedInGraph = false; // check if we need to update some existing shortcut in the graph EdgeSkipIterator iter = vehicleOutExplorer.setBaseNode(sc.from); while (iter.next()) { if (iter.isShortcut() && iter.getAdjNode() == sc.to && prepareEncoder.canBeOverwritten(iter.getFlags(), sc.flags) && iter.getDistance() > sc.weight) { iter.setFlags(sc.flags); iter.setSkippedEdges(sc.skippedEdge1, sc.skippedEdge2); iter.setDistance(sc.weight); setOrigEdgeCount(iter.getEdge(), sc.originalEdges); updatedInGraph = true; break; } } if (!updatedInGraph) { EdgeSkipIterState edgeState = g.shortcut(sc.from, sc.to); edgeState.setDistance(sc.weight).setFlags(sc.flags); edgeState.setSkippedEdges(sc.skippedEdge1, sc.skippedEdge2); setOrigEdgeCount(edgeState.getEdge(), sc.originalEdges); tmpNewShortcuts++; } } return tmpNewShortcuts; }
Set<Shortcut> testFindShortcuts(int node) { findShortcuts(addScHandler.setNode(node)); return shortcuts.keySet(); }