#环形图显示
import networkx as nx
G = nx.Graph()
#构建df_table
edge_lis=[]
for i in range(m.shape[0]):
for j in range(m.shape[0]):
if m[i][j]>0.5:
edge_lis.append([i,j])
rraw_edges= edge_lis
source_list=[] #边的起始节点
target_list=[] #边的终点
for m in range(0,len(rraw_edges)):
# for m in range(0,1):
subject_edge=rraw_edges[m]
source_list.append(subject_edge[0])
target_list.append(subject_edge[1])
# source_list=list(itertools.chain.from_iterable(source_list))
# target_list=list(itertools.chain.from_iterable(target_list))
# print(len(source_list))
# print('
')
# print(len(target_list))
# print('
')
df_table = pd.DataFrame(
{"source": source_list, "target": target_list}
)
df_table['C'] = [ 1 for i in range(len(df_table['source']))]
print(df_table)
G = nx.from_pandas_edgelist(df_table, source = 'source', target = 'target', edge_attr = 'C', create_using = nx.DiGraph())
nx.draw(G,
pos = nx.circular_layout(G),
node_color = 'b',
edge_color = 'green',
with_labels = True,
font_size =10,
node_size =20)
plt.show()