### Question:
BreadthFirstSearch extends XFirstSearch { @Override public void start( EdgeExplorer explorer, int startNode ) { SimpleIntDeque fifo = new SimpleIntDeque(); GHBitSet visited = createBitSet(); visited.add(startNode); fifo.push(startNode); int current; while (!fifo.isEmpty()) { current = fifo.pop(); if (!goFurther(current)) continue; EdgeIterator iter = explorer.setBaseNode(current); while (iter.next()) { int connectedId = iter.getAdjNode(); if (checkAdjacent(iter) && !visited.contains(connectedId)) { visited.add(connectedId); fifo.push(connectedId); } } } }  @Override void start( EdgeExplorer explorer, int startNode );  }### Answer:
@Test public void testBFS() { BreadthFirstSearch bfs = new BreadthFirstSearch() { @Override public boolean goFurther( int v ) { counter++; assertTrue("v " + v + " is already contained in set. iteration:" + counter, !set.contains(v)); set.add(v); list.add(v); return super.goFurther(v); } }; Graph g = new GraphBuilder(new EncodingManager("CAR")).create(); g.edge(0, 1, 85, true); g.edge(0, 2, 217, true); g.edge(0, 3, 173, true); g.edge(0, 5, 173, true); g.edge(1, 6, 75, true); g.edge(2, 7, 51, true); g.edge(3, 8, 23, true); g.edge(4, 8, 793, true); g.edge(8, 10, 343, true); g.edge(6, 9, 72, true); g.edge(9, 10, 8, true); g.edge(5, 10, 1, true); bfs.start(g.createEdgeExplorer(), 0); assertTrue(counter > 0); assertEquals(g.getNodes(), counter); assertEquals("{0, 5, 3, 2, 1, 10, 8, 7, 6, 9, 4}", list.toString()); }
@Test public void testBFS2() { BreadthFirstSearch bfs = new BreadthFirstSearch() { @Override public boolean goFurther( int v ) { counter++; assertTrue("v " + v + " is already contained in set. iteration:" + counter, !set.contains(v)); set.add(v); list.add(v); return super.goFurther(v); } }; Graph g = new GraphBuilder(new EncodingManager("CAR")).create(); g.edge(1, 2, 1, false); g.edge(2, 3, 1, false); g.edge(3, 4, 1, false); g.edge(1, 5, 1, false); g.edge(5, 6, 1, false); g.edge(6, 4, 1, false); bfs.start(g.createEdgeExplorer(), 1); assertTrue(counter > 0); assertEquals("{1, 5, 2, 6, 3, 4}", list.toString()); }