Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still curious about the code of building symmetric adjacency matrix #54

Closed
BilyZ98 opened this issue Dec 12, 2019 · 3 comments
Closed

Comments

@BilyZ98
Copy link

BilyZ98 commented Dec 12, 2019

` adj = sp.coo_matrix((np.ones(edges.shape[0]), (edges[:, 0], edges[:, 1])),
shape=(labels.shape[0], labels.shape[0]),
dtype=np.float32)

# build symmetric adjacency matrix
adj = adj + adj.T.multiply(adj.T > adj) - adj.multiply(adj.T > adj)`

I don't understand how the last line code produces the symmetric matrix.
And I think it is intuitive to build the symmetric like this
adj = adj + adj.T

Can anyone help to answer my questions? thanks a lot

@BilyZ98
Copy link
Author

BilyZ98 commented Dec 12, 2019

ok now I understand. the multiply is a point-wise multiplication, not a matrix product.

@BilyZ98 BilyZ98 closed this as completed Dec 12, 2019
@Spico197
Copy link

ok now I understand. the multiply is a point-wise multiplication, not a matrix product.

Hi, mate. I have the same problem here. I'm curious why we have to subtract adj.multiply(adj.T > adj)? Entries in adj.multiply(adj.T > adj) should be all zeros.

@Pager07
Copy link

Pager07 commented Dec 8, 2020

ok now I understand. the multiply is a point-wise multiplication, not a matrix product.

Hi, mate. I have the same problem here. I'm curious why we have to subtract adj.multiply(adj.T > adj)? Entries in adj.multiply(adj.T > adj) should be all zeros.

#3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants