Read GML format graphs by using LightGraphs.jl

229 views
Skip to first unread message

Charles Novaes de Santana

unread,
Jul 11, 2015, 6:48:52 AM7/11/15
to julia...@googlegroups.com
Hi folks,

Following the suggestion of Seth (https://groups.google.com/forum/#!topic/julia-users/Ftdo2LmxC-g) I am trying to use LightGraphs.jl to read my graph files.

My graphs are in GML format (http://gephi.github.io/users/supported-graph-formats/gml-format/). However, as far as I understand, LightGraphs.jl can not read graphs in this format.

I just found this thread talking about the creation of a GraphsIO.jl and its integration with Graphs.jl and LightGraphs.jl (https://github.com/JuliaLang/Graphs.jl/issues/37) Do you have any news about it? How can I read GML files to work with LightGraphs.jl?

Thanks for any help!

Charles

--
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles

Seth

unread,
Jul 11, 2015, 10:04:08 AM7/11/15
to julia...@googlegroups.com
Hi Charles,

You're correct; for persistence, LightGraphs currently supports an internal graph representation and GraphML. If you can convert to GraphML you're in luck; otherwise, if you open up an issue someone might be able to code something up.

The quickest thing, perhaps, would be to import the gml into NetworkX (http://networkx.github.io) and then write it out as GraphML, which you should then be able to use in LightGraphs.

Seth.

andrew cooke

unread,
Jul 16, 2015, 6:11:41 PM7/16/15
to julia...@googlegroups.com

hi, seth contacted me to see whether my ParserCombinator library could do this, and i've just finished adding support for GML.  you can see it at https://github.com/andrewcooke/ParserCombinator.jl#parsers

that is currently only available via git (not yet in a published release).  i've also emailed seth.  if either of you could have a look and tell me whether it's adequate or not, and / or report any bugs then i can look at releasing a version.

cheers,
andrew

Seth

unread,
Jul 17, 2015, 2:45:10 AM7/17/15
to julia...@googlegroups.com
Hi Charles,

I've implemented Andrew's excellent GML parser in LightGraphs (in the "gml" branch for now until a few things can be clarified and docs can be written). To use it, checkout the gml branch and then use g = readgml("/path/to/file.gml").

Note that there are a few issues with the GML parser (see the ones I opened at https://github.com/andrewcooke/ParserCombinator.jl/issues) but it seems to work for smaller gml files at this point.

Note also that readgml() is not type-stable, as it will create either a Graph or DiGraph depending on what it finds in the file. Not sure this is a huge problem.

Charles Novaes de Santana

unread,
Jul 17, 2015, 6:51:20 PM7/17/15
to julia...@googlegroups.com
Hi both,

Thank you very much for doing it!! I will take a look at the parser along the weekend and I hope it can be useful for us. Thank you for being so proactive and helpful!!

Best,

Charles

andrew cooke

unread,
Jul 18, 2015, 12:29:07 AM7/18/15
to julia...@googlegroups.com

the very latest from git has fixes for the issues Seth raised, i hope / believe.  later this weekend i'll probably make a new release, but right now you need to do

Pkg.clone("https://github.com/andrewcooke/ParserCombinator.jl.git")

cheers, andrew

Seth

unread,
Jul 28, 2015, 2:22:04 PM7/28/15
to julia-users, and...@acooke.org
Thanks to Andrew's diligent efforts to track down and fix a couple of unrelated issues in Base, I'm pleased to announce that LightGraphs master now supports GML via Andrew's ParserCombinator package. 

You'll have much better performance on a recent (0.4.0-dev+6325 or later) build, but graphs load in both 0.3 and 0.4.
Reply all
Reply to author
Forward
0 new messages