/** {@inheritDoc} */ protected <N, E> Graph<N, E> createFullGraph(final N nodeValue, final E edgeValue) { Graph<N, E> graph = new GraphImpl<N, E>(); Node<N, E> node0 = graph.createNode(nodeValue); Node<N, E> node1 = graph.createNode(nodeValue); graph.createEdge(node0, node1, edgeValue); return graph; }
public void testCopyConstructor() { Graph<String, Integer> emptyGraph = createEmptyGraph(); Graph<String, Integer> emptyCopy = new GraphImpl<String, Integer>(emptyGraph); assertNotNull(emptyCopy); assertTrue(emptyCopy.isEmpty()); Graph<String, Integer> fullGraph = createFullGraph("foo", Integer.valueOf(1)); Graph<String, Integer> fullCopy = new GraphImpl<String, Integer>(fullGraph); assertNotNull(fullCopy); assertFalse(fullCopy.isEmpty()); assertEquals(fullGraph.nodeCount(), fullCopy.nodeCount()); assertEquals(fullGraph.edgeCount(), fullCopy.edgeCount()); try { Graph<String, Integer> graph = new GraphImpl<String, Integer>(null); fail("ctr(null) expected IllegalArgumentException"); } catch (IllegalArgumentException e) { // expected } }