- Timestamp:
- Sep 14, 2010, 5:27:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/UndirectedGraph.java
r9 r10 10 10 import weka.core.Instances; 11 11 import edu.uci.ics.jung.graph.UndirectedSparseGraph; 12 import edu.uci.ics.jung.graph.util.Pair; 12 13 13 14 public class UndirectedGraph extends UndirectedSparseGraph<Node, Edge> { … … 94 95 g.addEdge(e.clone(), getEndpoints(e)); 95 96 } 96 97 98 97 return g; 98 } 99 100 public int getAdjcncyWeight(Node v1){ 101 Iterator<Node> nbsIterator = getNeighbors(v1).iterator(); 102 int adjcncyWgt = 0; 103 while(nbsIterator.hasNext()) { 104 Node v2 = nbsIterator.next(); 105 Edge edge = findEdge(v1, v2); 106 adjcncyWgt += edge.getWeight(); 107 } 108 return adjcncyWgt; 109 } 110 111 public String toString() { 112 StringBuffer sb = new StringBuffer("Vertices:"); 113 for(Node v : getVertices()) { 114 sb.append(v+ " Adjw: "+ getAdjcncyWeight(v) + ","); 115 } 116 sb.setLength(sb.length()-1); 117 sb.append("\nEdges:"); 118 for(Edge e : getEdges()) { 119 Pair<Node> ep = getEndpoints(e); 120 sb.append(e+"["+ep.getFirst()+","+ep.getSecond()+"] "); 121 } 122 return sb.toString(); 99 123 } 100 124
Note: See TracChangeset
for help on using the changeset viewer.