3

I want to store my embedded Neo4j Graph db to GraphML to draw it with a tool like yEd.

I'm managing the graph db with python27.

Does any body knows a way to do that?

Marc Pou
  • 649
  • 2
  • 7
  • 20

2 Answers2

1

If you can afford to do it outside of the process -- which means you'll need to shut down your existing process working on the embedded database and restart when finished with the export-- you can use Gremlin to do it. Here's the commands you'll need:

g = new Neo4jGraph("/YOUR/GRAPH/DIRECTORY")
writer = new GraphMLWriter(g)
out = new FileOutputStream("/YOUR/GRAPHML/file.graphml")
writer.outputGraph(out)
writer.setNormalize(true)
out.close()

This will create a nice pretty graphml file that is suitable for reading into a tool like Gephi or Cytoscape.

If you need to export the graph in-process you'll need to use something like jython to run your python scripts and then use the above commands by importing the objects from com.tinkerpop.blueprints.

Pridkett
  • 4,883
  • 4
  • 30
  • 47
  • that seems really nice, but unfortunately when I try to do this, neo4j is initialized, but fails to start :S Does gremlin work well with the python-embedded 1.6 neo4j edition? – chiffa Apr 03 '13 at 19:57
0

If neo4j.py does not support exporting to GraphML format, or for any reason you cannot do that with Neo4j + Java, you'll have to write a custom exporter.

With some simple hacks you can accomplish that with NetworkX, which supports importing from/exporting to GraphML. Just figure a way to import your Neo4j graph into NetworkX and then export it directly to GraphML.

hymloth
  • 6,869
  • 5
  • 36
  • 47