Changeset 11 for src/main/java/weka/clusterers/forMetisMQI/graph
- Timestamp:
- Sep 16, 2010, 10:44:40 AM (14 years ago)
- Location:
- src/main/java/weka/clusterers/forMetisMQI/graph
- Files:
-
- 1 added
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/graph/Bisection.java
r10 r11 1 package weka.clusterers.forMetisMQI ;1 package weka.clusterers.forMetisMQI.graph; 2 2 3 3 import java.util.HashSet; … … 6 6 7 7 8 public class KLPartition { 8 9 public class Bisection { 9 10 10 11 private Subgraph a = null; … … 13 14 14 15 private Set<Node> marked = null; 16 17 private UndirectedGraph g = null; 15 18 16 private KLPartition() {19 private Bisection() { 17 20 } 18 21 19 public KLPartition(Subgraph s) { 20 UndirectedGraph g = s.getGraph(); 22 /** 23 * Initialize the bisection with a given subgraph. 24 * @param s 25 */ 26 public Bisection(Subgraph s) { 27 g = s.getGraph(); 21 28 a = s; 22 29 b = new Subgraph(g); … … 30 37 } 31 38 32 public KLPartition(UndirectedGraph g){ 39 /** 40 * Creates a bisection choosing randomly the nodes for each subgraph. 41 * @param g 42 */ 43 public Bisection(UndirectedGraph g){ 44 this.g = g; 33 45 a = new Subgraph(g); 34 46 b = new Subgraph(g); … … 44 56 } 45 57 marked = new HashSet<Node>(); 58 } 59 60 public UndirectedGraph getGraph() { 61 return g; 46 62 } 47 63 … … 106 122 } 107 123 108 public KLPartition copy(){109 KLPartition clone = new KLPartition();124 public Bisection copy(){ 125 Bisection clone = new Bisection(); 110 126 clone.a = (Subgraph) a.clone(); 111 127 clone.b = (Subgraph) b.clone(); -
src/main/java/weka/clusterers/forMetisMQI/graph/Edge.java
r10 r11 1 package weka.clusterers.forMetisMQI ;1 package weka.clusterers.forMetisMQI.graph; 2 2 3 3 public class Edge { … … 48 48 @Override 49 49 public String toString() { 50 return "E" + id + " w:" + weight;50 return Integer.toString(capacity); 51 51 } 52 52 -
src/main/java/weka/clusterers/forMetisMQI/graph/Node.java
r10 r11 1 package weka.clusterers.forMetisMQI ;1 package weka.clusterers.forMetisMQI.graph; 2 2 3 3 -
src/main/java/weka/clusterers/forMetisMQI/graph/Subgraph.java
r9 r11 1 package weka.clusterers.forMetisMQI ;1 package weka.clusterers.forMetisMQI.graph; 2 2 3 3 import java.util.ArrayList; … … 11 11 import java.util.Map.Entry; 12 12 13 import edu.uci.ics.jung.algorithms.filters.FilterUtils; 14 15 13 16 public class Subgraph { 14 17 … … 17 20 private Set<Node> nodes = null; 18 21 19 // private BitSet nodes = null;20 // private List<Integer> listOfNodes = null;21 22 private HashMap<Node,Integer> ID = null; 22 23 private HashMap<Node,Integer> ED = null; … … 34 35 } 35 36 37 public Subgraph(UndirectedGraph g, Set<Node> nodes) { 38 this.g = g; 39 this.nodes = new HashSet<Node>(); 40 this.ID = new HashMap<Node,Integer>(); 41 this.ED = new HashMap<Node,Integer>(); 42 this.bucketGain = new HashMap<Integer, List<Node>>(); 43 this.gainSet = new TreeSet<Integer>(); 44 Iterator<Node> nodesIterator = nodes.iterator(); 45 while(nodesIterator.hasNext()) { 46 addVertex(nodesIterator.next()); 47 } 48 } 49 36 50 public UndirectedGraph getGraph() { 37 51 return g; 38 52 } 39 53 54 /** 55 * Adds to the subgraph the node u iff u belongs to the graph. 56 * @param u 57 */ 40 58 public void addVertex(Node u) { 41 nodes.add(u); 42 ID.put(u, 0); 43 ED.put(u, 0); 44 recomputeGain = true; 59 if(g.containsVertex(u)) { 60 nodes.add(u); 61 ID.put(u, 0); 62 ED.put(u, 0); 63 recomputeGain = true; 64 } 45 65 } 46 66 … … 233 253 return clone; 234 254 } 255 256 public UndirectedGraph createInducedSubgraph() { 257 return FilterUtils.createInducedSubgraph(nodes,g); 258 } 235 259 } -
src/main/java/weka/clusterers/forMetisMQI/graph/UndirectedGraph.java
r10 r11 1 package weka.clusterers.forMetisMQI ;1 package weka.clusterers.forMetisMQI.graph; 2 2 3 3 import java.util.ArrayList; … … 6 6 import java.util.List; 7 7 8 import weka.clusterers.forMetisMQI.Random; 8 9 import weka.core.Attribute; 9 10 import weka.core.Instance; … … 89 90 g.addVertex(nodesIterator.next().clone()); 90 91 } 91 92 92 Iterator<Edge> edgesIterator = getEdges().iterator(); 93 93 while(edgesIterator.hasNext()) {
Note: See TracChangeset
for help on using the changeset viewer.