Finding all disconnected subgraphs in a graph

As you can see on a figure, there are two kind of network. The first one on right hand is a main graph and another one is subgraph. My question is Are there any algorithms or techniques (cypher) that can query only the sub-graph?

1 Like

Hello @natakorn.chanpetch :slight_smile:

I think you should have a look at the Weakly Connected Components algorithm

Example: How to remove connected components less than x nodes?


thank you sir, it works very well for your example. I applied it a bit for solving my problem, but it not work well with a large of network (6xx nodes and 6xx relationships). By the way, I will read the wcc algorithm and understand it as fast a s possible. I hope it can tackle the problem. :smiley:

1 Like

I used the wcc algorithm's stream function to display each component (componentId) and set filtering by select only record that has the number of elements between 2 and 10 nodes. Moreover, a result was really good. Thank you again for helping me :smile: @Cobra

Nice, no problem, I'm happy to help :slight_smile:

1 Like