GraphStream Users

Archives de la liste Aide

Re: null pointer at source.addSink(graph);

Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT>
  • To: wordg2 AT
  • Cc: graphstream-users AT
  • Subject: Re: null pointer at source.addSink(graph);
  • Date: Thu, 5 Jul 2012 16:51:54 +0200

Hi Bob,

Thanks for your feedback. I fix FileSourceFactory to return a dgs source
when extension is .dgs (before that, it just checks the first line of the
file, trying to match it with DGSxxx).

About GEXF input, it should work so it is not expected ! Can you tell me
what is your version of GraphStream and maybe send me a gexf file that
you are using ?

What kind and format of graph example do you want ?
You can use generators of gs-algo to create fastly some graphs :


You just have to connect a generator to a FileSink :

| Generator gen = new BarabasiAlbertGenerator();
| FileSink out = new FileSinkDGS();
| out.begin("myGenerateGraph.dgs");
| gen.addSink(out);
| gen.begin();
| for (int i = 0; i < 100; i++)
|   gen.nextEvents();
| out.end();
| gen.end();

Note that actually there is only DGS that support dynamics. We
have to make some work on GEXF to add support for spells. But
you can generate a snapshot of your graph :

| Generator gen = new BarabasiAlbertGenerator();
| Graph g       = new AdjacencyListGraph("myGenerateGraph");
| FileSink out  = new FileSinkGEXF();
| gen.addSink(g);
| gen.begin();
| for (int i = 0; i < 100; i++)
|   gen.nextEvents();
| gen.end();
| out.writeAll(g, "myGenerateGraph.gexf");

Hope this helps ...


2012/7/5 <wordg2 AT>

   Thank you for your reply.  I found that the .dgs file did not have the first line as "DGS004" when I added that I did not get the error.
   I have tried to use .gexf files as a source and am not able to get them to run.  Is that expected?  Are there some good example graph files out on the web?  Are there more example programs one could use?
   I am really looking forward to working with your system. I think it is important.

Bob Garvey

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)

$ uname -a
Linux bob-EL1331G 3.2.0-26-generic #41-Ubuntu SMP Thu Jun 14 16:26:01 UTC 2012 i
686 athlon i386 GNU/Linux

Quoting guilhelm savin <guilhelm.savin AT>:

Hi and welcome to GraphStream community.

Can you give me more informations :
- the stack trace of the exception
- the version of your GraphStream jar
- your java version and OS

I try your code and got no exception.


2012/7/4 <bgsrvey AT>

First try with GraphStream.  I can't get over the hump of (FileSource)
being null.

I will be grateful for any assistance.  gs looks like a great

public class Tutorial2 {
        public static void main(String args[]) {
                Graph graph = new SingleGraph("Tutorial2");
                String filePath = "tutorial2.dgs";
                System.out.println("ID:" + graph.getId());

                try {
                        FileInputStream fstream = new
                        DataInputStream in = new DataInputStream(fstream);
                        BufferedReader br = new BufferedReader(new
                        String strLine;
                        while ((strLine = br.readLine()) != null) {
                        FileSource source =
                        while (source.nextEvents());
                } catch (InterruptedException ix) {
                        System.out.println("interrupted while waiting on
                } catch (IOException ioe) {
                } catch (Exception e) {

Guilhelm Savin
PhD Student of Computer Science
LITIS, University of Le Havre
http://g <> <>

Guilhelm Savin
PhD Student of Computer Science

Archives gérées par MHonArc 2.6.16.

Top of page