Changeset 20 for src/main/java/weka/clusterers/forMetisMQI/MQI.java
- Timestamp:
- Sep 30, 2010, 5:33:45 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/MQI.java
r18 r20 81 81 82 82 static private DirectedGraph<Node, Edge> prepareDirectedGraph( 83 Bisection partition, Node source, Node sink, boolean forConductance) { 84 Subgraph A = null; 85 Subgraph B = null; 86 if (partition.getSubgraph().getVertexCount() < partition 87 .getComplement().getVertexCount()) { 88 A = partition.getSubgraph(); 89 B = partition.getComplement(); 90 } else { 91 A = partition.getComplement(); 92 B = partition.getSubgraph(); 93 } 83 Bisection bisection, Node source, Node sink, boolean forConductance) { 84 Subgraph A = bisection.getLargerSubgraph(); 85 Subgraph B = bisection.getSmallerSubgraph(); 94 86 int a = 0; 95 87 if (!forConductance) … … 98 90 Iterator<Node> aIterator = A.iterator(); 99 91 while(aIterator.hasNext()) { 100 a += partition.getGraph().degree(aIterator.next());101 } 102 } 103 int c = partition.edgeCut() / 2;92 a += bisection.getGraph().degree(aIterator.next()); 93 } 94 } 95 int c = bisection.edgeCut() / 2; 104 96 105 97 DirectedGraph<Node, Edge> g = new DirectedSparseGraph<Node, Edge>(); … … 109 101 g.addVertex(u); 110 102 } 111 112 103 nodes = A.iterator(); 113 104 int id = 0; … … 153 144 if(forConductance) 154 145 //FIXME: CONTROLLAMI 155 g.addEdge(new Edge(Integer.toString(id), 1, c * partition.getGraph().degree(u)), u, sink);146 g.addEdge(new Edge(Integer.toString(id), 1, c * bisection.getGraph().degree(u)), u, sink); 156 147 else 157 148 g.addEdge(new Edge(Integer.toString(id), 1, c), u, sink); … … 173 164 boolean finished = false; 174 165 Bisection bisection = partition; 175 Set<Node> cluster = new HashSet<Node>(partition.get SmallerNotEmptySubgraph()166 Set<Node> cluster = new HashSet<Node>(partition.getLargerSubgraph() 176 167 .createInducedSubgraph().getVertices()); 177 168 int maxFlowThreshold = Integer.MAX_VALUE; … … 200 191 201 192 if (!forConductance) 202 maxFlowThreshold = bisection.get SmallerNotEmptySubgraph()193 maxFlowThreshold = bisection.getLargerSubgraph() 203 194 .getVertexCount() 204 195 * bisection.edgeCut() / 2; 205 196 else { 206 Iterator<Node> aIterator = bisection.get SmallerNotEmptySubgraph().iterator();197 Iterator<Node> aIterator = bisection.getLargerSubgraph().iterator(); 207 198 maxFlowThreshold = 0; 208 199 while(aIterator.hasNext()) … … 212 203 } 213 204 alg.evaluate(); 214 // 215 //System.out.println("MAX FLOW: " + alg.getMaxFlow() + " THRESHOLD: "216 //+ maxFlowThreshold);205 // Util.viewFlowGraph(directedGraph, edgeFlowMap); 206 System.out.println("MAX FLOW: " + alg.getMaxFlow() + " THRESHOLD: " 207 + maxFlowThreshold); 217 208 if (alg.getMaxFlow() < maxFlowThreshold) { 218 209 Set<Node> dfsResult = DFSReversed(sink, directedGraph, 219 210 edgeFlowMap, new HashSet<Node>()); 220 211 dfsResult.remove(sink); 221 // if (dfsResult.size() > 0) { 222 cluster = dfsResult; 223 bisection = new Bisection(new Subgraph( 224 bisection.getGraph(), cluster)); 225 // System.out 226 // .println("NEW BISECTION: " + bisection.toString()); 227 // } else 228 // finished = true; 212 cluster = dfsResult; 213 bisection = new Bisection(new Subgraph( 214 bisection.getGraph(), cluster)); 229 215 } else 230 216 finished = true;
Note: See TracChangeset
for help on using the changeset viewer.