Remove edges based on boolean mask

Hi there,

I’m working on a project where I need to remove some edges from the graph based on their features. The feature is this:

>>> mygraph.edges[('user', 'liked', 'category')].data["score"]
>>> tensor([[1., 0.],
         [1., 0.],
         [1., 0.],
         ...,
         [1., 0.],
         [1., 0.],
         [1., 0.]])

The boolean mask that I’d like to use to keep the edges that I’m interested In is:

mygraph.edges[('user', 'liked', 'category')].data["score"][:,1].eq(1)

Is there a way to do it?

You can try dgl.edge_subgraph — DGL 1.2 documentation to remove edges that your not interested by passing a Bool tensor to edges parameter in the edge_subgraph method.

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