Graph Node Ordering


in the batched graph example,, how do you account for the various ways graph nodes could be ordered? For example Node0 corresponds to different points across the various graph classes. Lets say I had three nodes A,B,C depending on the order I add them using “add_edge” the assignment by DGL of consecutive integers will change? How does DGL various differences in graph node ordering?



The order of the nodes and edges is determined during graph construction. In your example, G.add_nodes(3) will be called first to add three nodes. However, at this moment, which id, for example, does node A correspond to is unknown. Let’s say there is an edge A->B, which is added by G.add_edge(1, 2). This means that you want A to be node 1 and B be node 2, so node A’s feature will be the second row in the tensor returned by G.ndata.

dgl.batch will keep the node edge order of each given graphs. For example, node 2 in graph 0 will be node 2, while node 2 in graph 1 will be node |graph0_size| + 2.



It seems that the link has triggered the automatic spam detection by the system and I accidentally approved the spam flagging request. I haven’t figure out how to undo that and I’m sorry for it.