Dgl.to_bidirected() throws 'Unsupported graph data type:', <class 'dgl.heterograph.DGLHeteroGraph'>

Hi, I am a complete newby to dgl library. I started following the tutorials did the one below finally.

https://docs.dgl.ai/guide/graph-graphs-nodes-edges.html

But bg = dgl.to_bidirected(g) line throws the following error.

DGLError                                  Traceback (most recent call last)
<ipython-input-29-01a6bfd86165> in <module>()
----> 1 g = dgl.graph(g)
      2 
      3 bg = dgl.to_bidirected(g)
      4 
      5 bg.edges()

/home/halil/anaconda3/envs/dgl/lib/python3.5/site-packages/dgl/convert.py in graph(data, ntype, etype, num_nodes, card, validate, restrict_format, **kwargs)
    147             data, ntype, etype, restrict_format=restrict_format, **kwargs)
    148     else:
--> 149         raise DGLError('Unsupported graph data type:', type(data))
    150 
    151 def bipartite(data, utype='_U', etype='_E', vtype='_V', num_nodes=None, card=None,

DGLError: ('Unsupported graph data type:', <class 'dgl.heterograph.DGLHeteroGraph'>)

I checked and dgl.graph() function really returns an hetero graph and as far as I understand it should return a regular graph. What is causing this error and what is the solution.

Edit: I just realized that my to_bidirected() method’s implementation is different than the one in the docs. Is there an inconsistency or am I not getting the latest version somehow?

  1. The error is from dgl.graph. The argument g you passed to dgl.graph is already a DGLGraph so you don’t need to call dgl.graph.
  2. As of 0.5, DGL has merged DGLGraph and DGLHeteroGraph into a single data structure.
  3. What’s the version you are using? What are the implementation differences for to_bidirected?

I actually found the problem. The installation page for version 0.5.x is wrong. It is indicated that the environment should be created with python 3.5 but it actually requires python 3.8. This caused the 0.4.x version of the dgl to be installed. I recreated the environment with python 3.8 and it works now.

Sorry for that. DGL 0.5.x should work with Python 3.6+. Which installation page are you referring to?

https://docs.dgl.ai/install/index.html

This link. I couldn’t really remember the exact error message but it requires a version newer than 3.5.

Thank you for the pointer. We will fix that.