Changeset 9 for src/main/java/weka/clusterers/forMetisMQI/MQI.java
- Timestamp:
- Sep 14, 2010, 2:11:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/MQI.java
r8 r9 6 6 import javax.swing.JFrame; 7 7 8 import edu.uci.ics.jung.algorithms.layout. CircleLayout;8 import edu.uci.ics.jung.algorithms.layout.KKLayout; 9 9 import edu.uci.ics.jung.algorithms.layout.Layout; 10 10 import edu.uci.ics.jung.graph.DirectedSparseGraph; … … 16 16 17 17 public static void viewGraph(Graph<Node, Edge> g){ 18 Layout<Node, Edge> layout = new CircleLayout<Node, Edge>(g);18 Layout<Node, Edge> layout = new KKLayout<Node, Edge>(g); 19 19 layout.setSize(new Dimension(300,300)); // sets the initial size of the space 20 20 // The BasicVisualizationServer<V,E> is parameterized by the edge types … … 33 33 Subgraph A = null; 34 34 Subgraph B = null; 35 if(partition.getSubgraph(). size() > partition.getComplement().size()) {35 if(partition.getSubgraph().getVertexCount() > partition.getComplement().getVertexCount()) { 36 36 A = partition.getSubgraph(); 37 37 B = partition.getComplement(); … … 41 41 B = partition.getSubgraph(); 42 42 } 43 int a = A. size();43 int a = A.getVertexCount(); 44 44 int c = partition.edgeCut(); 45 45 46 46 47 47 Graph<Node,Edge> g = new DirectedSparseGraph<Node, Edge>(); 48 Iterator< Integer> nodes = A.iterator();48 Iterator<Node> nodes = A.iterator(); 49 49 while(nodes.hasNext()) { 50 intu = nodes.next();51 g.addVertex( new Node(Integer.toString(u)));50 Node u = nodes.next(); 51 g.addVertex(u); 52 52 } 53 53 … … 55 55 int id = 0; 56 56 while(nodes.hasNext()) { 57 intu = nodes.next();58 Iterator< Integer> neighbors = A.getNeighbours(u).iterator();57 Node u = nodes.next(); 58 Iterator<Node> neighbors = A.getNeighbors(u).iterator(); 59 59 while(neighbors.hasNext()) { 60 intv = neighbors.next();61 g.addEdge(new Edge(Integer.toString(id),A.getWeight(u, v),a), new Node(Integer.toString(u)),new Node(Integer.toString(v)));60 Node v = neighbors.next(); 61 g.addEdge(new Edge(Integer.toString(id),A.getWeight(u, v),a),u,v); 62 62 id++; 63 63 } … … 72 72 nodes = B.iterator(); 73 73 while(nodes.hasNext()) { 74 intu = nodes.next();75 Iterator< Integer> neighbors = B.getGraph().getNeighbors(u).iterator();74 Node u = nodes.next(); 75 Iterator<Node> neighbors = B.getGraph().getNeighbors(u).iterator(); 76 76 while(neighbors.hasNext()) { 77 intv = neighbors.next();77 Node v = neighbors.next(); 78 78 if(A.contains(v)) { 79 g.addEdge(new Edge(Integer.toString(id),1,a),source, new Node(Integer.toString(v)));79 g.addEdge(new Edge(Integer.toString(id),1,a),source,v); 80 80 id++; 81 81 } … … 85 85 nodes = A.iterator(); 86 86 while(nodes.hasNext()) { 87 intu = nodes.next();88 g.addEdge(new Edge(Integer.toString(id),1,c), new Node(Integer.toString(u)),sink);87 Node u = nodes.next(); 88 g.addEdge(new Edge(Integer.toString(id),1,c),u,sink); 89 89 id++; 90 90 }
Note: See TracChangeset
for help on using the changeset viewer.