csv to sparse matrix in python

后端 未结 3 986
长发绾君心
长发绾君心 2020-12-09 05:53

I have a big csv file which lists connections between nodes in a graph. example:

0001,95784
0001,98743
0002,00082
0002,00091

So this means that

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 06:32

    You might also be interested in Networkx, a pure python network/graphing package.

    From the website:

    NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.

    >>> import networkx as nx
    >>> G=nx.Graph()
    >>> G.add_edge(1,2)
    >>> G.add_node("spam")
    >>> print G.nodes()
    [1, 2, 'spam']
    >>> print G.edges()
    [(1, 2)]
    

提交回复
热议问题