How To Import A Networkx Graph To Neo4j?
I have a graph created with networkX and I am using neonx to import it to neo4j on localhost. I have a networkX type graph called G. Below is the code: data1 = json_graph.node_link
Solution 1:
I believe the issue is that your neo4j instance requires authentication, but neonx doesn't appear to support it.
to disable authentication set: dbms.security.auth_enabled=false
(see: https://neo4j.com/docs/operations-manual/current/security/authentication-authorization/enable/)
to verify this is the issue point your browser to: http://localhost:7474/db/data/ and see if you are prompted for a user and password
Solution 2:
Best way is to dump networkx graph and import it into Neo4j.
Advantages:
- You don't need to have a working connection with Neo4j server
- Dump once and load it anywhere anytime. You have saved version/backup.
Dump networkx graph:
nx.write_graphml(g, 'path/to/file.graphml')
Load into Neo4j:
- Install apoc plugin for Neo4j from here
- Enable
apoc.import.file.enabled=true
in conf/neo4j.conf - Place your graph dump
file.graphml
inimport/
folder
cypher-shell -a bolt://localhost:7687 "call apoc.import.graphml('file.graphml', {})"
Or in browser:
call apoc.import.graphml('file.graphml', {})
For more details:
Post a Comment for "How To Import A Networkx Graph To Neo4j?"