Split graph into subgraph(非连通图分成多个连通子图)

hi:
now I want to

大家好:
我现在想要实现这样一个功能,有个包含特征的非连通图,想把他分成多个子图 每个图都是连通的。
举个例子:
import dgl
import torch
src=[0,1,2,3,4,5]
dst=[1,2,3,0,5,4]
feats=torch.tensor([[0,0,0],[1,1,1],[2,2,2],[3,3,3],[4,4,4],[5,5,5]])
g=dgl.graph((torch.tensor(src),torch.tensor(dst)))

g.ndata[“feats”]=feats
print(g)

这里节点[0,1,2,3]是连通的 [4 5]是连通的 所以想把这个图分割成两个子图 对应的边和节点做出对应的改变

看了文档:dgl.node_subgraph() 但是dgl.ID 还是原始的ID没有重新变成0,1,2,3…

Translation: the OP wants to split the graph into connected components with DGL.

For now DGL does not support finding connected components. I would suggest using e.g. networkx to do that.

Besides, if you find speaking Chinese more comfortable than speaking English, we would like to invite you to our Slack channel where we have a dedicated Chinese channel.

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