1%{ @file weaklyconncomp.m
2 % @brief Finds weakly connected components in a directed graph
4 % @author LINE Development Team
8 % @brief Finds weakly connected components in a directed graph
11 % Returns the weakly connected components in a graph G.
15 % [S, C] = weaklyconncomp(G)
20 % <tr><th>Name<th>Description
21 % <tr><td>G<td>Adjacency matrix of the graph
26 % <tr><th>Name<th>Description
27 % <tr><td>S<td>Number of connected components
28 % <tr><td>C<td>Component assignment vector (C(i)
is the component index of node i)
31function [S,C] = weaklyconncomp(G)
33 [p,~,r] = dmperm(G
'+speye(size(G)));
35 C = cumsum(full(sparse(1,r(1:end-1),1,1,size(G,1))));