'_ID' in heterogeneous graphs

Hi, I was trying to access the node IDs of my heterogeneous graph. The problem is that if I do: hg.nodes[node_type].data, it is empty.

It only shows the node ids if I add some sort of data to the node, or if I remove some node.

It seems to me that this is a feature, not a bug, but does it need to be like that? It makes it a little confusing.

Thanks!!

To access the node IDs for a particular node type, you can use hg.nodes(node_type). hg.nodes[node_type].data[dgl.NID] typically stores old node IDs after you apply some graph transformation, e.g. adding/removing nodes.

1 Like