Changeset 24 for src/main/java/weka/clusterers/MetisMQIClusterer.java
- Timestamp:
- Oct 6, 2010, 4:02:40 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/MetisMQIClusterer.java
r22 r24 11 11 import weka.clusterers.forMetisMQI.graph.Node; 12 12 import weka.clusterers.forMetisMQI.graph.UndirectedGraph; 13 import weka.clusterers.forMetisMQI.util.Configuration; 13 14 import weka.core.Attribute; 14 15 import weka.core.Capabilities; … … 23 24 OptionHandler { 24 25 25 private int numberOfClusters = 2;26 27 private int sizeFinerGraph = 10;28 29 26 /** 30 27 * It maps each cluster with an integer id. … … 37 34 private Map<Node, Integer> nodeMap = null; 38 35 39 /** 40 * True if a random bisection must be used. 41 */ 42 private boolean randomBisection = false; 43 36 37 private Configuration conf = null; 44 38 /** 45 39 * … … 52 46 UndirectedGraph g = new UndirectedGraph(); 53 47 g.loadFromInstance(data); 54 Set<Set<Node>> clusters = GraphAlgorithms.metisMqi(g, numberOfClusters, 55 sizeFinerGraph, randomBisection); 48 Set<Set<Node>> clusters = GraphAlgorithms.metisMqi(g); 56 49 setNumClusters(clusters.size()); 57 50 int i = 0; … … 125 118 optionString = Utils.getOption('R', options); 126 119 setRandomBisection(Boolean.parseBoolean(optionString)); 120 optionString = Utils.getOption('V', options); 121 if (optionString.length() != 0) { 122 setVerboseLevel(Integer.parseInt(optionString)); 123 } 124 } 125 126 private void setVerboseLevel(int verboseLevel) { 127 Configuration.instance().setVerboseLevel(verboseLevel); 127 128 } 128 129 129 130 private void setRandomBisection(boolean b) { 130 this.randomBisection = b;131 Configuration.instance().setRandomBisection(b); 131 132 } 132 133 … … 146 147 result.add("" + getSizeFinerGraph()); 147 148 result.add("-R"); 149 result.add("" + getRandomBisection()); 150 result.add("-V"); 151 result.add("" + getVerboseLevel()); 148 152 return (String[]) result.toArray(new String[result.size()]); 149 153 } 150 154 155 private boolean getRandomBisection() { 156 return Configuration.instance().isRandomBisection(); 157 } 158 159 private int getVerboseLevel() { 160 return Configuration.instance().getVerboseLevel(); 161 } 162 151 163 private int getSizeFinerGraph() { 152 return sizeFinerGraph;164 return Configuration.instance().getSizeFinerGraph(); 153 165 } 154 166 155 167 private int getNumClusters() { 156 return numberOfClusters;168 return Configuration.instance().getNumberOfClusters(); 157 169 } 158 170 … … 170 182 result.addElement(new Option("\tsize of finer graph.\n" 171 183 + "\t(default 10).", "S", 1, "-S <num>")); 184 result.addElement(new Option("\trandom bisection.\n" 185 + "\t(default false).", "R", 1, "-V <boolean>")); 186 result.addElement(new Option("\tverbosity of graphical output.\n" 187 + "\t(default 1).", "V", 1, "-V <num>")); 172 188 return result.elements(); 173 189 } 174 190 175 191 private void setSizeFinerGraph(int size) { 176 this.sizeFinerGraph = size;192 Configuration.instance().setSizeFinerGraph(size); 177 193 } 178 194 179 195 private void setNumClusters(int n) { 180 this.numberOfClusters = n;196 Configuration.instance().setNumberOfClusters(n); 181 197 } 182 198 … … 198 214 @Override 199 215 public int numberOfClusters() throws Exception { 200 return numberOfClusters;216 return Configuration.instance().getNumberOfClusters(); 201 217 } 202 218
Note: See TracChangeset
for help on using the changeset viewer.