コード例 #1
0
 @Test
 public void testGetNodes1Node() {
   AdjacencyList<String, Integer> myGraph = new AdjacencyList<String, Integer>();
   boolean added = myGraph.addNode("A");
   assertTrue(added);
   Set<String> allNodes = myGraph.getNodes();
   assertEquals(1, allNodes.size());
   assertTrue(allNodes.contains("A"));
 }
コード例 #2
0
 @Test
 public void testSelfNode() {
   AdjacencyList<String, Integer> myGraph = new AdjacencyList<String, Integer>();
   boolean added = myGraph.addEdge("A", "A", new Integer(42));
   assertFalse(added);
   Set<String> allNodes = myGraph.getNodes();
   assertEquals(0, allNodes.size());
   assertFalse(allNodes.contains("A"));
   assertFalse(allNodes.contains("B"));
 }