Solved – Estimate power law exponent for node degree distribution in scale free networks

power lawpython

I am trying to use the powerlaw python package to estimate the power law exponent of the degree distribution in a graph. As a reference I am using networkx to generate a scale free network graph which should have an exponent close to 3. This is my code:

import powerlaw
import networkx as nx
g = nx.barabasi_albert_graph(1000, 5)
degrees = {}
for node in g.nodes_iter():
    key = len(g.neighbors(node))
    degrees[key] = degrees.get(key, 0) + 1

max_degree = max(degrees.keys(), key=int)
num_nodes = []
for i in range(1, max_degree + 1):
    num_nodes.append(degrees.get(i, 0))

fit = powerlaw.Fit(nodes)
print(fit.power_law.alpha)

The code above creates a scale free network with minimum node degree of five. I would expect the powerlaw package to find xmin to be >5 and to correctly estimate alpha. but it returns something around 1.8 instead of 3.0 for alpha and places xmin at 1 or 2. Is my data format wrong, or do I have to specify some other parameters?

Best Answer

Not sure if it is still of interest, however, you are estimating the exponent of the CDF of the degree which is equal to $-\alpha+1$, where $\alpha$ is 3 for the Barabasi Albert model, therefore, you should add +1 to your estimation which indeed gains something close to 3 as expected.

Related Question