我使用 Jung 来绘制图表,输入为 .net 格式(使用 txt2pajek 构建)。我想查看边缘和输出的权重。请帮我看看怎么做?谢谢
代码和.net文件格式为:
package pGraph;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.apache.commons.collections15.FactoryUtils;
import org.apache.commons.collections15.Transformer;
import org.apache.commons.collections15.functors.MapTransformer;
import com.sun.xml.internal.ws.api.server.Container;
import pGraph.JungExample2.MyRenderer;
import edu.uci.ics.jung.algorithms.layout.FRLayout;
import edu.uci.ics.jung.graph.DirectedSparseGraph;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.io.PajekNetReader;
import edu.uci.ics.jung.visualization.GraphZoomScrollPane;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse;
import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
import edu.uci.ics.jung.visualization.decorators.EdgeShape;
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
/**
* A class that shows the minimal work necessary to load and visualize a graph.
*/
public class D1
{
public static void main(String[] args) throws IOException
{
JFrame jf = new JFrame();
PajekNetReader pnr = new PajekNetReader(FactoryUtils.instantiateFactory(Object.class));
Graph g = new DirectedSparseGraph();
VisualizationViewer vv = new VisualizationViewer(new FRLayout(g));
vv.getRenderContext().setVertexLabelTransformer(pnr.getVertexLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
pnr.load("F:\\1c\\qq.net", g);
DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
vv.setGraphMouse(gm);
System.out.println(g.toString());
final DefaultModalGraphMouse<String, Number> graphMouse = new DefaultModalGraphMouse<String, Number>();
graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
vv.setGraphMouse(graphMouse);
final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
jf.getContentPane().add(vv) ;
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
}
}
*顶点 5
1“吨”
2“乙”
3 "c"
4个“d”
5个“一”
*弧线
1 2 0.2
3 4 0.9
5 4 0.86