Created
January 19, 2020 18:14
-
-
Save llSourcell/f9832052bf908d072bf6b978c4620176 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import dgl | |
| import torch as th | |
| g = dgl.DGLGraph() | |
| g.add_nodes(10) | |
| # A couple edges one-by-one | |
| for i in range(1, 4): | |
| g.add_edge(i, 0) | |
| # A few more with a paired list | |
| src = list(range(5, 8)); dst = [0]*3 | |
| g.add_edges(src, dst) | |
| # finish with a pair of tensors | |
| src = th.tensor([8, 9]); dst = th.tensor([0, 0]) | |
| g.add_edges(src, dst) | |
| # Edge broadcasting will do star graph in one go! | |
| g.clear(); g.add_nodes(10) | |
| src = th.tensor(list(range(1, 10))); | |
| g.add_edges(src, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment