randomGraph: Random Graph

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/random.R

Description

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.

Usage

1

Arguments

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 M

weights

A logical indicating whether to use the number of shared elements of M as weights.

Details

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.

Value

An object of class graphNEL-class is returned.

Author(s)

R. Gentleman

See Also

randomEGraph, randomNodeGraph

Examples

1
2
3
4
5
6
 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

vjcitn/graph documentation built on Dec. 23, 2021, 4:06 p.m.