Strange bahaviour of dgl.batch() on heterographs

Hi!

I’m trying to make a stacked graph out of heterographs in DGL 0.7.2, and it seems that dgl.batch() can either work or fail depending on the order in which it encounteres some types of edges/relations in the graphs being stacked.
Here is an example:

    g1 = dgl.heterograph({
        ('a','edge', 'b'): ([0,1], [1,0] ),
        ('c','EDGE', 'd'): ([0,1], [1,0] )
    })

    g2 = dgl.heterograph({
        ('c','EDGE', 'd'): ([0,1], [1,0] )
    })

    dgl.batch([g2,g1]) # works
    print('.')
    dgl.batch([g1,g2]) # fails

Is that an expected behaviour?

Sorry for the problem. Basically we use the first graph in the graph list as the schema.

It’s kind of by design. You can add an empty edge type like ('a','edge', 'b'): (,) to make all graphs having the same schema

Thanks for the clarification. Still, could you please suggest another way for adding an empty edge (ideally, allowing for having an associated edge data record, because a call to multi_update_all will follow)? Here is what I see now

In [5]: g2 = dgl.heterograph({
   ...:     ('a','edge', 'b'): (,) ,
   ...:     ('c','EDGE', 'd'): ([0,1], [1,0] )
   ...: })
  File "<ipython-input-5-943417f75650>", line 2
    ('a','edge', 'b'): (,) ,
                        ^
SyntaxError: invalid syntax

My bad. Please try ('a','edge', 'b'): ([], [])

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