1
2
3
4
5
6
7
8 package edu.uci.ics.jung.samples;
9
10 import java.io.IOException;
11
12 import javax.swing.JFrame;
13
14 import com.google.common.base.Supplier;
15
16 import edu.uci.ics.jung.algorithms.layout.FRLayout;
17 import edu.uci.ics.jung.graph.Graph;
18 import edu.uci.ics.jung.graph.UndirectedSparseGraph;
19 import edu.uci.ics.jung.io.PajekNetReader;
20 import edu.uci.ics.jung.visualization.VisualizationViewer;
21
22
23
24
25 public class SimpleGraphDraw
26 {
27
28 @SuppressWarnings({ "rawtypes", "unchecked" })
29 public static void main(String[] args) throws IOException
30 {
31 JFrame jf = new JFrame();
32 Graph g = getGraph();
33 VisualizationViewer vv = new VisualizationViewer(new FRLayout(g));
34 jf.getContentPane().add(vv);
35 jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
36 jf.pack();
37 jf.setVisible(true);
38 }
39
40
41
42
43
44
45
46 @SuppressWarnings({ "rawtypes", "unchecked" })
47 public static Graph getGraph() throws IOException
48 {
49 PajekNetReader pnr = new PajekNetReader(new Supplier(){
50 public Object get() {
51 return new Object();
52 }});
53 Graph g = new UndirectedSparseGraph();
54
55 pnr.load("src/main/resources/datasets/simple.net", g);
56 return g;
57 }
58 }