Node/edge text labels

I have some text labels that I would like to keep (apart from tensor features) so that I could calculate some basic similarity/validation checks on. Is there a way to create a name for each node/edge?

Hi, this is a part of our heterogeneous graph plan (WIP, not done yet), you may find the python interface here:

For now, I think a workaround is to record the edge ids for each type of node/edge, and use our subgraph and edge_subgraph to get the subgraph correspond to some type of nodes/edges, for example:

import dgl
import torch as th

g = dgl.DGLGraph()
type_self_ids = []
type_forward_ids = []
type_backward_ids = []

for i in range(10):
    for j in range(10):
        eid = g.number_of_edges()
        if i == j:
        elif i < j:
        else: # i > j
        g.add_edge(i, j)

g_self = g.edge_subgraph(type_self_ids)
g_forward = g.edge_subgraph(type_forward_ids)
g_backward = g.edge_subgraph(type_backward_ids)

and remember to call copy_from_parent and copy_to_parent when necessary.

I’ve got this error when I tried that code:

TypeError Traceback (most recent call last)
----> 1 g_self = g.edge_subgraph(type_self_ids)

~/anaconda3/envs/Pytorch/lib/python3.6/site-packages/dgl/ in edge_subgraph(self, edges)
2831 def prop_edges(self,
-> 2832 edges_generator,
2833 message_func=“default”,
2834 reduce_func=“default”,

TypeError: init() takes from 3 to 4 positional arguments but 5 were given

Could you please tell me the version of DGL you are using? In DGL 0.3 this shouldn’t happen… edge_subgraph does not call prop_edges.

I updated to 0.3 before running that code

Sorry was a env. issue. Working now