@Override public EdgeIterator setBaseNode(int baseNode) { // always use base graph edge access setEdgeId(baseGraph.edgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
@Override public final CHEdgeIterator setBaseNode(int baseNode) { assert baseGraph.isFrozen() : "Traversal CHGraph is only possible if BaseGraph is frozen"; // always use ch edge access setEdgeId(chEdgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
public void debugPrint() { final int printMax = 100; System.out.println("nodes:"); String formatNodes = "%12s | %12s | %12s | %12s \n"; System.out.format(Locale.ROOT, formatNodes, "#", "N_EDGE_REF", "N_LAT", "N_LON"); NodeAccess nodeAccess = getNodeAccess(); for (int i = 0; i < Math.min(nodeCount, printMax); ++i) { System.out.format(Locale.ROOT, formatNodes, i, edgeAccess.getEdgeRef(i), nodeAccess.getLat(i), nodeAccess.getLon(i)); } if (nodeCount > printMax) { System.out.format(Locale.ROOT, " ... %d more nodes\n", nodeCount - printMax); } System.out.println("edges:"); String formatEdges = "%12s | %12s | %12s | %12s | %12s | %12s | %12s \n"; System.out.format(Locale.ROOT, formatEdges, "#", "E_NODEA", "E_NODEB", "E_LINKA", "E_LINKB", "E_DIST", "E_FLAGS"); for (int i = 0; i < Math.min(edgeCount, printMax); ++i) { System.out.format(Locale.ROOT, formatEdges, i, edges.getInt((long) (i * edgeEntryBytes) + edgeAccess.E_NODEA), edges.getInt((long) (i * edgeEntryBytes) + edgeAccess.E_NODEB), edges.getInt((long) (i * edgeEntryBytes) + edgeAccess.E_LINKA), edges.getInt((long) (i * edgeEntryBytes) + edgeAccess.E_LINKB), edges.getInt((long) (i * edgeEntryBytes) + edgeAccess.E_DIST), edges.getInt((long) (i * edgeEntryBytes) + edgeAccess.E_FLAGS)); } if (edgeCount > printMax) { System.out.printf(Locale.ROOT, " ... %d more edges", edgeCount - printMax); } }
final void connectNewEdge(int fromNode, int otherNode, int newOrExistingEdge) { int edge = getEdgeRef(fromNode); if (edge > EdgeIterator.NO_EDGE) { long edgePointer = toPointer(newOrExistingEdge); long lastLink = _getLinkPosInEdgeArea(fromNode, otherNode, edgePointer); edges.setInt(lastLink, edge); } setEdgeRef(fromNode, newOrExistingEdge); }
@Override public final boolean next() { while (true) { if (nextEdgeId == EdgeIterator.NO_EDGE) return false; selectEdgeAccess(); edgePointer = edgeAccess.toPointer(nextEdgeId); edgeId = nextEdgeId; adjNode = edgeAccess.getOtherNode(baseNode, edgePointer); reverse = baseNode > adjNode; freshFlags = false; // position to next edge nextEdgeId = edgeAccess.getEdgeRef(baseNode, adjNode, edgePointer); assert nextEdgeId != edgeId : ("endless loop detected for base node: " + baseNode + ", adj node: " + adjNode + ", edge pointer: " + edgePointer + ", edge: " + edgeId); if (filter.accept(this)) return true; } }
/** * This method disconnects the specified edge from the list of edges of the specified node. It * does not release the freed space to be reused. * <p> * * @param edgeToUpdatePointer if it is negative then the nextEdgeId will be saved to refToEdges * of nodes */ final long internalEdgeDisconnect(int edgeToRemove, long edgeToUpdatePointer, int baseNode, int adjNode) { long edgeToRemovePointer = toPointer(edgeToRemove); // an edge is shared across the two nodes even if the edge is not in both directions // so we need to know two edge-pointers pointing to the edge before edgeToRemovePointer int nextEdgeId = getEdgeRef(baseNode, adjNode, edgeToRemovePointer); if (edgeToUpdatePointer < 0) { setEdgeRef(baseNode, nextEdgeId); } else { // adjNode is different for the edge we want to update with the new link long link = edges.getInt(edgeToUpdatePointer + E_NODEA) == baseNode ? edgeToUpdatePointer + E_LINKA : edgeToUpdatePointer + E_LINKB; edges.setInt(link, nextEdgeId); } return edgeToRemovePointer; }
int linkA = edgeAccess.getEdgeRef(nodeA, nodeB, edgePointer); int linkB = edgeAccess.getEdgeRef(nodeB, nodeA, edgePointer); long flags = edgeAccess.getFlags_(edgePointer, false); edgeAccess.writeEdge(edgeId, updatedA, updatedB, linkA, linkB);
@Override public EdgeIterator setBaseNode(int baseNode) { // always use base graph edge access setEdgeId(baseGraph.edgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
@Override public EdgeIterator setBaseNode(int baseNode) { // always use base graph edge access setEdgeId(baseGraph.edgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
@Override public EdgeIterator setBaseNode( int baseNode ) { // always use base graph edge access setEdgeId(baseGraph.edgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
@Override public final CHEdgeIterator setBaseNode(int baseNode) { assert baseGraph.isFrozen() : "Traversal CHGraph is only possible if BaseGraph is frozen"; // always use ch edge access setEdgeId(chEdgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
@Override public final CHEdgeIterator setBaseNode(int baseNode) { assert baseGraph.isFrozen() : "Traversal CHGraph is only possible if BaseGraph is frozen"; // always use ch edge access setEdgeId(chEdgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
@Override public final CHEdgeIterator setBaseNode( int baseNode ) { assert baseGraph.isFrozen() : "Traversal CHGraph is only possible if BaseGraph is frozen"; // always use ch edge access setEdgeId(chEdgeAccess.getEdgeRef(baseNode)); _setBaseNode(baseNode); return this; }
final void connectNewEdge(int fromNode, int otherNode, int newOrExistingEdge) { int edge = getEdgeRef(fromNode); if (edge > EdgeIterator.NO_EDGE) { long edgePointer = toPointer(newOrExistingEdge); long lastLink = _getLinkPosInEdgeArea(fromNode, otherNode, edgePointer); edges.setInt(lastLink, edge); } setEdgeRef(fromNode, newOrExistingEdge); }
final void connectNewEdge( int fromNode, int newOrExistingEdge ) { int edge = getEdgeRef(fromNode); if (edge > EdgeIterator.NO_EDGE) { long edgePointer = toPointer(newOrExistingEdge); int otherNode = getOtherNode(fromNode, edgePointer); long lastLink = _getLinkPosInEdgeArea(fromNode, otherNode, edgePointer); edges.setInt(lastLink, edge); } setEdgeRef(fromNode, newOrExistingEdge); }
@Override public final boolean next() { while (true) { if (nextEdgeId == EdgeIterator.NO_EDGE) return false; selectEdgeAccess(); edgePointer = edgeAccess.toPointer(nextEdgeId); edgeId = nextEdgeId; adjNode = edgeAccess.getOtherNode(baseNode, edgePointer); reverse = baseNode > adjNode; freshFlags = false; // position to next edge nextEdgeId = edgeAccess.getEdgeRef(baseNode, adjNode, edgePointer); assert nextEdgeId != edgeId : ("endless loop detected for base node: " + baseNode + ", adj node: " + adjNode + ", edge pointer: " + edgePointer + ", edge: " + edgeId); if (filter.accept(this)) return true; } }
@Override public final boolean next() { while (true) { if (nextEdgeId == EdgeIterator.NO_EDGE) return false; selectEdgeAccess(); edgePointer = edgeAccess.toPointer(nextEdgeId); edgeId = nextEdgeId; adjNode = edgeAccess.getOtherNode(baseNode, edgePointer); reverse = baseNode > adjNode; freshFlags = false; // position to next edge nextEdgeId = edgeAccess.getEdgeRef(baseNode, adjNode, edgePointer); assert nextEdgeId != edgeId : ("endless loop detected for base node: " + baseNode + ", adj node: " + adjNode + ", edge pointer: " + edgePointer + ", edge: " + edgeId); if (filter.accept(this)) return true; } }
final void connectNewEdge(int fromNode, int newOrExistingEdge) { int edge = getEdgeRef(fromNode); if (edge > EdgeIterator.NO_EDGE) { long edgePointer = toPointer(newOrExistingEdge); int otherNode = getOtherNode(fromNode, edgePointer); long lastLink = _getLinkPosInEdgeArea(fromNode, otherNode, edgePointer); edges.setInt(lastLink, edge); } setEdgeRef(fromNode, newOrExistingEdge); }
@Override public final boolean next() { while (true) { if (nextEdgeId == EdgeIterator.NO_EDGE) return false; selectEdgeAccess(); edgePointer = edgeAccess.toPointer(nextEdgeId); edgeId = nextEdgeId; adjNode = edgeAccess.getOtherNode(baseNode, edgePointer); reverse = baseNode > adjNode; freshFlags = false; // position to next edge nextEdgeId = edgeAccess.getEdgeRef(baseNode, adjNode, edgePointer); assert nextEdgeId != edgeId : ("endless loop detected for base node: " + baseNode + ", adj node: " + adjNode + ", edge pointer: " + edgePointer + ", edge: " + edgeId); if (filter.accept(this)) return true; } }
/** * This method disconnects the specified edge from the list of edges of the specified node. It * does not release the freed space to be reused. * <p> * * @param edgeToUpdatePointer if it is negative then the nextEdgeId will be saved to refToEdges * of nodes */ final long internalEdgeDisconnect(int edgeToRemove, long edgeToUpdatePointer, int baseNode, int adjNode) { long edgeToRemovePointer = toPointer(edgeToRemove); // an edge is shared across the two nodes even if the edge is not in both directions // so we need to know two edge-pointers pointing to the edge before edgeToRemovePointer int nextEdgeId = getEdgeRef(baseNode, adjNode, edgeToRemovePointer); if (edgeToUpdatePointer < 0) { setEdgeRef(baseNode, nextEdgeId); } else { // adjNode is different for the edge we want to update with the new link long link = edges.getInt(edgeToUpdatePointer + E_NODEA) == baseNode ? edgeToUpdatePointer + E_LINKA : edgeToUpdatePointer + E_LINKB; edges.setInt(link, nextEdgeId); } return edgeToRemovePointer; }