import networkx as nx
import matplotlib.pyplot as plt
from networkx.algorithms.community import k_clique_communities

G = nx.read_gml(‘D:\Download\dolphins\dolphins.gml’)
klist = list(k_clique_communities(G,5))

#plotting
pos = nx.spring_layout(G)
plt.clf()
nx.draw(G,pos = pos, with_labels=False)
nx.draw(G,pos = pos, nodelist = klist[0], node_color = ‘b’)
nx.draw(G,pos = pos, nodelist = klist[1], node_color = ‘y’)
plt.show()
networkx网络关系图

#按度调整节点大小
de = dict(G.degree()) #转换成dict
de2 = [de[v]*20 for v in sorted(de.keys(), reverse=False)]
nx.draw_networkx(G, pos, node_size=de2, with_labels = False, node_color=’#A52A2A’, linewidths=None, width=1.0, edge_color =’#858585’)
nx.draw_networkx_labels(G,pos,font_size=6,font_color=‘white’)
plt.show()
networkx网络关系图

相关文章:

  • 2021-07-15
  • 2021-12-29
  • 2021-04-03
  • 2021-03-30
  • 2022-12-23
  • 2021-08-04
  • 2021-12-18
猜你喜欢
  • 2022-12-23
  • 2021-12-02
  • 2021-07-09
  • 2022-12-23
  • 2021-09-18
  • 2021-12-19
  • 2021-07-29
相关资源
相似解决方案