문제

How can I randomly assign weights from a power-law distribution to a network with very large number of nodes.

I wrote

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)]

I know I assign weights to edges by a dictionary of tuples (node1,node2,weight) using:

nx.from_edgelist(edgelist,create_using=None)

But when I am just interested in getting a weighted network where weights are power-law distributed, is there another shorter way?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top