如何对一个复杂网络的图进行分析? 计算复杂网络相关的所有参数 批处理

import networkx as nx
#计算网络的度分布
d = nx.degree(G)
print("网络的度分布为:{}".format(d))
#整个网络的平均距离
nspl = nx.average_shortest_path_length(G)
print("网络的平均距离:{}".format(nspl))
#网络的直径
diameter = nx.diameter(G)
print("网络的直径为:{}".format(diameter))

#整个网络的连通性
nxic = nx.is_connected(G)
print("整个网络的连通性:{}".format(nxic))

#整个网络的集聚系数
nxcc = nx.clustering(G)
print("整个网络的集聚系数:{}".format(nxcc))

#整个网络的平均集聚系数
nxacc = nx.average_clustering(G)
print("整个网络的平均集聚系数:{}".format(nxacc))

#整个网络的全局集聚系数
nxtc = nx.transitivity(G)
print("整个网络的全局集聚系数:{}".format(nxtc))

#整个网路的局部效率
nxlec = nx.local_efficiency(G)
print("整个网路的局部效率:{}".format(nxlec))

#整个网络的全局效率
nxgec = nx.global_efficiency(G)
print("整个网络的全局效率:{}".format(nxgec))

#计算整个网络的 Pearson相关系数的度-度相关性
nxpddc = nx.degree_assortativity_coefficient(G)
print("Pearson度-度相关性:{}".format(nxpddc))

#整个网络的核度
nxks = nx.core_number(G)
max_id = max(nxks, key=nxks.get)
print("整个网络的核度为:{},获取核度最大的节点标签为:{}".format(nxks, max_id))

#输出整个网络的网络密度
nxd = nx.density(G)
print("整个网络的网络密度".format(nxd))

#输出整个网络的度中心性
nxdcr = nx.degree_centrality(G)
print("整个网络的度中心性:{}".format(nxdcr))

#整个网络的节点介数(中心性)
nxbcc = nx.betweenness_centrality(G)
print("整个网络的节点介数分别为(中心性):{}".format(nxbcc))

#整个网络的边介数(中心性)
nxecc = nx.edge_betweenness_centrality(G)
print("整个网络的边介数分别为(中心性):{}".format(nxecc))

#整个网络的接近度中心性
nxccc = nx.closeness_centrality(G)
print("整个网络的接近度中心性:{}".format(nxccc))

#整个网络的特征向量中心性
nxevcc = nx.eigenvector_centrality(G)
print("整个网络的特征向量中心性:{}".format(nxevcc))
posted @ 2022-04-28 16:37  bH1pJ  阅读(112)  评论(0编辑  收藏  举报