Search in sources :

Example 6 with GHBitSetImpl

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);
}
Also used : GHBitSetImpl(com.graphhopper.coll.GHBitSetImpl) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GHBitSet(com.graphhopper.coll.GHBitSet) GHIntArrayList(com.graphhopper.coll.GHIntArrayList)

Example 7 with GHBitSetImpl

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());
}
Also used : GHBitSetImpl(com.graphhopper.coll.GHBitSetImpl)

Example 8 with 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;
}
Also used : GHBitSetImpl(com.graphhopper.coll.GHBitSetImpl) GHBitSet(com.graphhopper.coll.GHBitSet)

Aggregations

GHBitSetImpl (com.graphhopper.coll.GHBitSetImpl)8 GHBitSet (com.graphhopper.coll.GHBitSet)7 GHIntArrayList (com.graphhopper.coll.GHIntArrayList)2 GHPoint (com.graphhopper.util.shapes.GHPoint)2 IntArrayList (com.carrotsearch.hppc.IntArrayList)1 SparseIntIntArray (com.graphhopper.coll.SparseIntIntArray)1 AllEdgesIterator (com.graphhopper.routing.util.AllEdgesIterator)1 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)1 EdgeExplorer (com.graphhopper.util.EdgeExplorer)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Logger (org.slf4j.Logger)1