import igraph
from igraph import Graph as ig
import csv
edges = []
firstLine = True
# 读取文件
with open('storm_copy.csv', 'r') as df:
for row in csv.reader(df.read().splitlines()):
if firstLine == True:
firstLine = False
continue
u, v, weight = [i for i in row]
# 添加网络边和权重
edges.append((u, v, int(weight)))
print(edges)
# 使用FR算法绘图
g = ig.TupleList(edges, directed=True, vertex_name_attr='name', edge_attrs=None, weights=True)
layout = g.layout('fr')
igraph.plot(g, layout=layout)