Skip to content

Instantly share code, notes, and snippets.

@bmtgoncalves
Created October 4, 2016 08:08
Show Gist options
  • Save bmtgoncalves/ae54cd70f9fd20d0bf013f6b384d4cfc to your computer and use it in GitHub Desktop.
Save bmtgoncalves/ae54cd70f9fd20d0bf013f6b384d4cfc to your computer and use it in GitHub Desktop.
def ErdosRenyi(N, m=N):
net = np.zeros(2*m, dtype='int')
for i in xrange(m):
while True:
node1, node2 = np.random.randint(0, N, 2)
# No self loops allowed
if node1 != node2:
break
net[2*i] = node1
net[2*i+1] = node2
return net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment