How to import a GraphML to JGraphT

1.6k Views Asked by At

JGraphT has a GraphMLExporter that enables to export a graph to a GraphML file. There doesn't seem to be a GraphMLImporter.

Is there a simple way to generate a graph in JGraphT from a .grphml file?

2

There are 2 best solutions below

0
On

Check out jgrapht-sna project. Beside implementations of SNA algorithms, it has GraphMLImporter class.

1
On

Starting from version 1.0.0 JGraphT has both an importer and an exporter for GraphML. The classes are named GraphMLImporter and GraphMLExporter inside the jgrapht-ext package.

Starting from version 1.1 all importers and exporters are located in the jgrapht-io package. Additionally, a simpler version called SimpleGraphMLImporter which provides less functionality in favor of greater speed is also available in latest versions.

A demo is also available, see GraphMLDemo.