@Test public void testNameIndex() { graph = createGraph(); EdgeIteratorState iter1 = graph.edge(0, 1, 10, true); iter1.setName("named street1"); EdgeIteratorState iter2 = graph.edge(0, 1, 10, true); iter2.setName("named street2"); assertEquals( "named street1", graph.getEdgeProps(iter1.getEdge(), iter1.getAdjNode()).getName()); assertEquals( "named street2", graph.getEdgeProps(iter2.getEdge(), iter2.getAdjNode()).getName()); }
@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))); }
@Test public void testEdgeProperties() { graph = createGraph(); EdgeIteratorState iter1 = graph.edge(0, 1, 10, true); EdgeIteratorState iter2 = graph.edge(0, 2, 20, true); int edgeId = iter1.getEdge(); EdgeIteratorState iter = graph.getEdgeProps(edgeId, 0); assertEquals(10, iter.getDistance(), 1e-5); edgeId = iter2.getEdge(); iter = graph.getEdgeProps(edgeId, 0); assertEquals(2, iter.getBaseNode()); assertEquals(0, iter.getAdjNode()); assertEquals(20, iter.getDistance(), 1e-5); iter = graph.getEdgeProps(edgeId, 2); assertEquals(0, iter.getBaseNode()); assertEquals(2, iter.getAdjNode()); assertEquals(20, iter.getDistance(), 1e-5); iter = graph.getEdgeProps(edgeId, Integer.MIN_VALUE); assertFalse(iter == null); assertEquals(0, iter.getBaseNode()); assertEquals(2, iter.getAdjNode()); iter = graph.getEdgeProps(edgeId, 1); assertTrue(iter == null); // delete graph.markNodeRemoved(1); graph.optimize(); // throw exception if accessing deleted edge try { graph.getEdgeProps(iter1.getEdge(), -1); assertTrue(false); } catch (Exception ex) { } }