Finding all disconnected subgraphs in a graph

后端 未结 7 2230
长发绾君心
长发绾君心 2020-12-07 22:57

I have a graph which contains an unknown number of disconnected subgraphs. What\'s a good algorithm (or Java library) to find them all?

7条回答
  •  被撕碎了的回忆
    2020-12-07 23:20

    I'm assuming you want to find all the (strongly) connected components? For that you can use Tarjan's algorithm (a variant of DFS)

提交回复
热议问题