randomNodeGraph: Generate Random Graph with Specified Degree Distribution

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

View source: R/random.R

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

1
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

randomGraph, randomEGraph

Examples

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

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

Example output

Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

A graphNEL graph with directed edges
Number of Nodes = 4 
Number of Edges = 4 

graph documentation built on Nov. 8, 2020, 6:02 p.m.