Drop zero columns in DGL sparse matrix

I want to ask if it is possible to drop zero columns of a dgl sparse matrix. I do not think there is some built function but is there any way to do it?

Thanks in advance!

Hi @ShuaiWang97, DGL sparse currently does not support this functionality. But there is a workaround. First, you can get the CSC (indptr and indices) of a DGL sparse matrix. Then you can utilize indptr.diff() to calculate the in-degree of each node and filter those nodes with zero in-degree. Finally you can call cumsum() to get the correct indptr. Notice that the column IDs is changed during the process. You may need to maintain those IDs by yourself.

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