@Override protected void multipleShortestPathUpdate(VWCent u, VWCent v, E e) { // Accumulate the number of shortest paths v.accumulateSPCount(u.getSPCount()); super.multipleShortestPathUpdate(u, v, e); }
/** * Checks if the given node can be pushed to the stack by making sure its * distance is greater than the node previously pushed to the stack. * * @param node The node. * * @return {@code true} if and only if the node can be pushed to the stack. */ private boolean canPushToStack(VWCent node) { if (!(stack.size() == 0)) { if (node.getDistance() < stack.peek().getDistance()) { return false; } } return true; }
@Override protected void shortestPathSoFarUpdate(VWCent startNode, VWCent u, VWCent v, Double uvWeight, E e, PriorityQueue<VWCent> queue) { // Reset the number of shortest paths v.setSPCount(u.getSPCount()); super.shortestPathSoFarUpdate(startNode, u, v, uvWeight, e, queue); }
/** * Before relaxing the outgoing edges of u, we push it to the stack and * record its shortest path length. * * @param startNode * @param u Vertex u. * @return */ @Override protected boolean preRelaxStep(VWCent startNode, VWCent u) { // Push it to the stack. if (canPushToStack(u)) { stack.push(u); } else { throw new IllegalStateException( "Cannot push node " + u.getID() + " to the stack."); } // Record this shortest path length (for closeness). if (!u.equals(startNode)) { pathsFromStartNode.addSPLength(u.getDistance()); } // Don't stop the search. return false; }