コード例 #1
0
 @Test
 public void testMinimumSpanningTree() {
   MiniGraph<Character> tree = graph.generateMinimumSpanningTree();
   assertEquals(ORIGINAL_NUMBER_OF_NODES, graph.getNumberOfNodes());
   assertEquals(ORIGINAL_NUMBER_OF_EDGES, graph.getNumberOfEdges());
   assertEquals(ORIGINAL_EDGE_WEIGHT, graph.getTotalEdgeWeight());
   assertEquals(ORIGINAL_NUMBER_OF_NODES, tree.getNumberOfNodes());
   assertEquals(ORIGINAL_NUMBER_OF_NODES - 1, tree.getNumberOfEdges());
   assertEquals(16, tree.getTotalEdgeWeight());
 }
コード例 #2
0
  @Test
  public void testEmptyGraph() {
    graph = new MyGraph<Character>(); // MyGraph ersätts med namnet på din
    // graftyp
    graph.connectNodes('A', 'F', 1);
    assertEquals(0, graph.getNumberOfNodes());
    assertEquals(0, graph.getNumberOfEdges());
    assertEquals(0, graph.getTotalEdgeWeight());

    MiniGraph<Character> tree = graph.generateMinimumSpanningTree();
    assertEquals(0, tree.getNumberOfNodes());
    assertEquals(0, tree.getNumberOfEdges());
    assertEquals(0, tree.getTotalEdgeWeight());
  }