如何从幂律分布中随机分配权重给节点数非常多的网络。在
我写的
import networkx as nx
import numpy as np
from networkx.utils import powerlaw_sequence
z=nx.utils.create_degree_sequence(200,nx.utils.powerlaw_sequence,exponent=1.9)
nx.is_valid_degree_sequence(z)
G=nx.configuration_model(z)
Gcc=nx.connected_component_subgraphs(G)[0]
edgelist=[nx.utils.powerlaw_sequence(nx.number_of_edges(Gcc),exponent=2.0)]
我知道我通过元组字典(node1,node2,weight)为边指定权重,使用:
^{pr2}$但是,当我只想得到一个加权网络,其中的权重是幂律分布的,有没有其他更短的方法?在
我试着得到了以下结果。。我希望有帮助。此外,我正在寻找更好的方法,因为这不能确保我得到一个连接的网络。另外,我还要检查它的属性。在
例如,可以使用G[u][v][weight']直接指定权重
我用的是Python的随机变量()选择重量,但你可以,当然,把你想放在那里的任何东西。在
相关问题 更多 >
编程相关推荐