dgl.DGLGraph.canonical_etypesΒΆ
-
property
DGLGraph.
canonical_etypes
ΒΆ Return all the canonical edge types in the graph.
A canonical edge type is a string triplet
(str, str, str)
for source node type, edge type and destination node type.Notes
DGL internally assigns an integer ID for each edge type. The returned edge type names are sorted according to their IDs.
See also
Examples
The following example uses PyTorch backend.
>>> import dgl >>> import torch
>>> g = dgl.heterograph({ ... ('user', 'follows', 'user'): (torch.tensor([0, 1]), torch.tensor([1, 2])), ... ('user', 'follows', 'game'): (torch.tensor([0, 1, 2]), torch.tensor([1, 2, 3])), ... ('user', 'plays', 'game'): (torch.tensor([1, 3]), torch.tensor([2, 3])) ... }) >>> g.canonical_etypes [('user', 'follows', 'user'), ('user', 'follows', 'game'), ('user', 'plays', 'game')]