- Timestamp:
- Sep 16, 2010, 7:01:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/GraphAlgorithms.java
r11 r12 1 1 package weka.clusterers.forMetisMQI; 2 2 3 import java.util.HashSet; 4 import java.util.Set; 3 5 import java.util.Stack; 4 6 … … 10 12 11 13 public class GraphAlgorithms { 12 14 13 15 public Bisection KL(UndirectedGraph g) { 14 16 Bisection partition = new Bisection(g); … … 16 18 int bestEdgeCut = Integer.MAX_VALUE; 17 19 Node u = partition.getCandidate(); 18 while (u != null) {20 while (u != null) { 19 21 partition.swap(u); 20 if (partition.edgeCut() <=bestEdgeCut) {22 if (partition.edgeCut() <= bestEdgeCut) { 21 23 bestEdgeCut = partition.edgeCut(); 22 24 result = partition.copy(); … … 26 28 return result; 27 29 } 28 30 29 31 public void METIS(UndirectedGraph g) { 30 MQI.viewGraph(g); 31 Bisection partition = null; 32 Coarse.setFinerSize(8); 33 Stack<CoarserGraphElement> stack = Coarse.coarse(g); 34 if(stack.size() > 0) { 35 partition = KL(stack.peek().getContracted()); 36 System.out.println(partition.toString()); 37 partition = new Uncoarse().uncoarse(stack, partition); 38 System.out.println(partition.toString()); 32 // MQI.viewGraph(g); 33 Set<Set<Node>> clusters = new HashSet<Set<Node>>(); 34 for (int i = 0; i < 8; i++) { 35 Coarse.setFinerSize(8); 36 Stack<CoarserGraphElement> stack = Coarse.coarse(g); 37 Bisection partition = null; 38 if (stack.size() > 0) { 39 partition = KL(stack.peek().getContracted()); 40 // System.out.println(partition.toString()); 41 partition = new Uncoarse().uncoarse(stack, partition); 42 // System.out.println(partition.toString()); 43 Set<Node> cluster = MQI.mqi(partition); 44 clusters.add(cluster); 45 // Set<Set<Node>> foundCluster = new HashSet<Set<Node>>(); 46 // foundCluster.add(cluster); 47 // MQI.viewClusters(g, foundCluster); 48 } 39 49 } 40 System.out.println("AAAAAA"); 41 System.out.println(MQI.mqi(partition).toString()); 42 50 MQI.viewClusters(g, clusters); 43 51 } 44 52
Note: See TracChangeset
for help on using the changeset viewer.