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]");
}
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]");
}
Aggregations