コード例 #1
0
  @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());
  }
コード例 #2
0
  @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) {
    }
  }