- Timestamp:
- Sep 16, 2010, 10:44:40 AM (14 years ago)
- Location:
- src/main/java/weka/clusterers/forMetisMQI/graph
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.