concom {concom} | R Documentation |
Connected components
Description
Fast computation of the connected components of an undirected graph.
Usage
concom(edges)
Arguments
edges |
a matrix with two columns, whose rows represent the edges of the graph; each edge is given by two vertex indices, and it is assumed that the vertex indices are 1, 2, 3, ... |
Value
A list with four elements: indices
, an integer vector
whose i
-th element gives the label of the connected component of
vertex i
; sizes
, an integer vector giving the number of
elements of each connected component; ncomponents
, the number
of connected components; components
, a list of length
ncomponents
, whose j
-th element is the integer vector made
of the labels of the j
-th connected component.
Examples
library(concom)
edges <- cbind(
1:7,
c(2, 3, 1, 5, 6, 7, 4)
)
concom(edges)
[Package concom version 1.0.0 Index]