dgl.DGLGraph.etypesΒΆ
-
property
DGLGraph.
etypes
ΒΆ Return all the edge type names in the graph.
Notes
DGL internally assigns an integer ID for each edge type. The returned edge type names are sorted according to their IDs.
The complete format to specify an relation is a string triplet
(str, str, str)
for source node type, edge type and destination node type. DGL calls this format canonical edge type. An edge type can appear in multiple canonical edge types. For example,'interacts'
can appear in two canonical edge types('drug', 'interacts', 'drug')
and('protein', 'interacts', 'protein')
.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.etypes ['follows', 'follows', 'plays']