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

randomNodeGraph

Generate Random Graph with Specified Degree Distribution


Description

randomNodeGraph generates a random graph with the specified degree distribution. Self-loops are allowed. The resultant graph is directed (but can always be coerced to be undirected).

Usage

randomNodeGraph(nodeDegree)

Arguments

nodeDegree

A named integer vector specifying the node degrees.

Details

The input vector must be named, the names are taken to be the names of the nodes. The sum must be even (there is a theorem that says we require that to construct a graph). Self-loops are allowed, although patches to the code that make this a switchable parameter would be welcome.

Value

An instance of the graphNEL class. The graph is directed.

Author(s)

R. Gentleman

References

Random Graphs as Models of Networks, M. E. J. Newman.

See Also

Examples

set.seed(123)
c1 <- c(a = 1, b = 1, c = 2, d = 4)

(g1 <- randomNodeGraph(c1))
stopifnot(validObject(g1))

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.