Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

randomEGraph

Random Edge Graph


Description

A function to create random graphs according to a random edge model. The user supplies the set of nodes for the graph as V and either a probability, p, that is used for each edge or the number of edges, edges they want to have in the resulting graph.

Usage

randomEGraph(V, p, edges)

Arguments

V

The nodes for the graph.

p

The probability of an edge being selected.

edges

The number of edges wanted.

Details

The user must specify the set of nodes and either a probability for edge selection or the number of edges wanted, but not both. Let nV denote the number of nodes. There are choose(nV, 2) edges in the complete graph. If p is specified then a biased coin (probability of heads being p) is tossed for each edge and if it is heads that edge is selected. If edges is specified then that many edges are sampled without replacement from the set of possible edges.

Value

An object of class graphNEL-class that contains the nodes and edges.

Author(s)

R. Gentleman

See Also

Examples

set.seed(123)
  V <- letters[14:22]
  g1 <- randomEGraph(V, .2)

  g2 <- randomEGraph(V, edges=30)

graph

graph: A package to handle graph data structures

v1.68.0
Artistic-2.0
Authors
R. Gentleman, Elizabeth Whalen, W. Huber, S. Falcon
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.