【复杂网络】【基础图形】【打开文件】【有向图】

import networkx as np
import os
import matplotlib.pyplot as plt
path ='C:\\Users\\师亚勇\\Desktop'
os.chdir(path)
filename = 'test1.txt'
G = np.DiGraph()
with open(filename) as file:
    for line in file:
        head,tool = (str(x) for x in line.split())
        G.add_edge(head,tool)
np.draw(G,with_labels=True)
plt.show()

猜你喜欢

转载自blog.csdn.net/qq_30317875/article/details/82884698