On Sun, Feb 10, 2013 at 6:26 PM, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 02/10/2013 01:51 PM, tcb wrote:
Json may be interesting, but again, there must be an agreement on how to
encode the data. It seems to me one would simply replace xml for json,
and one would still need to define a graphml equivalent for it.


yes and no- its not much different than graphml, with a list of nodes, a list of edges and properties attached to each. But it seems like a simpler format (to read and write), easier to extend where necessary, and is a very direct representation of the data in your graph.
 
I have the following questions:

   Is there any documentation on how exactly is the networkx graph
   stored as json, other than looking at the source code?

not that I know of. But its very simple- just a list of nodes and a list of edges with the properties written as a dict for each.
 

   Are there other programs which currently read/write the same format
   used by networkx?


not sure about that either- I think there are some javascript libraries which read node/link format, but there is no agreed standard for this I am aware of- since its just json there is a certain amount of flexibility with the actual data layout.
 
   Can you parse it with Python in an event-based manner (this is
   important for large graphs)? Is this done in networkx?


Now that is a real problem. There is a python library I am aware of which reads json like that:

  http://lloyd.github.com/yajl/

but networkx uses standard json routines which just slurp in all the json at once and then parse it. If you're going to read all the data anyway, then it may not make too much difference for speed, but memory usage will be an issue.

On the C++ side I have used the boost spirit parser for json:

  http://www.codeproject.com/Articles/20027/JSON-Spirit-A-C-JSON-Parser-Generator-Implemented

which works really well.

So for the moment I just need something simple to work, but I'm interested in a better fix.

thanks,

-

Cheers,
Tiago


--
Tiago de Paula Peixoto <tiago@skewed.de>


_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool