Learn R Programming

sna (version 2.8)

rgnmix: Draw Mixing-Conditioned Random Graphs

Description

rgnmix generates random draws from a mixing-conditioned uniform random graph distribution.

Usage

rgnmix(n, tv, mix, mode = "digraph", diag = FALSE, 
    method = c("probability", "exact"), return.as.edgelist = FALSE)

Value

rgnmix draws from a simple generalization of the Erdos-Renyi N,M family (and the related N,p family), generating graphs with fixed expected or realized mixing rates. Mixing is determined by the mix argument, which must contain a class-by-class matrix of mixing rates (either edge probabilities or number of realized edges). The class for each vertex is specified in tv, whose entries must correspond to the rows and columns of mix. The resulting functionality is much like blockmodel.expand, although more general (and in some cases more efficient).

Arguments

n

the number of graphs to generate.

tv

a vector of types or classes (one entry per vertex), corresponding to the rows and columns of mix. (Note that the total number of vertices generated will be length(tv).)

mix

a class-by-class mixing matrix, containing either mixing rates (for method=="probability") or edge counts (for method=="exact").

mode

"digraph" for directed graphs, or "graph" for undirected graphs.

diag

logical; should loops be allowed?

method

the generation method to use. "probability" results in a Bernoulli edge distribution (conditional on the underlying rates), while "exact" results in a uniform draw conditional on the exact per-block edge distribution.

return.as.edgelist

logical; should the resulting graphs be returned in sna edgelist form?

Author

Carter T. Butts buttsc@uci.edu

Details

The generated graphs (in either adjacency or edgelist form).

References

Wasserman, S. and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge: Cambridge University Press.

See Also

rguman, rgnm, blockmodel.expand

Examples

Run this code
#Draw a random mixing matrix
mix<-matrix(runif(9),3,3)

#Generate a graph with 4 members per class
g<-rgnmix(1,rep(1:3,each=4),mix)
plot.sociomatrix(g)                                 #Visualize the result

#Repeat the exercise, using the exact method
mix2<-round(mix*8)                                  #Draw an exact matrix
g<-rgnmix(1,rep(1:3,each=4),mix2,method="exact")
plot.sociomatrix(g)

Run the code above in your browser using DataLab