protected void testBasic(Graph graph) {
Node A = graph.addNode("A");
Node B = graph.addNode("B");
Node C = graph.addNode("C");
Edge AB = graph.addEdge("AB", "A", "B");
Edge BC = graph.addEdge("BC", "B", "C");
Edge CA = graph.addEdge("CA", "C", "A");
assertEquals(3, graph.getNodeCount());
assertEquals(3, graph.getEdgeCount());
assertNotNull(A);
assertNotNull(B);
assertNotNull(C);
assertNotNull(AB);
assertNotNull(BC);
assertNotNull(CA);
assertEquals("A", A.getId());
assertEquals("B", B.getId());
assertEquals("C", C.getId());
assertEquals("AB", AB.getId());
assertEquals("BC", BC.getId());
assertEquals("CA", CA.getId());
assertEquals(A, graph.getNode("A"));
assertEquals(B, graph.getNode("B"));
assertEquals(C, graph.getNode("C"));
assertEquals(AB, graph.getEdge("AB"));
assertEquals(BC, graph.getEdge("BC"));
assertEquals(CA, graph.getEdge("CA"));
assertFalse(AB.isDirected());
assertFalse(BC.isDirected());
assertFalse(CA.isDirected());
assertEquals(A, AB.getNode0());
assertEquals(B, AB.getNode1());
assertEquals(A, AB.getSourceNode());
assertEquals(B, AB.getTargetNode());
assertEquals(B, BC.getNode0());
assertEquals(C, BC.getNode1());
assertEquals(B, BC.getSourceNode());
assertEquals(C, BC.getTargetNode());
assertEquals(C, CA.getNode0());
assertEquals(A, CA.getNode1());
assertEquals(C, CA.getSourceNode());
assertEquals(A, CA.getTargetNode());
assertEquals(B, AB.getOpposite(A));
assertEquals(A, AB.getOpposite(B));
assertEquals(C, BC.getOpposite(B));
assertEquals(B, BC.getOpposite(C));
assertEquals(A, CA.getOpposite(C));
assertEquals(C, CA.getOpposite(A));
assertEquals(2, A.getDegree());
assertEquals(2, B.getDegree());
assertEquals(2, C.getDegree());
assertEquals(2, A.getInDegree());
assertEquals(2, A.getOutDegree());
assertEquals(2, B.getInDegree());
assertEquals(2, B.getOutDegree());
assertEquals(2, C.getInDegree());
assertEquals(2, C.getOutDegree());
assertTrue(A.hasEdgeFrom("B"));
assertTrue(A.hasEdgeFrom("C"));
assertTrue(B.hasEdgeFrom("A"));
assertTrue(B.hasEdgeFrom("C"));
assertTrue(C.hasEdgeFrom("A"));
assertTrue(C.hasEdgeFrom("B"));
assertEquals(AB, A.getEdgeFrom("B"));
assertEquals(CA, A.getEdgeFrom("C"));
assertEquals(AB, B.getEdgeFrom("A"));
assertEquals(BC, B.getEdgeFrom("C"));
assertEquals(CA, C.getEdgeFrom("A"));
assertEquals(BC, C.getEdgeFrom("B"));
assertTrue(A.hasEdgeToward("B"));
assertTrue(A.hasEdgeToward("C"));
assertTrue(B.hasEdgeToward("A"));
assertTrue(B.hasEdgeToward("C"));
assertTrue(C.hasEdgeToward("A"));
assertTrue(C.hasEdgeToward("B"));
assertEquals(AB, A.getEdgeToward("B"));
assertEquals(CA, A.getEdgeToward("C"));
assertEquals(AB, B.getEdgeToward("A"));
assertEquals(BC, B.getEdgeToward("C"));
assertEquals(CA, C.getEdgeToward("A"));
assertEquals(BC, C.getEdgeToward("B"));
assertNull(A.getEdgeFrom("Z"));
assertNull(B.getEdgeFrom("Z"));
assertNull(C.getEdgeFrom("Z"));
assertNull(A.getEdgeToward("Z"));
assertNull(B.getEdgeToward("Z"));
assertNull(C.getEdgeToward("Z"));
// Loop edges
assertFalse(A.hasEdgeBetween(A));
assertFalse(A.hasEdgeToward(A));
assertFalse(A.hasEdgeFrom(A));
assertNull(A.getEdgeBetween(A));
assertNull(A.getEdgeToward(A));
assertNull(A.getEdgeFrom(A));
Edge AA = graph.addEdge("AA", "A", "A");
assertEquals(4, graph.getEdgeCount());
assertEquals(3, A.getDegree());
assertEquals(3, A.getInDegree());
assertEquals(3, A.getOutDegree());
assertTrue(A.hasEdgeBetween(A));
assertTrue(A.hasEdgeToward(A));
assertTrue(A.hasEdgeFrom(A));
assertEquals(AA, A.getEdgeBetween(A));
assertEquals(AA, A.getEdgeToward(A));
assertEquals(AA, A.getEdgeFrom(A));
assertEquals(A, AA.getSourceNode());
assertEquals(A, AA.getTargetNode());
}