Skip to content

Instantly share code, notes, and snippets.

@guenter-r
Last active May 1, 2020 15:47
Show Gist options
  • Save guenter-r/d96cd2a91f9d5e5d400142d2f859a1c6 to your computer and use it in GitHub Desktop.
Save guenter-r/d96cd2a91f9d5e5d400142d2f859a1c6 to your computer and use it in GitHub Desktop.
x,y = [],[]
for element in connections_list:
xi = element[0]
yi = element[1]
x.append(xi)
x.append(yi) # make symmetric
y.append(yi)
y.append(xi) # make symmetric
# create 'one' entries for the coo matrix
vals = np.ones(len(x))
# numpy(scipy.sparse)
from scipy.sparse import coo_matrix
m = coo_matrix((vals,(x,y)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment