The following snippet comes from the tutorial https://cnvrg.io/graph-neural-networks/. How can I visualize a graph from the dataset
? Using something like matplotlib
if possible.
import dgl
import torch
import torch.nn as nn
import torch.nn.functional as F
import dgl.data
dataset = dgl.data.CoraGraphDataset()
g = dataset[0]
It is a huge graph so you might have to play with the sizes (node, width, figure, etc.). Here are some useful links:
https://networkx.org/documentation/stable/tutorial.html
https://docs.dgl.ai/en/0.5.x/generated/dgl.to_networkx.html#dgl.to_networkx
https://docs.dgl.ai/en/0.5.x/api/python/dgl.data.html