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.component.dist(dat, connected="strong")
rule
parameter of the symmetrize
command; by default, ``strong'' components are used.dat
is already symmetric, then the connected
parameter has no effect.components
, symmetrize
, geodist
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