Learn R Programming

sna (version 0.3)

components: Find the Number of (Maximal) Components Within a Given Graph

Description

Returns the number of components within dat, using the connectedness rule given in connected.

Usage

components(dat, connected="strong", comp.dist.precomp=NULL)

Arguments

dat
An nxn adjacency matrix
connected
The symmetrizing rule to be used by symmetrize before components are extracted
comp.dist.precomp
A component size distribution object from component.dist (optional)

Value

  • The number of components of dat

Details

The connected parameter corresponds to the rule parameter of component.dist. By default, components returns the number of strong components, but weak components can be returned if so desired. For symmetric matrices, this is obviously a moot point.

References

West, D.B. (1996). Introduction to Graph Theory. Upper Saddle River, NJ: Prentice Hall.

See Also

component.dist, link{symmetrize}

Examples

Run this code
g<-rgraph(20,tprob=0.05)   #Generate a sparse random graph

#Find weak components
components(g,connected="weak")

#Find strong components
components(g,connected="strong")

Run the code above in your browser using DataLab