public void testEdge() { try { path.tailEdge(); fail(); } catch (NoSuchElementException ok) { } assertEquals(n[0], path.headNode()); assertEquals(n[0], path.tailNode()); Edge e = newEdge(0); path = path.append(e.asPath()); assertEquals(e, path.tailEdge()); assertEquals(e.n2(), path.tailNode()); e = newEdge(1); path = path.append(e.asPath()); assertEquals(e, path.tailEdge()); assertEquals(e.n2(), path.tailNode()); }
public void testToString() { assertEquals("[1]", path.toString()); path = path.append(newEdge(0, 1).asPath()); assertEquals("[1-->2]", path.toString()); Edge e = newEdge(2, 1); path = path.append(e.asPath(e.n2())); assertEquals("[1-->2<--3]", path.toString()); }
public void testNegativeIndexInSingleEdge() { Graph g = new PrimaryGraph(); Edge e = g.newEdge(g.newNode(), g.newNode()); assertSame(e.n2(), e.asPath().getNode(-1)); assertSame(e.n1(), e.asPath().getNode(-2)); }