Extract the list of blocks from a block tree

Share:

Description

Returns the list of blocks from a block tree. The block tree is an (intermediate) result of the function setTreeBlocks. setTreeBlocks is used in simpleGraphToGraph on the slot block.tree of the object of class dg.simple.graph-class.

Usage

1

Arguments

tree

The BlockTree part of the result of setTreeBlocks.

Value

A list of blocks, each block of class dg.Block.

Author(s)

Jens Henrik Badsberg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Block.tree <- list(label = "W", Vertices = c("contry"),
                   X = list(Vertices = c("sex", "race"),
                            A = list(Vertices = c("hair", "eye"),
                                     horizontal = FALSE),
                            B = list(Vertices = c("age"),
                                     C = list(Vertices = c("education")))))
Names <- unlist(Block.tree)
Names <- Names[grep("Vertices", names(Names))]
Types <- rep("Discrete", length(Names))
vertices <- returnVertexList(Names, types = Types)
blocktree <- setTreeBlocks(Block.tree, vertices)
blocklist <- blockTreeToList(blocktree$BlockTree)
Labels(blocklist)
str(Parents(blocklist))
str(Children(blocklist))
str(NodeAncestors(blocklist))
str(NodeDescendants(blocklist))
parent(blocklist[[5]])
children(blocklist[[1]])
ancestors(blocklist[[5]])
descendants(blocklist[[1]])
parent(blocklist[[3]]) <- 4
children(blocklist[[2]])
checkBlockList(blocklist)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.