Loading a Neo4j subgraph into Networkx

末鹿安然 提交于 2019-12-03 07:01:25

问题


I have been dealing with Neo4j through python's Bulbflow and now need a way to save/export subgraphs. I have seen Java and even Ruby approaches for doing this, however a simple Python approach seems to be hiding from me..

So far, I have found two potential paths:

  1. Accessing Geoff through py2neo, but there is surprisingly little documentation for extracting a subgraph from a big local neo4j database or from a neo4jserver.

  2. Using Networkx: I found networkx can load graphs from many different formats (I am unsure which format neo4j stores their dbs), however I haven't found a way to extract a only a subgraph into Networkx. I assume this should be done from a gremlin query, but I'm not sure how to go about this.

I have a preference for the Networkx path, as it also comes with network analysis algorithms I wish to apply to subgraphs. I feel it would also avoid potential clashes between Bulbflow and py2neo, although I'm not sure whether such a clash would exist.

Any advice would be much appreciated!

Thanks in advance


回答1:


I didn't know the answer until you asked, but it seems like you can just export in gml, which networkx can read. Here are a few answers that might be useful:

Neo4j export Tree

Convert Neo4j DB to XML?

https://github.com/tinkerpop/gremlin/wiki/Gremlin-Methods

Hope that helps.




回答2:


I know it's an old question, but if you stumbled upon it like me - know that networkx has a subgraph command, so you can load the whole graph from Neo4j and use that.



来源:https://stackoverflow.com/questions/15459615/loading-a-neo4j-subgraph-into-networkx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!