Clear Filters
Clear Filters

How can you remove all sub-graphs that are not part of the largest component of connected sub-graphs?

1 view (last 30 days)
I imagine generating equivalence relations between the sub-graphs and doing some sort of union-find operation would be the way to go about this, but how to do this? Can somebody give an example?

Accepted Answer

Matt J
Matt J on 16 Mar 2022
Edited: Matt J on 16 Mar 2022
Given a agraph, G,
bins=biconncomp(G);
[~,cmaj]=max(histcounts(bins,1:max(bins)+1));
ekeep=find(bins==cmaj);
[sk,tk]=findedge(G,ekeep);
G=graph(sk,tk);
  4 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!