Last active
December 20, 2019 18:09
-
-
Save juliensimon/5bb079d9eea91e0f79ddab3729a536e6 to your computer and use it in GitHub Desktop.
DGL part 1
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 | |
import numpy as np | |
import pickle | |
node_count = 34 | |
epochs = 30 | |
# Load edges | |
with open('edge_list.pickle', 'rb') as f: | |
edge_list = pickle.load(f) | |
# Build graph | |
G = dgl.DGLGraph() | |
G.add_nodes(node_count) | |
src, dst = tuple(zip(*edges)) | |
G.add_edges(src, dst) | |
# Edges are directional in DGL; make them bidirectional | |
G.add_edges(dst, src) | |
print('We have %d nodes.' % G.number_of_nodes()) | |
print('We have %d edges.' % G.number_of_edges()) | |
We have 34 nodes. | |
We have 156 edges. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment