-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNetworkLayout.java
46 lines (36 loc) · 1.41 KB
/
NetworkLayout.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import processing.core.PApplet;
import jdg.graph.AdjacencyListGraph;
import jdg.io.GraphReader;
import jdg.io.GraphReader_MTX;
import jdg.layout.Layout;
/**
* A program for computing network layouts with the "spring embedder" paradigm
*
* This program requires one parameter: the input network, stored in Matrix Market format (.mtx)
*
* @author Luca Castelli Aleardi (Ecole Polytechnique, INF421, 2018)
*/
public class NetworkLayout extends DrawGraph {
/**
* For running the PApplet as Java application
*/
public static void main(String args[]) {
System.out.println("PI INF421 (2018)");
if(args.length==0 || args.length>1) {
System.out.println("Error: wrong arguments, one parameter required");
System.out.println("Usage example: java -jar NetworkLayout networks/network.mtx");
System.exit(0);
}
if(args[0].endsWith(".mtx")==false) {
System.out.println("Error: wrong input format (MTX format supported)");
System.exit(0);
}
String filename=args[0];
GraphReader reader=new GraphReader_MTX(); // open networks stores in Matrix Market format (.mtx)
AdjacencyListGraph g=reader.read(filename); // read input network from file
//FastFR91Layout fast = new FastFR91Layout(g, 400, 400);
Layout.setRandomPoints(g, 400, 400); // set initial locations at random
DrawGraph.inputGraph=g; // set the input network
PApplet.main(new String[] { "DrawGraph" }); // start the Processing viewer
}
}