5.0 | 1 rating Rate this file 15 Downloads (last 30 days) File Size: 1.22 KB File ID: #30926 Version: 1.4

Largest Component



31 Mar 2011 (Updated )

Takes an adj. matrix of a network and outputs a list of the nodes in its largest connected component

| Watch this File

File Information


This function find the largest connected component of a networks.

Input A is the adjacency matrix of the network.

Output B is a list of the nodes that are in the largest component.

A(B,B) will give the adj. matrix of the largest component.

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
30 Jan 2014 Deepesh Nagarajan

Used on Octave, works as advertised.

18 Feb 2012 Fabio Gori

It would be nice if you commented the code, so that the procedure would be more comprehensible.

Comment only
06 Jun 2011 Puck Rombach

You are right. Thank you!

Comment only
26 May 2011 Xin Dong

There is a bug in this script. It fails when there are several largest connected components of the same size, because now cm is a vector.

If you only need to find any one of them, than it should be:


Otherwise, a loop is needed to print out all the largest components.

Comment only
02 Apr 2011 1.1

Made the code faster by not using the 'find' function.

06 Jun 2011 1.4

Fixed bug about multiple largest components.

Contact us