Hej everyone!
I am right now working on a preferential attachment model in MATLAB and I have some troubles to understand the following:
Assuming I have 4 nodes in the beginning, connected like this:
time = 0
1 <-----> 2
3 <-----> 4
In the next time step I add a single node and 4 connections, then another single node and 4 connections.
The formula for my linking probability to node i is:
P_link(i) = degree(i) / sum of all degrees at time-1
This results in the probabilities of 1/4 for each of the nodes i = 1 to 4 in the first step and then, having node 5 connected to 1, 2, 3 and 4, I will have a "sum of degrees" = 12, when adding node 6 in the following time step.
That then means the linking probabilities are: 1/6, 1/6, 1/6, 1/6 and 1/3.
How can I set this up in MATLAB? My problem is, I normally write these things on paper to get a better understanding, and if there is a randomisation I just "simulate" it on paper to compare it with a simple MATLAB program.
What I would now do is: I take a random number, let's say 0.3045.
To add this to a node it would have to be in the range of
node1: [0.0000, 1/6],
node2: [1/6, 1/3],
node3: [1/3, 1/2],
node4: [1/2, 2/3],
node5: [2/3, 1.0000].
---> CONNECT to node2
So for the first step I have an idea of how to do it, but now I have two different problems, which are, I think, closely related:
- How am I able to implement this in MATLAB, is the range approach a good idea?
- How do the probablities change after adding the first connection for the rest, assuming it can only be connected once to each node? (this might be a more mathematical question I have to admit ...)
I am very sorry, this question looks so messy, but I hope someone can give me some hints about the implementation of this.
Thanks in advance!