コード例 #1
0
 @Test
 public void testRemoveEdge() {
   AdjacencyList<String, Integer> myGraph = new AdjacencyList<String, Integer>();
   boolean added = myGraph.addEdge("A", "B", new Integer(42));
   assertTrue(added);
   assertTrue(myGraph.adjacent("A", "B"));
   Integer edgeRemoved = myGraph.removeEdge("A", "B");
   assertEquals(new Integer(42), edgeRemoved);
   assertFalse(myGraph.adjacent("A", "B"));
 }
コード例 #2
0
 @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"));
 }