Random Graph

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)
The nodes of the graph.
A set of values used to generate the graph.
A value between 0 and 1 that indicates the probability of selecting an element of M
A logical indicating whether to use the number of shared elements of M as weights.

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.

See Also

randomEGraph, randomNodeGraph

  • randomGraph
 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
Documentation reproduced from package graph, version 1.50.0, License: Artistic-2.0

Community examples

Looks like there are no examples yet.