Read/Write NetworkX Graph Object

后端 未结 3 1125
北荒
北荒 2021-02-01 09:46

I am trying to deal with a super-massive NetworkX Graph object with hundreds of millions of nodes. I\'d like to be able to write it to file as to not consume all my computer mem

3条回答
  •  别跟我提以往
    2021-02-01 10:25

    I forgot what problem I came to StackOverflow to solve originally, but I stumbled on this question and (nearly a decade too late!) can recommend Grand, a networkx-like library we wrote to solve exactly this problem:

    Before

    import networkx as nx
    
    g = nx.DiGraph()
    g.add_edge("A", "B")
    print(len(g.edges()))
    

    After

    import grand
    from grand.backends import SQLBackend # or choose another!
    
    g = grand.Graph(backend=SQLBackend())
    g.nx.add_edge("A", "B")
    print(len(g.nx.edges()))
    

    The API is the same as NetworkX, but the data live in SQL, DynamoDB, etc.

提交回复
热议问题