View Javadoc
1   package edu.uci.ics.jung.algorithms.shortestpath;
2   
3   import junit.framework.TestCase;
4   import edu.uci.ics.jung.graph.DirectedGraph;
5   import edu.uci.ics.jung.graph.DirectedSparseMultigraph;
6   import edu.uci.ics.jung.graph.DelegateTree;
7   import edu.uci.ics.jung.graph.Tree;
8   import edu.uci.ics.jung.graph.UndirectedGraph;
9   import edu.uci.ics.jung.graph.UndirectedSparseMultigraph;
10  
11  public class TestPrimMinimumSpanningTree extends TestCase {
12  	
13  	public void testSimpleTree() {
14  		Tree<String,Integer> tree = new DelegateTree<String,Integer>();
15  		tree.addVertex("A");
16  		tree.addEdge(0,"A","B0");
17  		tree.addEdge(1,"A","B1");
18  		
19  //		System.err.println("tree = "+tree);
20  		PrimMinimumSpanningTree<String,Integer> pmst = 
21  			new PrimMinimumSpanningTree<String,Integer>(DelegateTree.<String,Integer>getFactory());
22  		
23  //		Graph<String,Integer> mst = 
24  		pmst.apply(tree);
25  //		System.err.println("mst = "+mst);
26  		
27  //		assertEquals(tree.getVertices(), mst.getVertices());
28  //		assertEquals(tree.getEdges(), mst.getEdges());
29  		
30  	}
31  	
32  	public void testDAG() {
33  		DirectedGraph<String,Integer> graph = new DirectedSparseMultigraph<String,Integer>();
34  		graph.addVertex("B0");
35  		graph.addEdge(0, "A", "B0");
36  		graph.addEdge(1, "A", "B1");
37  //		System.err.println("graph = "+graph);
38  		PrimMinimumSpanningTree<String,Integer> pmst = 
39  			new PrimMinimumSpanningTree<String,Integer>(DelegateTree.<String,Integer>getFactory());
40  		
41  //		Graph<String,Integer> mst = 
42  		pmst.apply(graph);
43  //		System.err.println("mst = "+mst);
44  		
45  	}
46  
47  	public void testUAG() {
48  		UndirectedGraph<String,Integer> graph = new UndirectedSparseMultigraph<String,Integer>();
49  		graph.addVertex("B0");
50  		graph.addEdge(0, "A", "B0");
51  		graph.addEdge(1, "A", "B1");
52  //		System.err.println("graph = "+graph);
53  		PrimMinimumSpanningTree<String,Integer> pmst = 
54  			new PrimMinimumSpanningTree<String,Integer>(DelegateTree.<String,Integer>getFactory());
55  		
56  //		Graph<String,Integer> mst = 
57  		pmst.apply(graph);
58  //		System.err.println("mst = "+mst);
59  		
60  	}
61  
62  }