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()
#按度调整节点大小
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()