如何在图形网络中分割出断开连接的节点区域(弧节点?)?

How can I segment out disconnected regions of nodes (arc nodes?) in a graph network?

下图显示了节点-边图。

我想将节点集群分割成单独的图表,如下所示。节点 4、5 不是图形重置的一部分。我如何通过算法为任意图形网络执行此操作?

我正在使用 python 3.8 和 windows 10。

您可以使用scipy.sparse.csgraph.connected_components

https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.connected_components.html