Changeset 20 for src/main/java/weka/clusterers/forMetisMQI/graph
- Timestamp:
- Sep 30, 2010, 5:33:45 PM (14 years ago)
- Location:
- src/main/java/weka/clusterers/forMetisMQI/graph
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/graph/Bisection.java
r18 r20 139 139 } 140 140 141 public Subgraph getLargerSubgraph() { 142 if(a.getVertexCount() < b.getVertexCount()) 143 return b; 144 else 145 return a; 146 } 147 141 148 /** 142 * Returns the smaller not emptysubgraph of this bisection, null otherwise.149 * Returns the smaller subgraph of this bisection, null otherwise. 143 150 * @return 144 151 */ 145 public Subgraph getSmallerNotEmptySubgraph() { 146 if(a.getVertexCount() > 0 && b.getVertexCount() == 0) 147 return a; 148 if(b.getVertexCount() > 0 && a.getVertexCount() == 0) 149 return b; 152 public Subgraph getSmallerSubgraph() { 150 153 if(a.getVertexCount() < b.getVertexCount()) 151 154 return a; -
src/main/java/weka/clusterers/forMetisMQI/graph/UndirectedGraph.java
r17 r20 1 1 package weka.clusterers.forMetisMQI.graph; 2 2 3 import java.io.PrintStream; 3 4 import java.util.ArrayList; 4 5 import java.util.Collection; 6 import java.util.HashMap; 5 7 import java.util.Iterator; 6 8 import java.util.List; 9 import java.util.TreeMap; 7 10 8 11 import weka.clusterers.forMetisMQI.Random; … … 109 112 } 110 113 114 public void printForMetis(PrintStream output) { 115 TreeMap<Integer,Node> map = new TreeMap<Integer,Node>(); 116 HashMap<Node,Integer> reverseMap = new HashMap<Node,Integer>(); 117 Iterator<Node> nodesIterator = getVertices().iterator(); 118 int id = 1; 119 while(nodesIterator.hasNext()) { 120 Node node = nodesIterator.next(); 121 map.put(id, node); 122 reverseMap.put(node,id); 123 id++; 124 } 125 output.println(getVertexCount() + " "+ getEdgeCount()); 126 Iterator<Integer> mappedIterator = map.keySet().iterator(); 127 while(mappedIterator.hasNext()) { 128 id = mappedIterator.next(); 129 Iterator<Node> neighbors = getNeighbors(map.get(id)).iterator(); 130 while(neighbors.hasNext()){ 131 output.print(reverseMap.get(neighbors.next())); 132 if(neighbors.hasNext()) output.print(" "); 133 } 134 output.println(); 135 } 136 } 137 111 138 public String toString() { 112 139 StringBuffer sb = new StringBuffer("Vertices:");
Note: See TracChangeset
for help on using the changeset viewer.