Пример #1
0
  public void testIsCycle() {
    assertFalse(path.isCycle());
    path = path.append(newEdge(0).asPath());
    assertFalse(path.isCycle());
    path = path.append(newEdge(1, 0).asPath());
    assertTrue(path.isCycle());
    path = path.append(newEdge(0).asPath());
    assertFalse(path.isCycle());

    assertTrue(path.split(1)[1].isCycle());
  }
Пример #2
0
  public void testSplit() {
    Edge[] edges = {newEdge(0), newEdge(1), newEdge(2), newEdge(3)};
    for (Edge e : edges) {
      path = path.append(e.asPath());
    }
    Path[] paths = path.split(2);
    assertEquals(2, paths[0].size());
    assertEquals(2, paths[1].size());
    assertEquals(n[0], paths[0].headNode());
    assertEquals(n[2], paths[0].tailNode());
    assertEquals(n[2], paths[1].headNode());
    assertEquals(n[4], paths[1].tailNode());

    paths = paths[1].split(2);
    assertEquals(2, paths[0].size());
    assertEquals(0, paths[1].size());
    assertEquals(n[4], paths[1].headNode());
    assertEquals(n[4], paths[1].tailNode());
  }