2

Background

I am new to both GraphStream and Java. However, I do have experience with other OOP-languages like C++. I personally find the tutorials for GraphStream quite sparse, for example the Layout API doesn't mention which layout algorithms are valid. Thus am looking for a more consolidated tutorial.

Question

Using GraphStream, I want to be able to do the following basic operations:

  • Import a graph as a .dgs
  • Import a graph as a .csv
  • Change from the automatic layout to a specified layout (please list which are valid in the first place too)
  • Change all edge attributes (e.g. weight)
  • Find at most n paths of length l or less from s to t.
  • Add an event (e.g. click node, get user input about about length of paths from that node to show, prune/grow appropriately)

Code

Note

I am using Eclipse. From the GraphStream repository, I have added the following to my build path: gs-algo-1.3, gs-core-1.3, gs-openord-master, and gs-ui-1.3

//import anything I might need
import org.graphstream.graph.*;
import org.graphstream.graph.implementations.*;
import org.graphstream.stream.file.*;
import org.graphstream.algorithm.*;
import org.graphstream.ui.layout.*;
import java.io.IOException;
@SuppressWarnings("unused")

public class pleaseHelpMe {
    public static void main(String args[]) throws IOException, InterruptedException {
        //do something that was in some code somewhere... 
        //please explain
        System.setProperty("org.graphstream.ui.renderer","org.graphstream.ui.j2dviewer.J2DGraphRenderer");


        //instantiate a graph
        Graph graph = new SingleGraph("thisGraphNeedsHelp");
        graph.addAttribute("ui.antialias"); //this does something...
        graph.addAttribute("ui.quality"); //this sounds less important...
        graph.setAttribute("ui.stylesheet", "url(../myStyle.css);"); //get some style

        //errors, errors everywhere
        //OpenOrdLayout layout = new OpenOrdLayout();
        //layout.init(graph);
        //layout.compute();

        //changing all edges layout.weight is not that simple
        //graph.setAttribute("edges","layout.weight:4");

        graph.dsiplay();//this just makes the canvas?

        FileSource source = new FileSourceDGS(); //prep. to get a file


        //make graph a sink of source to get the contents of the file
        source.addSink(graph);

        source.begin("../dgs_files/awesomeFile.dgs");//read the file? strange command name i.m.o. file below.

        while(source.nextEvents()); //keep graph interactive? or is this the GraphStream version of readline?

        source.end() //close file? or end interaction?


        //find paths
        //get user input

    }
}

enter image description here

DGS File

DGS004
null 0 0
an a ui.label:a
an b ui.label:b
an c ui.label:c
an d ui.label:d
an e ui.label:e
an f ui.label:f
ae a_c a > c
ae c_e c > e
ae e_a e > a
ae b_d b > d
ae d_f d > f
ae f_b f > b
ae f_a f > a
ae e_b e > b
ae d_c d > c

CSS File

node:clicked {
    fill-color: purple;
    text-size:    16;
    text-style:   bold;
    text-color:   #FFF;
    text-alignment: at-right; 
    text-padding: 3px, 2px; 
    text-background-mode: rounded-box; 
    text-background-color: #A7CC; 
    text-color: white; 
    text-offset: 5px, 0px; 
}

node {
    size:         20px;
    shape:        circle;
    fill-color:   #8facb4;
    stroke-mode:  plain;
    stroke-color: black;

}

edge {
    size:           2px;
    fill-mode:      plain;
    /*changing edge layout here also doesn't work*/
}

/*edge:clicked isn't a thing... :( */
SumNeuron
  • 4,850
  • 5
  • 39
  • 107
  • 1
    Asking for off-site material is off-topic here. The specific questions that you posed look fine, but they should be split up into discrete questions. – chrylis -cautiouslyoptimistic- Oct 27 '16 at 04:43
  • 1
    @chrylis I understand where you are coming. However the documentation for GraphStream is a bit off till one can use that to learn. The tag `graphstream` already exists so it clearly isn't the first. I am happy to make the documentation, but first i need to understand their internal syntax peculiarities. – SumNeuron Oct 27 '16 at 05:19

0 Answers0