Skip to content

Instantly share code, notes, and snippets.

@juliensimon
Last active December 20, 2019 18:09
Show Gist options
  • Save juliensimon/5bb079d9eea91e0f79ddab3729a536e6 to your computer and use it in GitHub Desktop.
Save juliensimon/5bb079d9eea91e0f79ddab3729a536e6 to your computer and use it in GitHub Desktop.
DGL part 1
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