@Test public void testRemoveNode() { AdjacencyList<String, Integer> myGraph = new AdjacencyList<String, Integer>(); boolean added = myGraph.addNode("A"); assertTrue(added); assertTrue(myGraph.containsNode("A")); boolean removed = myGraph.removeNode("A"); assertTrue(removed); assertFalse(myGraph.containsNode("A")); assertFalse(myGraph.containsNode("B")); }
@Test public void testContains3() { AdjacencyList<String, Integer> myGraph = new AdjacencyList<String, Integer>(); myGraph.addNode("A"); assertTrue(myGraph.containsNode("A")); assertFalse(myGraph.containsNode("B")); myGraph.addNode("B"); assertTrue(myGraph.containsNode("A")); assertTrue(myGraph.containsNode("B")); myGraph.removeNode("A"); assertFalse(myGraph.containsNode("A")); assertTrue(myGraph.containsNode("B")); }
@Test public void testContains2() { AdjacencyList<String, Integer> myGraph = new AdjacencyList<String, Integer>(); // contains nodes A and B after adding edge A->B boolean added = myGraph.addEdge("A", "B", new Integer(42)); assertTrue(added); assertTrue(myGraph.containsNode("A")); assertTrue(myGraph.containsNode("B")); // still contains nodes A and B after removing edge A->B Integer edgeRemoved = myGraph.removeEdge("A", "B"); assertEquals(new Integer(42), edgeRemoved); assertTrue(myGraph.containsNode("A")); assertTrue(myGraph.containsNode("B")); }