Changeset 15 for src/main/java/weka/clusterers/forMetisMQI/util
- Timestamp:
- Sep 17, 2010, 6:04:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/weka/clusterers/forMetisMQI/util/Util.java
r14 r15 91 91 vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>()); 92 92 vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); 93 93 JFrame frame = new JFrame("Simple Graph View"); 94 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 95 frame.getContentPane().add(vv); 96 frame.pack(); 97 frame.setVisible(true); 98 } 99 100 public static void viewFlowGraph(Graph<Node, Edge> g, Map<Edge, Number> edgeFlowMap){ 101 class EdgeTransformer implements Transformer<Edge,String> { 102 Map<Edge,Number> edgeFlowMap = null; 103 public String transform(Edge edge){ 104 return edgeFlowMap.get(edge) + "/" + edge.getCapacity(); 105 } 106 public EdgeTransformer(Map<Edge,Number> edgeFlowMap) { 107 this.edgeFlowMap = edgeFlowMap; 108 } 109 } 110 Layout<Node, Edge> layout = new FRLayout<Node, Edge>(g); 111 layout.setSize(new Dimension(800,600)); // sets the initial size of the space 112 // The BasicVisualizationServer<V,E> is parameterized by the edge types 113 BasicVisualizationServer<Node,Edge> vv = 114 new BasicVisualizationServer<Node,Edge>(layout); 115 vv.setPreferredSize(new Dimension(800,600)); //Sets the viewing area size 116 vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>()); 117 vv.getRenderContext().setEdgeLabelTransformer(new EdgeTransformer(edgeFlowMap)); 94 118 JFrame frame = new JFrame("Simple Graph View"); 95 119 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Note: See TracChangeset
for help on using the changeset viewer.