Barabasi-Albert Algorithm for Constructing Scale Free Graphs

896 Views Asked by At

I'm trying to construct a scale-free network using the Barabasi-Albert algorithm in C++. I've seen some other questions on here concerning the algorithm (and I'm using an algorithm similar to this one), but I wanted to make sure that I wasn't misunderstanding something about the mathematics. The algorithm I am using has the following steps:

  1. Create an initial completely connected graph with m0 = 10 nodes.
  2. Create a new node -- call this new node n.
  3. Select a node i in the original connected graph.
  4. Draw a random number r from a uniform distribution on [0,1].
  5. Set p = k_i/k_tot, where k_i is the number of edges connected to node i and k_tot is the sum of k_j for all edges in the original connected graph.
  6. If r
  7. Repeat steps 2-6 until the graph has N = 30,000 nodes.

When I use this algorithm, the resulting degree distribution is exponential and not a power law as it should be. When plotted on a linear-log plot, the degree distribution is a striaght line over several orders of magnitude; plotted on a log-log plot, the degree distribution is very clearly a curve.

What am I doing wrong? Is my algorithm correct, or is there something fundamental I've misunderstand? By the way: the exponential distribution resulting from my present code is actually really pretty, so I wonder if I've instead reproduced some other well known process instead of preferential attachment.