Created
October 4, 2016 08:07
-
-
Save bmtgoncalves/0919d8c1b57ee0f477d6b906f3b15212 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def BarabasiAlbert(N): | |
net = np.zeros(2*N, dtype='int') | |
# Edges represented by sequence of nodes | |
net[:6] = [0, 1, 1, 2, 2, 3] | |
# Generate the network | |
for i in xrange(3, N): | |
pos = np.random.randint(0, i) | |
net[2*i] = i | |
net[2*i+1] = net[pos] | |
return net |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't Line 11 be
?
Otherwise, you are limiting the range of
2*i+1
(edge) values to only the first half of the list.