常见网络拓扑模型的生成
import networkx as nx
import matplotlib.pyplot as plt
#常见网络模型的生成
#规则网络
RG = nx.random_graphs.random_regular_graph(4, 20)
nx.draw(RG, with_labels = False, node_size = 200,pos=nx.circular_layout(RG))
plt.show()
#ER随机网络
ER = nx.random_graphs.erdos_renyi_graph(20, 0.2)
nx.draw(ER, with_labels = False, node_size = 200,pos=nx.circular_layout(ER))
plt.show()
#小世界网络
WS = nx.random_graphs.watts_strogatz_graph(20, 4, 0.3)
nx.draw(WS, with_labels = False, node_size = 200,pos=nx.circular_layout(WS))
plt.show()
#无标度网络
BA = nx.random_graphs.barabasi_albert_graph(20, 1)
nx.draw(BA, with_labels = False, node_size = 200)
plt.show()