randomDAG: outputs the adjacency matrix of a randomly generated directed...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/randomDAG.R

Description

After simulating a random topological order first (the order can also be prespecified), the algorithm connects two nodes with the porbability probConnect.

Usage

1
randomDAG(p, probConnect, causalOrder = sample(p, p, replace = FALSE))

Arguments

p

number of nodes.

probConnect

probability of connecting two nodes, determines the sparsity of the graph. Choosing probConnect = 2/(p-1), for example, leads to an expected number of p nodes.

causalOrder

OPTIONAL: causal or topological order of the nodes. If not provided, the topological order is chosen randomly.

Value

p x p adjacency matrix that describes a directed acyclic graph (DAG) with p nodes. The entry (i,j) equals one if and only if there is an edge from i to j.

Author(s)

Jonas Peters <jonas.peters@tuebingen.mpg.de>

See Also

structIntervDist hammingDist

Examples

1
randomDAG(p = 5, probConnect = 0.6)

Example output

5 x 5 sparse Matrix of class "dgCMatrix"
              
[1,] . 1 1 1 1
[2,] . . 1 1 1
[3,] . . . . .
[4,] . . . . .
[5,] . . 1 . .

SID documentation built on May 2, 2019, 1:05 p.m.