On 02/10/2013 08:25 PM, tcb wrote:
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.
This might actually be a problem from the point of view of interoperability... One can easily imagine different programs with their own json representation which are mutually incompatible. Although, one must admit there are very few sane ways to do the same thing, i.e. represent a graph with node/edge properties.
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:
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.
Implementing it like this in graph-tool would make it automatically a second-grade citizen, since loading very large graphs efficiently memory-wise is supported by all other formats.
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-Genera...
which works really well.
Nice. A spirit parser such as this would do the trick for graph-tool, since not only it would be event-driven, but it would also be faster than Python based. This actually satisfies me quite a bit.
So for the moment I just need something simple to work, but I'm interested in a better fix.
I'll take a look at the networkx format, and see what I can cook up with the json spirit parser, when I have some time. It should not be very difficult. Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>