@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 testGetAllEdges() { graph = createGraph(); graph.edge(0, 1, 2, true); graph.edge(3, 1, 1, false); graph.edge(3, 2, 1, false); EdgeIterator iter = graph.getAllEdges(); assertTrue(iter.next()); int edgeId = iter.getEdge(); assertEquals(0, iter.getBaseNode()); assertEquals(1, iter.getAdjNode()); assertEquals(2, iter.getDistance(), 1e-6); assertTrue(iter.next()); int edgeId2 = iter.getEdge(); assertEquals(1, edgeId2 - edgeId); assertEquals(1, iter.getBaseNode()); assertEquals(3, iter.getAdjNode()); assertTrue(iter.next()); assertEquals(2, iter.getBaseNode()); assertEquals(3, iter.getAdjNode()); assertFalse(iter.next()); }