Search in sources :

Example 1 with RandomWalk

use of org.graphstream.algorithm.randomWalk.RandomWalk in project gs-ui-javafx by graphstream.

the class TestRandomWalk method run.

private void run() {
    MultiGraph graph = new MultiGraph("random walk");
    DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
    RandomWalk rwalk = new RandomWalk();
    gen.addSink(graph);
    gen.begin();
    for (int i = 0; i < 400; i++) {
        gen.nextEvents();
    }
    gen.end();
    graph.setAttribute("ui.stylesheet", styleSheet);
    graph.setAttribute("ui.quality");
    graph.setAttribute("ui.antialias");
    graph.display();
    rwalk.setEntityCount(graph.getNodeCount() * 2);
    rwalk.setEvaporation(0.97);
    rwalk.setEntityMemory(40);
    rwalk.init(graph);
    for (int i = 0; i < 3000; i++) {
        rwalk.compute();
        if (i % 100 == 0) {
            System.err.println("step " + i);
            updateGraph(graph, rwalk);
        }
    // Thread.sleep(100)
    }
    rwalk.terminate();
    updateGraph(graph, rwalk);
    graph.setAttribute("ui.screenshot", "randomWalk.png");
}
Also used : DorogovtsevMendesGenerator(org.graphstream.algorithm.generator.DorogovtsevMendesGenerator) RandomWalk(org.graphstream.algorithm.randomWalk.RandomWalk) MultiGraph(org.graphstream.graph.implementations.MultiGraph)

Aggregations

DorogovtsevMendesGenerator (org.graphstream.algorithm.generator.DorogovtsevMendesGenerator)1 RandomWalk (org.graphstream.algorithm.randomWalk.RandomWalk)1 MultiGraph (org.graphstream.graph.implementations.MultiGraph)1