Search in sources :

Example 11 with GHBitSetImpl

use of com.graphhopper.coll.GHBitSetImpl in project graphhopper by graphhopper.

the class DepthFirstSearchTest method testDFS2.

@Test
public void testDFS2() {
    DepthFirstSearch dfs = new DepthFirstSearch() {

        @Override
        protected GHBitSet createBitSet() {
            return new GHBitSetImpl();
        }

        @Override
        public boolean goFurther(int v) {
            counter++;
            assertTrue(!set.contains(v), "v " + v + " is already contained in set. iteration:" + counter);
            set.add(v);
            list.add(v);
            return super.goFurther(v);
        }
    };
    EncodingManager em = EncodingManager.create("car");
    FlagEncoder encoder = em.getEncoder("car");
    Graph g = new GraphBuilder(em).create();
    GHUtility.setSpeed(60, true, false, encoder, g.edge(1, 2).setDistance(1));
    GHUtility.setSpeed(60, true, true, encoder, g.edge(1, 4).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(1, 3).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(2, 3).setDistance(1));
    GHUtility.setSpeed(60, true, true, encoder, g.edge(4, 3).setDistance(1));
    dfs.start(g.createEdgeExplorer(AccessFilter.outEdges(encoder.getAccessEnc())), 1);
    assertTrue(counter > 0);
    assertEquals(list.toString(), "[1, 2, 3, 4]");
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) GHBitSetImpl(com.graphhopper.coll.GHBitSetImpl) Graph(com.graphhopper.storage.Graph) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) GraphBuilder(com.graphhopper.storage.GraphBuilder) Test(org.junit.jupiter.api.Test)

Example 12 with GHBitSetImpl

use of com.graphhopper.coll.GHBitSetImpl in project graphhopper by graphhopper.

the class DepthFirstSearchTest method testDFS1.

@Test
public void testDFS1() {
    DepthFirstSearch dfs = new DepthFirstSearch() {

        @Override
        protected GHBitSet createBitSet() {
            return new GHBitSetImpl();
        }

        @Override
        public boolean goFurther(int v) {
            counter++;
            assertTrue(!set.contains(v), "v " + v + " is already contained in set. iteration:" + counter);
            set.add(v);
            list.add(v);
            return super.goFurther(v);
        }
    };
    EncodingManager em = EncodingManager.create("car");
    FlagEncoder encoder = em.getEncoder("car");
    Graph g = new GraphBuilder(em).create();
    GHUtility.setSpeed(60, true, false, encoder, g.edge(1, 2).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(1, 5).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(1, 4).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(2, 3).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(3, 4).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(5, 6).setDistance(1));
    GHUtility.setSpeed(60, true, false, encoder, g.edge(6, 4).setDistance(1));
    dfs.start(g.createEdgeExplorer(AccessFilter.outEdges(encoder.getAccessEnc())), 1);
    assertTrue(counter > 0);
    assertEquals(list.toString(), "[1, 2, 3, 4, 5, 6]");
}
Also used : EncodingManager(com.graphhopper.routing.util.EncodingManager) GHBitSetImpl(com.graphhopper.coll.GHBitSetImpl) Graph(com.graphhopper.storage.Graph) FlagEncoder(com.graphhopper.routing.util.FlagEncoder) GraphBuilder(com.graphhopper.storage.GraphBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

GHBitSetImpl (com.graphhopper.coll.GHBitSetImpl)12 GHBitSet (com.graphhopper.coll.GHBitSet)9 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 Test (org.junit.jupiter.api.Test)3 IntArrayList (com.carrotsearch.hppc.IntArrayList)2 AllEdgesIterator (com.graphhopper.routing.util.AllEdgesIterator)2 EncodingManager (com.graphhopper.routing.util.EncodingManager)2 Graph (com.graphhopper.storage.Graph)2 GraphBuilder (com.graphhopper.storage.GraphBuilder)2 GHIntArrayList (com.graphhopper.coll.GHIntArrayList)1 SparseIntIntArray (com.graphhopper.coll.SparseIntIntArray)1 CHProfile (com.graphhopper.config.CHProfile)1 LMProfile (com.graphhopper.config.LMProfile)1 Profile (com.graphhopper.config.Profile)1 CustomProfile (com.graphhopper.routing.weighting.custom.CustomProfile)1 NodeAccess (com.graphhopper.storage.NodeAccess)1 LocationIndexTree (com.graphhopper.storage.index.LocationIndexTree)1 EdgeExplorer (com.graphhopper.util.EdgeExplorer)1 BBox (com.graphhopper.util.shapes.BBox)1