Learn R Programming

sna (version 0.3)

component.dist: Calculate the Component Size Distribution of a Graph

Description

component.dist returns a data frame containing a vector of length n such that the ith element contains the number of components of G having size i, and a vector of length n giving component membership. Component strength is determined by the rule used to symmetrize the adjacency matrix; this is controlled by the eponymous parameter given to the symmetrize command.

Usage

component.dist(dat, connected="strong")

Arguments

dat
A single nxn adjacency matrix
connected
A string corresponding to the rule parameter of the symmetrize command; by default, ``strong'' components are used.

Value

  • A data frame containing:
  • membershipA vector of component memberships, by vertex
  • csizeA vector of component sizes, by component
  • cdistA vector of length |V(G)| with the (unnormalized) empirical distribution function of component sizes

Details

Use ``strong'' to find strongly connected components, ``weak'' for weakly connected components, etc. If dat is already symmetric, then the connected parameter has no effect.

References

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

See Also

components, symmetrize, geodist

Examples

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

#Find weak components
cd<-component.dist(g,connected="weak")
cd$membership              #Who's in what component?
cd$csize                   #What are the component sizes?
                           #Plot the size distribution
plot(1:length(cd$cdist),cd$cdist/sum(cd$cdist),ylim=c(0,1),type="h")  

#Find strong components
cd<-component.dist(g,connected="strong")
cd$membership              #Who's in what component?
cd$csize                   #What are the component sizes?
                           #Plot the size distribution
plot(1:length(cd$cdist),cd$cdist/sum(cd$cdist),ylim=c(0,1),type="h")

Run the code above in your browser using DataLab