AssertionError: to_bidirected only support simple graph?

I have created many graphs using dgl.DGLGraph(), now i want to convert them into undirected graphs before giving them to GIN, but to_bidirected doesn’t work and gives this error :

AssertionError: to_bidirected only support simple graph?

also the reason I’m trying to convert them into undirected graphs is that GIN is performing much much worse than GCN in my dataset for graph classification, and i think since GIN can work with directed graphs, its causing problems in the message passing phase since if there is an edge from a to b, in GCN both of them get updated but i guess in GIN only b gets updated by its neighbor features, but correct me if I’m wrong.

one performance comparison is that with only node degree feature, GCN is 60% in my dataset and GIN is 28%. i used the same code for GIN as provided in the dgl repository. although using my own node features, it does reach above 90% but still less than GCN. tried changing the graph pooling and neighbor pooling to mean/max/sum, didnt affect much. in fact for some reason sum works worse than the mean, but based on their GIN paper it seems like SUM should be much better!

i think since GIN can work with directed graphs, its causing problems in the message passing phase since if there is an edge from a to b, in GCN both of them get updated but i guess in GIN only b gets updated by its neighbor features

Did you use the built-in DGL NN modules for GCN and GIN? If so, did you process the graphs in the same way? If so, they should be dealing with the same graphs, i.e. GraphConv does not add additional reverse edges.

in fact for some reason sum works worse than the mean, but based on their GIN paper it seems like SUM should be much better!

Not necessarily. SUM might yield a better expressive power for graph isomorphism test, but it is not necessarily helpful for the particular task you are interested.

1 Like

For GCN i used the dgl’s GraphConv, for GIN i used the same code provided in dgl repository and only changed the datalaoder and some basic stuff, so in my original code now i use model = GIN( …) instead of my previous gcn model. but i thought GCN works with undirected graphs? maybe this is happening because i created the graphs not using the latest dgl version, will upgrade and report back. there has to be something wrong because when i use only degree features GIN doesn’t go above 28% accuracy but GCN goes above 60, but it doesnt seem to be a code issue since using my own set of features for nodes it is able to reach high accuracy, but still little behind GCN even with mean mean approach.

one question : in theory, is the GIN with mean graph pooling and mean neighbor pooling as powerful as using GCN with mean pooling for graph pooling?

Okay i generated the graphs on the latest dgl, and just to make sure i added the edges both ways, so if there is a edge from a to b, i also added b to a. but still no luck, GIN performs much worse than GCN, the learning rate, optimizer etc are all the same. is this normal? even the mean neighbor and mean graph pooling performs worse than GCN when the feature is a simple node degree! i thought mean mean should be almost the same as gcn?

for example after 10 epoch with only degree feature with same learning rate, GCN is 55% and GIN with mean/mean is 33% and doesn’t seem to be going up that much. loss for GCN is ~1.3 and for GIN is ~2.6. is this normal?

Updated : tried setting the num layers/num mlp layers to 1, made it worse, the accuracy of GIN is now after 10 epoch :

train set - average loss: 1.8288, accuracy: 19.8520%
valid set - average loss: 1.8522, accuracy: 19.1607%

I opened another thread for this specific problem of GIN :

Both GraphConv and GIN do not modify graph structures so whether a graph is directed or not does not make a difference here. In theory, GIN with mean graph pooling + 1 linear layer is the same as GCN with mean graph pooling + no symmetric normalization.