- Timestamp:
- Oct 6, 2010, 4:02:40 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/GraphAlgorithms.java
r23 r24 11 11 import weka.clusterers.forMetisMQI.graph.UndirectedGraph; 12 12 import weka.clusterers.forMetisMQI.util.CoarserGraphElement; 13 import weka.clusterers.forMetisMQI.util.Configuration; 13 14 import weka.clusterers.forMetisMQI.util.GraphsFrame; 14 15 import weka.clusterers.forMetisMQI.util.Util; … … 68 69 if (stack.size() > 0) { 69 70 partition = KL(stack.peek().getContracted()); 71 if(Configuration.instance().getVerboseLevel() > 1) { 72 GraphsFrame.instance().addPanel(Util.panelContractedGraph(stack.peek())); 73 GraphsFrame.instance().addPanel(Util.panelContractedGraph(stack.peek(),partition.getSmallerSubgraph().createInducedSubgraph().getVertices())); 74 } 70 75 partition = Uncoarse.uncoarse(stack, partition); 71 76 } … … 81 86 * @param sizeFinerGraph 82 87 */ 83 static public Set<Set<Node>> metisMqi(UndirectedGraph g, int numberOfCluster, int sizeFinerGraph, boolean randomBisection) { 84 GraphsFrame gf = new GraphsFrame("Prova"); 88 static public Set<Set<Node>> metisMqi(UndirectedGraph g) { 89 int numberOfCluster = Configuration.instance().getNumberOfClusters(); 90 boolean randomBisection = Configuration.instance().isRandomBisection(); 91 int sizeFinerGraph = Configuration.instance().getSizeFinerGraph(); 92 int verboseLevel = Configuration.instance().getVerboseLevel(); 93 GraphsFrame gf = GraphsFrame.instance(); 85 94 System.out.println("Vertex count: " + g.getVertexCount()); 86 95 System.out.println("Edges count: " + g.getEdgeCount()); 87 Iterator<Node> iNodes = g.getVertices().iterator();88 int degreeCounter = 0;89 while(iNodes.hasNext()) {90 Node node = iNodes.next();91 if(g.degree(node) == 1) {92 degreeCounter++;93 }94 }95 96 Set<Set<Node>> clusters = new HashSet<Set<Node>>(); 96 97 UndirectedGraph gclone = g.clone(); 97 gf.addPanel(Util.panelGraph(gclone));98 98 for (int i = 0; i < numberOfCluster; i++) { 99 99 Bisection bisection = null; 100 if(verboseLevel > 1) 101 gf.addPanel(Util.panelGraph(g.clone())); 100 102 if(!randomBisection) 101 103 bisection = metis(g,sizeFinerGraph); 102 104 else 103 105 bisection = new Bisection(g); 106 107 if(verboseLevel > 1) 108 gf.addPanel(Util.panelCluster(g.clone(),bisection.getSmallerSubgraph().createInducedSubgraph().getVertices())); 109 104 110 System.out.print("Partizione iniziale: "); 105 111 System.out.print("V1: " + bisection.getSubgraph().getVertexCount()); … … 127 133 } 128 134 } 129 gf.addPanel(Util.panelClusters(gclone, clusters)); 135 if(verboseLevel > 0) 136 gf.addPanel(Util.panelClusters(gclone, clusters)); 130 137 gf.setVisible(true); 131 138 return clusters;
Note: See TracChangeset
for help on using the changeset viewer.