randomGraph | R Documentation |
This function generates a random graph according to a model that
involves a latent variable. The construction is to randomly assign
members of the set M
to the nodes, V
. An edge is assigned
between two elements of V
when they both have the same element
of M
assigned to them. An object of class graphNEL
is
returned.
randomGraph(V, M, p, weights=TRUE)
V |
The nodes of the graph. |
M |
A set of values used to generate the graph. |
p |
A value between 0 and 1 that indicates the probability of
selecting an element of |
weights |
A logical indicating whether to use the number of
shared elements of |
The model is quite simple. To generate a graph, G
, the user
supplies the list of nodes, V
and a set of values M
which will be used to create the graph. For each node in V
a
logical vector with length equal to the length of M
is
generated. The probability of a TRUE
at any position is
determined by p
. Once valus from M
have been assigned to
each node in V
the result is processed into a graph. This is
done by creating an edge between any two elements of V
that
share an element of M
(as chosen by the selection process).
The sizes of V
and M
and the values of p
determine how dense the graph will be.
An object of class graphNEL-class
is returned.
R. Gentleman
randomEGraph
, randomNodeGraph
set.seed(123)
V <- letters[1:10]
M <- 1:4
g1 <- randomGraph(V, M, 0.2)
numEdges(g1) # 16, in this case
edgeNames(g1)# "<from> ~ <to>" since undirected
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.