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

build symmetric adjacency matrix #3

Closed
laoreja opened this issue Feb 25, 2018 · 4 comments
Closed

build symmetric adjacency matrix #3

laoreja opened this issue Feb 25, 2018 · 4 comments

Comments

@laoreja
Copy link

laoreja commented Feb 25, 2018

Hi tkipf, thank you for your amazing work!
in utils.py, starts from Line 36,

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

As far as I understand, these lines are turning a directed adjacency matrix into an undirected adjacency matrix?
Since adj is a 0-1 matrix, then for the positions adj[i,j] where adj.T > adj, we should have adj[i,j] = 0, so the - adj.multiply(adj.T > adj) part is always zero.

Then what's the purpose of having that part, or am I understand it incorrectly?

@tkipf
Copy link
Owner

tkipf commented Feb 26, 2018

Yes, for binary adjacency matrices you are right. In all other cases you need the last term to ensure that only a single edge is kept (the one with largest weight).

@fansariadeh
Copy link

I do not understand why adj matrix should be turned into a symmetric matrix. Could you please clarify it?

@baojianzhou
Copy link

@fansariadeh. Based on my understanding, the original GCN paper considers undirected graphs. In some datasets, the graph may not be undirected ( e.g. store as the directed graph). This line of code can make sure the input graph be undirected.

@fansariadeh
Copy link

@fansariadeh. Based on my understanding, the original GCN paper considers undirected graphs. In some datasets, the graph may not be undirected ( e.g. store as the directed graph). This line of code can make sure the input graph be undirected.

Dear @baojianzhou
That makes sense to me now. I appreciate it.
Cheers,

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

4 participants