- #1
dholbach
- 7
- 0
I've been working on implementing the Barabasi-Albert model in C++. Barabasi-Albert networks are supposed to be scale-free -- that is, their degree distribution is supposed to be power-law distributed. In order to test whether my program was working correctly, I plotted the degree distribution from a network with a total of N=30,000 nodes. Unfortunately, I seem to have done something very wrong.
The resulting degree distribution from my program had a very nice, very clean exponential distribution and not a power-law distribution. On a linear-log plot, the degree distribution was a straight line for several orders of magnitude. While I'd be happy to share the relevant snippet of code at some point, I wanted to check to see if I've misunderstand BA algorithm at some important point.
1. Create an initial completely connected graph with m0 nodes. I used m0=10 nodes because my understanding is that m0 should be small compared to N. By "completely connected", I mean a graph where every node is connected exactly once to every other node. So, for example, node 0 is connected to 9 other nodes: 1, 2, ..., 9, node 1 is also connected to 9 other nodes: 0, 2, 3, ..., 9, and so on.
2. Create a new node not yet connected to any other 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 [itex] p = k_i/k_{tot} [/itex], where [itex] p = k_i [/itex] is the number of edges connected to node i and [itex] k_{tot} [/itex] is the sum of [itex] k_j [/itex] for all edges in the original connected graph. In other words, [itex] k_{tot} [/itex] is twice the number of edges in the entire graph.
6. If r < p, connect n to i. That is, add i to n's adjacency list and add n to i's adjacency list.
7. Repeat steps 2-6 until the graph has N = 30,000 nodes.
After completing steps 1-7, I have my program output the number of edges connected to every node. Then I use an awk script to construct a histogram. The resulting distribution is exponential and not power-law; what gives? Have I misunderstood the BA algorithm at some point?
The resulting degree distribution from my program had a very nice, very clean exponential distribution and not a power-law distribution. On a linear-log plot, the degree distribution was a straight line for several orders of magnitude. While I'd be happy to share the relevant snippet of code at some point, I wanted to check to see if I've misunderstand BA algorithm at some important point.
1. Create an initial completely connected graph with m0 nodes. I used m0=10 nodes because my understanding is that m0 should be small compared to N. By "completely connected", I mean a graph where every node is connected exactly once to every other node. So, for example, node 0 is connected to 9 other nodes: 1, 2, ..., 9, node 1 is also connected to 9 other nodes: 0, 2, 3, ..., 9, and so on.
2. Create a new node not yet connected to any other 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 [itex] p = k_i/k_{tot} [/itex], where [itex] p = k_i [/itex] is the number of edges connected to node i and [itex] k_{tot} [/itex] is the sum of [itex] k_j [/itex] for all edges in the original connected graph. In other words, [itex] k_{tot} [/itex] is twice the number of edges in the entire graph.
6. If r < p, connect n to i. That is, add i to n's adjacency list and add n to i's adjacency list.
7. Repeat steps 2-6 until the graph has N = 30,000 nodes.
After completing steps 1-7, I have my program output the number of edges connected to every node. Then I use an awk script to construct a histogram. The resulting distribution is exponential and not power-law; what gives? Have I misunderstood the BA algorithm at some point?