Python networkx and persistence (perhaps in neo4j)

前端 未结 1 2081
再見小時候
再見小時候 2021-02-10 16:24

I have an application that creates many thousands of graphs in memory per second. I wish to find a way to persist these for subsequent querying. They aren\'t particularly large

1条回答
  •  别那么骄傲
    2021-02-10 16:41

    Networkx has several serialization method.

    In your case, I would choose graphml serialization :

    http://networkx.github.io/documentation/latest/reference/readwrite.graphml.html

    It's quite simple to use :

    import networkx as nx
    nx.write_graphml('/path/to/file')
    

    To load it in Neo4j, provided you have Neo4j<2.0, you could use Tinkerpop Gremlin to load your graphml dump in Neo4J

    g.loadGraphML('/path/to/file')
    

    The Tinkerpop are quite useful - not only for serialization/deserialization.

    It will allow you to use different graph database with a commion "dialect" (provided they have a "Blueprint" driver which most of them do)

    0 讨论(0)
提交回复
热议问题