Changeset 17 for src/main/java/weka
- Timestamp:
- Sep 23, 2010, 10:32:44 AM (14 years ago)
- Location:
- src/main/java/weka/clusterers/forMetisMQI
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/GraphAlgorithms.java
r16 r17 2 2 3 3 import java.util.HashSet; 4 import java.util.Iterator; 4 5 import java.util.Set; 5 6 import java.util.Stack; … … 57 58 static public Set<Set<Node>> metisMqi(UndirectedGraph g, int numberOfCluster, int sizeFinerGraph) { 58 59 Set<Set<Node>> clusters = new HashSet<Set<Node>>(); 59 Util.viewGraph(g); 60 UndirectedGraph gclone = g.clone(); 61 // Util.viewGraph(g); 60 62 for (int i = 0; i < numberOfCluster; i++) { 61 63 Bisection partition = metis(g,sizeFinerGraph); 62 64 Set<Node> cluster = MQI.mqi(partition); 63 clusters.add(cluster); 65 Iterator<Node> clustersNode = cluster.iterator(); 66 while(clustersNode.hasNext()){ 67 g.removeVertex(clustersNode.next()); 68 } 69 70 71 if(cluster.size()>10) { 72 clusters.add(cluster); 73 } 64 74 System.out.println("CLUSTER "+ i + ": " + cluster); 65 75 } 66 Util.viewClusters(g , clusters);76 Util.viewClusters(gclone, clusters); 67 77 return clusters; 68 78 } -
src/main/java/weka/clusterers/forMetisMQI/MQI.java
r16 r17 159 159 */ 160 160 static public Set<Node> mqi(Bisection partition) { 161 System.out.println("INITIAL BISECTION: " + partition.toString());161 // System.out.println("INITIAL BISECTION: " + partition.toString()); 162 162 boolean finished = false; 163 163 Bisection bisection = partition; … … 167 167 int maxFlowThreshold = Integer.MAX_VALUE; 168 168 while (!finished) { 169 Node source = new Node(" S");170 Node sink = new Node(" T");169 Node source = new Node("$$$$S"); 170 Node sink = new Node("$$$$T"); 171 171 DirectedGraph<Node, Edge> directedGraph = prepareDirectedGraph( 172 172 bisection, source, sink); … … 182 182 public Edge create() { 183 183 i++; 184 return new Edge(" f" + Integer.toString(i), 1, 1);184 return new Edge("$$$$" + Integer.toString(i), 1, 1); 185 185 } 186 186 }; … … 194 194 alg.evaluate(); 195 195 // Util.viewFlowGraph(directedGraph, edgeFlowMap); 196 System.out.println("MAX FLOW: " + alg.getMaxFlow() + " THRESHOLD: "197 + maxFlowThreshold);196 // System.out.println("MAX FLOW: " + alg.getMaxFlow() + " THRESHOLD: " 197 // + maxFlowThreshold); 198 198 if (alg.getMaxFlow() < maxFlowThreshold) { 199 199 cluster = DFSReversed(sink, directedGraph, edgeFlowMap, new HashSet<Node>()); … … 201 201 bisection = new Bisection(new Subgraph(bisection.getGraph(), 202 202 cluster)); 203 System.out.println("NEW BISECTION: " + bisection.toString());203 // System.out.println("NEW BISECTION: " + bisection.toString()); 204 204 } else 205 205 finished = true; -
src/main/java/weka/clusterers/forMetisMQI/graph/Node.java
r11 r17 34 34 @Override 35 35 public String toString() { 36 return "N" +id; //+ " Cewgt: " + cewgt;36 return id; //+ " Cewgt: " + cewgt; 37 37 } 38 38 -
src/main/java/weka/clusterers/forMetisMQI/graph/UndirectedGraph.java
r14 r17 74 74 while (dataIterator.hasNext()) { 75 75 Instance edge = dataIterator.next(); 76 Node node1 = new Node( Integer.toString(((int) Math.round(edge.value(from)))));77 Node node2 = new Node( Integer.toString(((int) Math.round(edge.value(to)))));76 Node node1 = new Node(edge.stringValue(from)); 77 Node node2 = new Node(edge.stringValue(to)); 78 78 addVertex(node1); 79 79 addVertex(node2);
Note: See TracChangeset
for help on using the changeset viewer.