Finding Connected Component in the graph.

13 visualizzazioni (ultimi 30 giorni)
Souarv De
Souarv De il 24 Apr 2021
Risposto: Clayton Gotberg il 24 Apr 2021
I have following two questions.
(1) How to find number of connected components in a graph in MATLAB?
(2) How to find the numbers of nodes in the largest connected component in MATLAB?

Risposte (1)

Clayton Gotberg
Clayton Gotberg il 24 Apr 2021
Have you looked at the functions available for graphs (see the 'Object Functions' section) in MATLAB? It appears that conncomp will do exactly what you're looking for.
G = graph(); % put your graph here
[bins,binsizes] = conncomp(G); % Find the connected components in G and find the number
% of nodes in each connected component
% binsizes = number of nodes in each connected component
% bins = vector explaining which bin each node goes into

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by