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)
M
M
as weights. graphNEL-class
is returned.
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.
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
Run the code above in your browser using DataLab