Changeset 23 for src/main/java
- Timestamp:
- Oct 5, 2010, 9:55:49 PM (14 years ago)
- Location:
- src/main/java/weka/clusterers/forMetisMQI
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/GraphAlgorithms.java
r22 r23 11 11 import weka.clusterers.forMetisMQI.graph.UndirectedGraph; 12 12 import weka.clusterers.forMetisMQI.util.CoarserGraphElement; 13 import weka.clusterers.forMetisMQI.util.GraphsFrame; 13 14 import weka.clusterers.forMetisMQI.util.Util; 14 15 … … 81 82 */ 82 83 static public Set<Set<Node>> metisMqi(UndirectedGraph g, int numberOfCluster, int sizeFinerGraph, boolean randomBisection) { 84 GraphsFrame gf = new GraphsFrame("Prova"); 83 85 System.out.println("Vertex count: " + g.getVertexCount()); 84 86 System.out.println("Edges count: " + g.getEdgeCount()); … … 93 95 Set<Set<Node>> clusters = new HashSet<Set<Node>>(); 94 96 UndirectedGraph gclone = g.clone(); 95 // Util.viewGraph(g);97 gf.addPanel(Util.panelGraph(gclone)); 96 98 for (int i = 0; i < numberOfCluster; i++) { 97 99 Bisection bisection = null; … … 125 127 } 126 128 } 127 Util.viewClusters(gclone, clusters); 129 gf.addPanel(Util.panelClusters(gclone, clusters)); 130 gf.setVisible(true); 128 131 return clusters; 129 132 } -
src/main/java/weka/clusterers/forMetisMQI/util/Util.java
r18 r23 11 11 12 12 import javax.swing.JFrame; 13 import javax.swing.JPanel; 13 14 14 15 import org.apache.commons.collections15.Transformer; … … 19 20 import weka.clusterers.forMetisMQI.graph.UndirectedGraph; 20 21 import edu.uci.ics.jung.algorithms.layout.FRLayout; 21 import edu.uci.ics.jung.algorithms.layout.ISOMLayout;22 22 import edu.uci.ics.jung.algorithms.layout.Layout; 23 23 import edu.uci.ics.jung.graph.Graph; … … 27 27 public class Util { 28 28 29 public static void viewCluster(Graph<Node, Edge> g, Set<Node> cluster) {29 public static JPanel panelCluster(Graph<Node, Edge> g, Set<Node> cluster) { 30 30 Set<Set<Node>> clusters = new HashSet<Set<Node>>(); 31 31 clusters.add(cluster); 32 viewClusters(g, clusters);32 return panelClusters(g, clusters); 33 33 } 34 34 35 35 36 public static void viewClusters(Graph<Node, Edge> g, Set<Set<Node>> clusters) {36 public static JPanel panelClusters(Graph<Node, Edge> g, Set<Set<Node>> clusters) { 37 37 Layout<Node, Edge> layout = new FRLayout<Node, Edge>(g); 38 38 layout.setSize(new Dimension(800, 600)); // sets the initial size of the space … … 85 85 new ToStringLabeller<Edge>()); 86 86 vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); 87 JFrame frame = new JFrame("Graph View"); 88 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 89 frame.getContentPane().add(vv); 90 frame.pack(); 91 frame.setVisible(true); 87 return vv; 92 88 } 93 89 94 public static void viewGraph(Graph<Node, Edge> g){90 public static JPanel panelGraph(Graph<Node, Edge> g){ 95 91 Layout<Node, Edge> layout = new FRLayout<Node, Edge>(g); 96 92 layout.setSize(new Dimension(800,600)); // sets the initial size of the space … … 101 97 vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>()); 102 98 vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); 103 JFrame frame = new JFrame("Simple Graph View"); 104 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 105 frame.getContentPane().add(vv); 106 frame.pack(); 107 frame.setVisible(true); 99 return vv; 108 100 } 109 101 110 public static void viewFlowGraph(Graph<Node, Edge> g, Map<Edge, Number> edgeFlowMap){102 public static JPanel panelFlowGraph(Graph<Node, Edge> g, Map<Edge, Number> edgeFlowMap){ 111 103 class EdgeTransformer implements Transformer<Edge,String> { 112 104 Map<Edge,Number> edgeFlowMap = null; … … 126 118 vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>()); 127 119 vv.getRenderContext().setEdgeLabelTransformer(new EdgeTransformer(edgeFlowMap)); 128 JFrame frame = new JFrame("Simple Graph View"); 129 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 130 frame.getContentPane().add(vv); 131 frame.pack(); 132 frame.setVisible(true); 120 return vv; 133 121 } 134 122
Note: See TracChangeset
for help on using the changeset viewer.