GraphStream Users

Archives de la liste Aide


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


Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT gmail.com>
  • To: wordg2 AT wordgraph.com
  • Cc: graphstream-users AT litislab.fr
  • 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 ...
Regards.

Guilhelm

2012/7/5 <wordg2 AT wordgraph.com>
Guilhelm,

   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.

Regards
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 gmail.com>:

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.

Regards.
Guilhelm

2012/7/4 <bgsrvey AT wordgraph.com>


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

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


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

                graph.addAttribute("ui.antialias");
                try {
                        Thread.sleep(1000);
                        FileInputStream fstream = new
FileInputStream(filePath);
                        DataInputStream in = new DataInputStream(fstream);
                        BufferedReader br = new BufferedReader(new
InputStreamReader(in));
                        String strLine;
                        while ((strLine = br.readLine()) != null) {
                                System.out.println(strLine);
                        }
                        fstream.close();
                        FileSource source =
FileSourceFactory.sourceFor(filePath);
                        Thread.sleep(5000);
                        source.addSink(graph);
                        source.begin(filePath);
                        while (source.nextEvents());
                        source.end();
                } catch (InterruptedException ix) {
                        System.out.println("interrupted while waiting on
invokeAndWait()");
                } catch (IOException ioe) {
                        System.out.println("IOE");
                        ioe.printStackTrace();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}




--
Guilhelm Savin
PhD Student of Computer Science
LITIS, University of Le Havre
\/\/\/\/\/\/
http://g <http://litis.univ-lehavre.fr/~savin>savin.lewub.org
http://d3-project.org
http://iscn.univ-lehavre.fr
http://graphstream-project.org <http://www.graphstream-project.org>
/\/\/\/\/\/\







--
Guilhelm Savin
PhD Student of Computer Science




Archives gérées par MHonArc 2.6.16.

Top of page