networkx 读写文件学习

读取.adjlist文件

test.adjlist

a b c #a-b a-c
d e #d-e

读取

import networkx as nx
import matplotlib.pyplot as plt

G = nx.read_adjlist(‘test.adjlist’)
nx.draw(G)
plt.show()
结果

mulitiline-adjlist

a 3 #a-b a-c a-f
b
c
f
d 1 #d-e
e
g1=nx.read_multiline_adjlist(‘test.adjlist’)
nx.draw(g1)
plt.show()
resault

edge list

a b 3 #node-node weight
a c 4
c d 5
e f 6
g = nx.read_weighted_edgelist(‘test.edgelist’)#edges with weighted
resault

你可能感兴趣的:(复杂网络,networkx)