Is the message order passing to the same node random?

Hi~ I am a graduate student who is new to DGL, and I found it’s an amazing project for my research!
However, I wonder what the order of message passing like in a DGL graph. For example, nodes a1, a2, a3 are source nodes of node b in graph g. We add edges to graph in the order of [(a1, b), (a2, b), (a3, b)]. When we are passing message ‘h’ in g, b will receive mesage from a1, a2 and a3 in b’s mailbox[‘h’]. Will these messages sorted in mailbox[‘h’] follows the edges order we added to the graph, or it’s totally ramdon?
I can’t find explainations in DGL’s documentation but it’s very important for me since I need to process mailbox[‘h’] one by one according to a fix order. I have done some simple experiments in my own computer (without a nividia gpu and my pytorch version is 1.3.1_cpu) and I found the order of mailbox[‘h’] is the same like the edges order added to the graph. But I am not sure if I can get the same effect in a gpu server or other versions of DGL.

Hi,

You can try sending node id and edge id as message also to the reduce function. And sort/reorder it as you wanted. The order should be fixed.

g.ndata['nid'] = th.arange(g.number_of_nodes())
g.edata['eid'] = th.arange(g.number_of_edges())
def msg_func(edges):
    {'nid': edges.src['nid'], 'eid': edges.dst['eid']}

...
1 Like

Thanks a lot and I will have a try~