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

Sparse graph and full graph #9

Closed
immortal13 opened this issue Apr 17, 2021 · 2 comments
Closed

Sparse graph and full graph #9

immortal13 opened this issue Apr 17, 2021 · 2 comments

Comments

@immortal13
Copy link

Thanks for the innovative work! Could you please tell me how can we get a full graph?Did full graph mean the full attention map?Did sparse graph mean that we only retain the immediate neighbor nodes‘ value of full graph?

@vijaydwivedi75
Copy link
Member

Hi @immortal13,
In sparse graph experiments, the original graph is used which means a node attends to its local neighbors only.
In full graph experiments, a new graph is created with each node connected to every other nodes which means a node attends to all other nodes in a graph.

The code that makes full graph, for example on SBM datasets, is:

def make_full_graph(g):
"""
Converting the given graph to fully connected
"""
full_g = dgl.from_networkx(nx.complete_graph(g.number_of_nodes()))
full_g.ndata['feat'] = g.ndata['feat']
full_g.edata['feat'] = torch.zeros(full_g.number_of_edges())
try:
full_g.ndata['lap_pos_enc'] = g.ndata['lap_pos_enc']
except:
pass
try:
full_g.ndata['wl_pos_enc'] = g.ndata['wl_pos_enc']
except:
pass
return full_g

@immortal13
Copy link
Author

Thanks for you prompt reply!

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

2 participants