Search in sources :

Example 1 with IntArrayDeque

use of com.carrotsearch.hppc.IntArrayDeque in project graphhopper by graphhopper.

the class DepthFirstSearch method start.

/**
 * beginning with startNode add all following nodes to LIFO queue. If node has been already
 * explored before, skip reexploration.
 */
@Override
public void start(EdgeExplorer explorer, int startNode) {
    IntArrayDeque stack = new IntArrayDeque();
    GHBitSet explored = createBitSet();
    stack.addLast(startNode);
    int current;
    while (stack.size() > 0) {
        current = stack.removeLast();
        if (!explored.contains(current) && goFurther(current)) {
            EdgeIterator iter = explorer.setBaseNode(current);
            while (iter.next()) {
                int connectedId = iter.getAdjNode();
                if (checkAdjacent(iter)) {
                    stack.addLast(connectedId);
                }
            }
            explored.add(current);
        }
    }
}
Also used : GHBitSet(com.graphhopper.coll.GHBitSet) IntArrayDeque(com.carrotsearch.hppc.IntArrayDeque)

Aggregations

IntArrayDeque (com.carrotsearch.hppc.IntArrayDeque)1 GHBitSet (com.graphhopper.coll.GHBitSet)1