Whta is the order of c_etype in hetero graph?

In hetero graph, if the value of cross_reducer param of multi_update_all function is set to stack, the results of multiple c_etypes will be stacked. I want to know what is the order of stacking? It seems that the staking order is not the same as the c_etype statement order.

Can you provide a code snippet for reproducing the issue?

graph_data = {
   ('n', 'original', 'n'): (th.tensor([0, 1]), th.tensor([1, 2])),
   ('n', 'inverse', 'n'): (th.tensor([1]), th.tensor([2])),
   ('n', 'selfloop', 'n'): (th.tensor([0]), th.tensor([1]))
}
g = dgl.heterograph(graph_data)

for c_etype in g.canonical_etypes:
    print(c_etype)

# Output :
# ('n', 'inverse', 'n')
# ('n', 'original', 'n')
# ('n', 'selfloop', 'n')

It seems that the inner storage order of canonical type is alphabetical? and the statement order does not matter.

Yes, the construction involves sorting the canonical edge types here. Do you think it will be better to mention that in the documentation of heterograph?

Yes! I think the mention is necessary.

This has been addressed in PR 2376.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.