Commit 112acab3 authored by Antoine's avatar Antoine

Changes for the LinLog layout.

parent d1e1dc06
...@@ -40,7 +40,7 @@ import org.graphstream.graph.implementations.MultiGraph; ...@@ -40,7 +40,7 @@ import org.graphstream.graph.implementations.MultiGraph;
public class TestLayout { public class TestLayout {
public static void main(String args[]) { public static void main(String args[]) {
System.getProperties().put("gs.ui.layout", "org.graphstream.ui.layout.springbox.implementations.LinLog"); //System.getProperties().put("gs.ui.layout", "org.graphstream.ui.layout.springbox.implementations.LinLog");
(new TestLayout()).test(); (new TestLayout()).test();
} }
...@@ -48,16 +48,17 @@ public class TestLayout { ...@@ -48,16 +48,17 @@ public class TestLayout {
Graph graph = new MultiGraph("test"); Graph graph = new MultiGraph("test");
// int steps = 50; // int steps = 50;
// Generator gen = new BarabasiAlbertGenerator(2); // Generator gen = new BarabasiAlbertGenerator(2);
int steps = 6; // int steps = 6;
Generator gen = new GridGenerator(); // Generator gen = new GridGenerator();
gen.addSink(graph); // gen.addSink(graph);
gen.begin(); // gen.begin();
for(int i=0; i<steps; i++) { // for(int i=0; i<steps; i++) {
gen.nextEvents(); // gen.nextEvents();
sleep(10); // sleep(10);
} // }
gen.end(); // gen.end();
try { graph.read("src-test/org/graphstream/ui/layout/test/data/WorldImport1999.edge"); } catch(Exception e) { e.printStackTrace(); }
// try { graph.write("grid7x7.dgs"); } catch(Exception e) { } // try { graph.write("grid7x7.dgs"); } catch(Exception e) { }
graph.display(); graph.display();
} }
......
...@@ -38,7 +38,9 @@ import org.graphstream.graph.implementations.MultiGraph; ...@@ -38,7 +38,9 @@ import org.graphstream.graph.implementations.MultiGraph;
import org.graphstream.stream.ProxyPipe; import org.graphstream.stream.ProxyPipe;
import org.graphstream.stream.file.FileSource; import org.graphstream.stream.file.FileSource;
import org.graphstream.stream.file.FileSourceDGS; import org.graphstream.stream.file.FileSourceDGS;
import org.graphstream.stream.file.FileSourceEdge;
import org.graphstream.stream.file.FileSourceGML; import org.graphstream.stream.file.FileSourceGML;
import org.graphstream.stream.file.FileSourcePajek;
import org.graphstream.stream.thread.ThreadProxyPipe; import org.graphstream.stream.thread.ThreadProxyPipe;
import org.graphstream.ui.geom.Point3; import org.graphstream.ui.geom.Point3;
import org.graphstream.ui.graphicGraph.GraphPosLengthUtils; import org.graphstream.ui.graphicGraph.GraphPosLengthUtils;
...@@ -61,13 +63,15 @@ import org.graphstream.ui.swingViewer.Viewer; ...@@ -61,13 +63,15 @@ import org.graphstream.ui.swingViewer.Viewer;
*/ */
public class TestLinLogLayout { public class TestLinLogLayout {
// public static final String GRAPH = "data/dorogovtsev_mendes6000.dgs"; public static final double a= 0; public static final double r=-1.3; public static double force = 3; // public static final String GRAPH = "data/dorogovtsev_mendes6000.dgs"; public static final double a= 0; public static final double r=-1.3; public static double force = 3;
public static final String GRAPH = "data/karate.gml"; public static double a= 0; public static double r=-1.3; public static double force = 3; // public static final String GRAPH = "data/karate.gml"; public static double a= 0; public static double r=-1.3; public static double force = 3;
// public static final String GRAPH = "data/dolphins.gml"; public static double a= 0; public static double r=-1.2; public static double force = 8; // public static final String GRAPH = "data/dolphins.gml"; public static double a= 0; public static double r=-1.2; public static double force = 8;
// public static final String GRAPH = "data/polbooks.gml"; public static double a= 0; public static double r=-2; public static double force = 3; public static final String GRAPH = "data/polbooks.gml"; public static double a= 0; public static double r=-1.9; public static double force = 5;
// public static final String GRAPH = "data/triangles.dgs"; public static double a= 1; public static double r=-1; public static double force = 0.5; // public static final String GRAPH = "data/triangles.dgs"; public static double a= 1; public static double r=-1; public static double force = 0.5;
// public static final String GRAPH = "data/FourClusters.dgs"; public static double a= 0; public static double r=-1; public static double force = 3; // public static final String GRAPH = "data/FourClusters.dgs"; public static double a= 0; public static double r=-1; public static double force = 3;
// public static final String GRAPH = "data/grid7x7.dgs"; public static double a= 0; public static double r=-1; public static double force = 100; // public static final String GRAPH = "data/grid7x7.dgs"; public static double a= 0; public static double r=-1; public static double force = 100;
// public static final String GRAPH = "data/imdb.dgs"; // public static final String GRAPH = "data/celegansneural.gml";public static double a= 0; public static double r=-1; public static double force = 5;
// public static final String GRAPH = "data/USAir97.net"; public static double a= 0; public static double r=-1.9; public static double force = 8;
// public static final String GRAPH = "data/WorldImport1999.edge"; public static double a= 0; public static double r=-2; public static double force = 5;
protected Graph graph; protected Graph graph;
...@@ -98,6 +102,8 @@ public class TestLinLogLayout { ...@@ -98,6 +102,8 @@ public class TestLinLogLayout {
CC.setPosition(Units.PX, 20, 20, 0); CC.setPosition(Units.PX, 20, 20, 0);
layout.configure(a, r, true, force); layout.configure(a, r, true, force);
layout.setQuality(0);
layout.setBarnesHutTheta(0.5);
graph.addAttribute("ui.antialias"); graph.addAttribute("ui.antialias");
graph.addAttribute("ui.stylesheet", styleSheet); graph.addAttribute("ui.stylesheet", styleSheet);
...@@ -106,15 +112,23 @@ public class TestLinLogLayout { ...@@ -106,15 +112,23 @@ public class TestLinLogLayout {
graph.addSink(layout); graph.addSink(layout);
layout.addAttributeSink(graph); layout.addAttributeSink(graph);
FileSource dgs = GRAPH.endsWith(".gml") ? new FileSourceGML() : new FileSourceDGS(); FileSource dgs = null;
if(GRAPH.endsWith(".gml")) dgs = new FileSourceGML();
else if(GRAPH.endsWith(".dgs")) dgs= new FileSourceDGS();
else if(GRAPH.endsWith(".net")) dgs = new FileSourcePajek();
else if(GRAPH.endsWith(".edge")) dgs = new FileSourceEdge();
else throw new RuntimeException("WTF?");
dgs.addSink(graph); dgs.addSink(graph);
try { try {
dgs.begin(getClass().getResourceAsStream(GRAPH)); dgs.begin(getClass().getResourceAsStream(GRAPH));
for (int i = 0; i < 5000 && dgs.nextEvents(); i++) { for (int i = 0; i < 5000 && dgs.nextEvents(); i++) {
// fromViewer.pump(); if(i%1==0) {
// layout.compute(); fromViewer.pump();
// sleep(100); layout.compute();
findCommunities(1);
updateCC();
}
} }
dgs.end(); dgs.end();
} catch (IOException e1) { } catch (IOException e1) {
...@@ -130,10 +144,14 @@ public class TestLinLogLayout { ...@@ -130,10 +144,14 @@ public class TestLinLogLayout {
if (graph.hasAttribute("ui.viewClosed")) { if (graph.hasAttribute("ui.viewClosed")) {
loop = false; loop = false;
} else { } else {
//sleep(1000); // System.out.print(" * compute ...");
//sleep(1);
layout.compute(); layout.compute();
findCommunities(1.3); // System.out.print(" communities ...");
findCommunities(1);
// System.out.print(" CC ...");
updateCC(); updateCC();
// System.out.println(" OK");
} }
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment