make_dag: Returns the adjacency matrix of a chain, complete, or a...

Description Usage Arguments Details Value Examples

View source: R/zero_gen.R

Description

Returns the adjacency matrix of a chain, complete, or a lattice DAG.

Usage

1
make_dag(m, mode, nrows = 0, shuffle = FALSE, seed = NULL)

Arguments

m

A positive integer, the dimension.

mode

One of "chain", "star_out", "star_in", "tree", "complete", "lattice".

nrows

A positive integer that divides m, used for mode == "lattice" as the number of rows in the graph.

shuffle

A logical, indicates whether the nodes 1:m should be shuffled. Defaults to FALSE.

seed

A number, the seed passed to set.seed() if shuffle == TRUE.

Details

A chain graph has the form 1 -> 2 -> 3 -> ... -> m. A star_out graph has and only has edges 1 -> i for all 1 < i <= m. A star_in graph has and only has edges i -> 1 for all 1 < i <= m. A tree graph has edges (i A complete graph has an edge from i to j for any 1 <= i < j <= m. A lattice graph first places the nodes in a nrows x (m/nrows) matrix, row by row. That is, the i-th node is on the i %/% (m/nrows) + 1-th row and the i %% (m/nrows)-th column (or the (m/nrows)-th column if i divides it). Then add an edge between any two adjacent nodes, pointing from the left to the right or from the node above to the node below. If shuffle == TRUE, the rows/columns of the returning adjacency matrix are simultaneously shuffled.

Value

The m x m adjacency matrix of the DAG.

Examples

1
2
3
4
5
6
make_dag(10, "chain", shuffle=FALSE)
make_dag(10, "chain", shuffle=TRUE)
make_dag(10, "complete", shuffle=FALSE)
make_dag(10, "complete", shuffle=TRUE)
make_dag(12, "lattice", nrows=3, shuffle=FALSE)
make_dag(12, "lattice", nrows=3, shuffle=TRUE)

sqyu/ZiDAG documentation built on Jan. 19, 2021, 4:11 p.m.