graph icon indicating copy to clipboard operation
graph copied to clipboard

How to split graph into disconnected subgraphs

Open orzel7 opened this issue 8 months ago • 4 comments

Is there a way to split graph into subgraphs which are not connected with each other? For example, the graph with vertices A,B,C,D,E and edges A-B ,C-D, D-E(please note lack of B-C edge) could be divided into two "isolated" graphs: (A-B) (C-D-E)

orzel7 avatar Dec 17 '23 00:12 orzel7

@orzel7 did you found a solution for it ?

AkashKumar7902 avatar Feb 09 '24 19:02 AkashKumar7902

@AkashKumar7902 I used github.com/yourbasic/graph package(function graph.Components()) to complete my task. But i still hope this functionality will be added to this package.

orzel7 avatar Feb 09 '24 21:02 orzel7

Hi, I'm going to open a feature request for this function.

dominikbraun avatar Mar 06 '24 12:03 dominikbraun

@dominikbraun, please take a look on my change: #171 If is conceptually ok for you, I'll add some tests. @AkashKumar7902, this PR works for me.

orzel7 avatar Apr 07 '24 21:04 orzel7