class, force_reload=False, verbose=True, transform=None)[source]


BA-2motifs dataset from Parameterized Explainer for Graph Neural Network

This is a synthetic dataset for graph classification. It was generated by performing the following steps in order.

  • Construct 1000 base Barabási–Albert (BA) graphs.

  • Attach house-structured network motifs to half of the base BA graphs.

  • Attach five-node cycle motifs to the rest base BA graphs.

  • Assign each graph to one of two classes according to the type of the attached motif.

  • raw_dir (str, optional) – Raw file directory to download and store the data. Default: ~/.dgl/

  • force_reload (bool, optional) – Whether to reload the dataset. Default: False

  • verbose (bool, optional) – Whether to print progress information. Default: True

  • transform (callable, optional) – A transform that takes in a DGLGraph object and returns a transformed version. The DGLGraph object will be transformed before every access. Default: None


Number of graph classes




>>> from import BA2MotifDataset
>>> dataset = BA2MotifDataset()
>>> dataset.num_classes
>>> # Get the first graph and its label
>>> g, label = dataset[0]
>>> feat = g.ndata['feat']

Gets the data object at index.


The number of examples in the dataset.