use of com.graphhopper.coll.GHBitSetImpl in project graphhopper by graphhopper.
the class GHUtility method sortDFS.
/**
* Sorts the graph according to depth-first search traversal. Other traversals have either no
* significant difference (bfs) for querying or are worse (z-curve).
*/
public static Graph sortDFS(Graph g, Graph sortedGraph) {
int nodes = g.getNodes();
final GHIntArrayList list = new GHIntArrayList(nodes);
list.fill(nodes, -1);
final GHBitSetImpl bitset = new GHBitSetImpl(nodes);
final AtomicInteger ref = new AtomicInteger(-1);
EdgeExplorer explorer = g.createEdgeExplorer();
for (int startNode = 0; startNode >= 0 && startNode < nodes; startNode = bitset.nextClear(startNode + 1)) {
new DepthFirstSearch() {
@Override
protected GHBitSet createBitSet() {
return bitset;
}
@Override
protected boolean goFurther(int nodeId) {
list.set(nodeId, ref.incrementAndGet());
return super.goFurther(nodeId);
}
}.start(explorer, startNode);
}
return createSortedGraph(g, sortedGraph, list);
}
use of com.graphhopper.coll.GHBitSetImpl in project graphhopper by graphhopper.
the class BaseGraph method _copyTo.
void _copyTo(BaseGraph clonedG) {
if (clonedG.edgeEntryBytes != edgeEntryBytes)
throw new IllegalStateException("edgeEntryBytes cannot be different for cloned graph. " + "Cloned: " + clonedG.edgeEntryBytes + " vs " + edgeEntryBytes);
if (clonedG.nodeEntryBytes != nodeEntryBytes)
throw new IllegalStateException("nodeEntryBytes cannot be different for cloned graph. " + "Cloned: " + clonedG.nodeEntryBytes + " vs " + nodeEntryBytes);
if (clonedG.nodeAccess.getDimension() != nodeAccess.getDimension())
throw new IllegalStateException("dimension cannot be different for cloned graph. " + "Cloned: " + clonedG.nodeAccess.getDimension() + " vs " + nodeAccess.getDimension());
// nodes
setNodesHeader();
nodes.copyTo(clonedG.nodes);
clonedG.loadNodesHeader();
// edges
setEdgesHeader();
edges.copyTo(clonedG.edges);
clonedG.loadEdgesHeader();
// name
nameIndex.copyTo(clonedG.nameIndex);
// geometry
setWayGeometryHeader();
wayGeometry.copyTo(clonedG.wayGeometry);
clonedG.loadWayGeometryHeader();
// extStorage
extStorage.copyTo(clonedG.extStorage);
if (removedNodes == null)
clonedG.removedNodes = null;
else
clonedG.removedNodes = removedNodes.copyTo(new GHBitSetImpl());
}
use of com.graphhopper.coll.GHBitSetImpl in project graphhopper by graphhopper.
the class Measurement method printGraphDetails.
private GHBitSet printGraphDetails(GraphHopperStorage g, String vehicleStr) {
// graph size (edge, node and storage size)
put("graph.nodes", g.getNodes());
put("graph.edges", g.getAllEdges().getMaxId());
put("graph.size_in_MB", g.getCapacity() / Helper.MB);
put("graph.encoder", vehicleStr);
AllEdgesIterator iter = g.getAllEdges();
final int maxEdgesId = g.getAllEdges().getMaxId();
final GHBitSet allowedEdges = new GHBitSetImpl(maxEdgesId);
fillAllowedEdges(iter, allowedEdges);
put("graph.valid_edges", allowedEdges.getCardinality());
return allowedEdges;
}
Aggregations