Changeset 8 for src/main/java/weka/clusterers
- Timestamp:
- Sep 11, 2010, 4:12:16 PM (14 years ago)
- Location:
- src/main/java/weka/clusterers/forMetisMQI
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/Coarse.java
r7 r8 13 13 private static boolean debug = true; 14 14 private static PrintStream debugStream = System.err; 15 private static int nodesContracted= 5;15 private static int finerSize = 5; 16 16 17 17 /** … … 61 61 map.set(g.getIndex(matchedNode), labelCounter); 62 62 if(debug) debugStream.println("Contracting node " + u + " with " + matchedNode + ". Node id: " + getMappedNode(g, map, u)); 63 } else 63 } else { 64 64 map.set(g.getIndex(u), labelCounter); 65 if(debug) debugStream.println("Node " + u + " with " + " new node id: " + getMappedNode(g, map, u)); 66 } 65 67 labelCounter++; 66 68 } … … 106 108 //calcolo dei pesi del nuovo grafo: per ogni arco (u,v) && u < v. 107 109 //w(map(u),map(v)) += w(u,v). 108 for(int u=0; u < g.size(); u++) { 110 for(int i=0; i < g.size(); i++) { 111 int u = g.getLabel(i); 109 112 Iterator<Integer> it = g.getNeighbors(u).iterator(); 110 113 while(it.hasNext()) { … … 115 118 } 116 119 } 117 for(int u = 0; u < g.size(); u++) { 120 for(int i=0; i < g.size(); i++) { 121 int u = g.getLabel(i); 118 122 if(isMatched(g,match,u)) { 119 123 int v = getMatchedNode(g,match,u); … … 159 163 if(debug) 160 164 debugStream.println("-----------------------------------------------------"); 161 } while(e.getProjected().size() > e.getContracted().size() && e.getContracted().size() > nodesContracted);165 } while(e.getProjected().size() > e.getContracted().size() && e.getContracted().size() > finerSize); 162 166 return stack; 163 167 } 168 169 public static void setFinerSize(int i) { 170 finerSize = i; 171 } 164 172 } -
src/main/java/weka/clusterers/forMetisMQI/GraphAlgorithms.java
r7 r8 23 23 public void METIS(Graph g) { 24 24 KLPartition partition = null; 25 Coarse.setFinerSize(10); 25 26 Stack<CoarserGraphElement> stack = Coarse.coarse(g); 26 27 … … 32 33 } 33 34 35 MQI.start(partition); 36 34 37 } 35 38 -
src/main/java/weka/clusterers/forMetisMQI/KLPartition.java
r7 r8 33 33 a = new Subgraph(g); 34 34 b = new Subgraph(g); 35 Random r = Random.instance(); 36 for(int i=0;i<g.size();i++) { 37 if(r.nextBoolean()) 38 a.addNode(g.getLabel(i)); 35 Iterator<Integer> graph = g.vtxsPermutation().iterator(); 36 int i = 0; 37 while(graph.hasNext()) { 38 int u = graph.next(); 39 if((i%2)==0) 40 a.addNode(u); 39 41 else 40 b.addNode(g.getLabel(i)); 42 b.addNode(u); 43 i++; 41 44 } 42 45 marked = new ArrayList<Integer>(); -
src/main/java/weka/clusterers/forMetisMQI/Subgraph.java
r7 r8 9 9 import java.util.TreeSet; 10 10 import java.util.Map.Entry; 11 12 import weka.clusterers.forMetisMQI.Graph.NodeInfo;13 11 14 12 public class Subgraph { … … 134 132 } 135 133 134 public int getWeight(int u, int v) { 135 int ret = -1; 136 if(isEdge(u,v)) 137 ret = g.getWeight(u, v); 138 return ret; 139 } 140 136 141 public Iterator<Integer> iterator() { 137 142 return listOfNodes.iterator();
Note: See TracChangeset
for help on using the changeset viewer.