@Test
  public void testSimpleDelete3() {
    graph = createGraph();
    NodeAccess na = graph.getNodeAccess();
    na.setNode(7, 7, 1);
    na.setNode(8, 8, 1);
    na.setNode(9, 9, 1);
    na.setNode(11, 11, 1);

    // mini subnetwork which gets completely removed:
    graph.edge(5, 10, 510, true);
    graph.markNodeRemoved(3);
    graph.markNodeRemoved(4);
    graph.markNodeRemoved(5);
    graph.markNodeRemoved(10);

    graph.edge(9, 11, 911, true);
    graph.edge(7, 9, 78, true);
    graph.edge(8, 9, 89, true);

    // perform deletion
    graph.optimize();

    assertEquals(Arrays.<String>asList(), GHUtility.getProblems(graph));

    assertEquals(3, GHUtility.count(carAllExplorer.setBaseNode(getIdOf(graph, 9))));
    assertEquals(1, GHUtility.count(carAllExplorer.setBaseNode(getIdOf(graph, 7))));
    assertEquals(1, GHUtility.count(carAllExplorer.setBaseNode(getIdOf(graph, 8))));
    assertEquals(1, GHUtility.count(carAllExplorer.setBaseNode(getIdOf(graph, 11))));
  }
  @Test
  public void testGetAllEdgesWithDelete() {
    graph = createGraph();
    NodeAccess na = graph.getNodeAccess();
    na.setNode(0, 0, 5);
    na.setNode(1, 1, 5);
    na.setNode(2, 2, 5);
    na.setNode(3, 3, 5);
    graph.edge(0, 1, 1, true);
    graph.edge(0, 2, 1, true);
    graph.edge(1, 2, 1, true);
    graph.edge(2, 3, 1, true);
    AllEdgesIterator iter = graph.getAllEdges();
    assertEquals(4, GHUtility.count(iter));
    assertEquals(4, iter.getMaxId());

    // delete
    graph.markNodeRemoved(1);
    graph.optimize();
    iter = graph.getAllEdges();
    assertEquals(2, GHUtility.count(iter));
    assertEquals(4, iter.getMaxId());

    iter = graph.getAllEdges();
    iter.next();
    EdgeIteratorState eState = iter.detach(false);
    assertEquals(iter.toString(), eState.toString());
    iter.next();
    assertNotEquals(iter.toString(), eState.toString());

    EdgeIteratorState eState2 = iter.detach(true);
    assertEquals(iter.getAdjNode(), eState2.getBaseNode());
    iter.next();
    assertNotEquals(iter.getAdjNode(), eState2.getBaseNode());
  }
  @Test
  public void testDeleteNodeForUnidir() {
    graph = createGraph();
    NodeAccess na = graph.getNodeAccess();
    na.setNode(10, 10, 1);
    na.setNode(6, 6, 1);
    na.setNode(20, 20, 1);
    na.setNode(21, 21, 1);

    graph.edge(10, 20, 10, false);
    graph.edge(21, 6, 10, false);

    graph.markNodeRemoved(0);
    graph.markNodeRemoved(7);
    assertEquals(22, graph.getNodes());
    graph.optimize();
    assertEquals(20, graph.getNodes());

    assertEquals(1, GHUtility.count(carInExplorer.setBaseNode(getIdOf(graph, 20))));
    assertEquals(0, GHUtility.count(carOutExplorer.setBaseNode(getIdOf(graph, 20))));

    assertEquals(1, GHUtility.count(carOutExplorer.setBaseNode(getIdOf(graph, 10))));
    assertEquals(0, GHUtility.count(carInExplorer.setBaseNode(getIdOf(graph, 10))));

    assertEquals(1, GHUtility.count(carInExplorer.setBaseNode(getIdOf(graph, 6))));
    assertEquals(0, GHUtility.count(carOutExplorer.setBaseNode(getIdOf(graph, 6))));

    assertEquals(1, GHUtility.count(carOutExplorer.setBaseNode(getIdOf(graph, 21))));
    assertEquals(0, GHUtility.count(carInExplorer.setBaseNode(getIdOf(graph, 21))));
  }
 @Test
 public void testIdenticalNodes2() {
   graph = createGraph();
   graph.edge(0, 0, 100, false);
   graph.edge(0, 0, 100, false);
   assertEquals(2, GHUtility.count(carAllExplorer.setBaseNode(0)));
 }
  @Test
  public void testUnidirectionalEdgeFilter() {
    graph = createGraph();

    graph.edge(1, 2, 12, false);
    graph.edge(1, 11, 12, false);
    graph.edge(11, 1, 12, false);
    graph.edge(1, 12, 12, false);
    graph.edge(3, 2, 112, false);
    EdgeIterator i = carOutExplorer.setBaseNode(2);
    assertFalse(i.next());

    assertEquals(4, GHUtility.count(carAllExplorer.setBaseNode(1)));

    assertEquals(1, GHUtility.count(carInExplorer.setBaseNode(1)));
    assertEquals(2, GHUtility.count(carInExplorer.setBaseNode(2)));
    assertEquals(0, GHUtility.count(carInExplorer.setBaseNode(3)));

    assertEquals(3, GHUtility.count(carOutExplorer.setBaseNode(1)));
    assertEquals(0, GHUtility.count(carOutExplorer.setBaseNode(2)));
    assertEquals(1, GHUtility.count(carOutExplorer.setBaseNode(3)));
    i = carOutExplorer.setBaseNode(3);
    i.next();
    assertEquals(2, i.getAdjNode());

    i = carOutExplorer.setBaseNode(1);
    assertTrue(i.next());
    assertEquals(12, i.getAdjNode());
    assertTrue(i.next());
    assertEquals(11, i.getAdjNode());
    assertTrue(i.next());
    assertEquals(2, i.getAdjNode());
    assertFalse(i.next());
  }
 @Test
 public void testSetNodes() {
   graph = createGraph();
   NodeAccess na = graph.getNodeAccess();
   for (int i = 0; i < defaultSize * 2; i++) {
     na.setNode(i, 2 * i, 3 * i);
   }
   graph.edge(defaultSize + 1, defaultSize + 2, 10, true);
   graph.edge(defaultSize + 1, defaultSize + 3, 10, true);
   assertEquals(2, GHUtility.count(carAllExplorer.setBaseNode(defaultSize + 1)));
 }
  @Test
  public void testCreateDuplicateEdges() {
    graph = createGraph();
    graph.edge(2, 1, 12, true);
    graph.edge(2, 3, 12, true);
    graph.edge(2, 3, 13, false);
    assertEquals(3, GHUtility.count(carOutExplorer.setBaseNode(2)));

    // no exception
    graph.getEdgeProps(1, 3);

    // raise exception
    try {
      graph.getEdgeProps(4, 3);
      assertTrue(false);
    } catch (Exception ex) {
    }
    try {
      graph.getEdgeProps(-1, 3);
      assertTrue(false);
    } catch (Exception ex) {
    }

    EdgeIterator iter = carOutExplorer.setBaseNode(2);
    assertTrue(iter.next());
    EdgeIteratorState oneIter = graph.getEdgeProps(iter.getEdge(), 3);
    assertEquals(13, oneIter.getDistance(), 1e-6);
    assertEquals(2, oneIter.getBaseNode());
    assertTrue(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_FORWARD));
    assertFalse(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_BACKWARD));

    oneIter = graph.getEdgeProps(iter.getEdge(), 2);
    assertEquals(13, oneIter.getDistance(), 1e-6);
    assertEquals(3, oneIter.getBaseNode());
    assertFalse(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_FORWARD));
    assertTrue(carEncoder.isBool(oneIter.getFlags(), FlagEncoder.K_BACKWARD));

    graph.edge(3, 2, 14, true);
    assertEquals(4, GHUtility.count(carOutExplorer.setBaseNode(2)));
  }