Get list of vertices and their parents for graph.

vchi(object, getv = TRUE, forceCheck = TRUE)

vchiMAT(object, getv = TRUE, forceCheck = TRUE)

vpar(object, getv = TRUE, forceCheck = TRUE)

vparMAT(object, getv = TRUE, forceCheck = TRUE)

Arguments

object

An object representing a graph. Valid objects are an adjacency matrix or an igraph.

getv

The result is by default a list of vectors of the form (v, pa1, pa2, ... paN) where pa1, pa2, ... paN are the parents of v. If getv is FALSE then the vectors will have the form (pa1, pa2, ... paN)

forceCheck

Logical indicating if it should be checked that the object is a DAG.

Value

A list of vectors where each vector will have the form (v, pa1, pa2, ... paN) where pa1, pa2, ... paN are the parents of v.

See also

Examples


## DAGs
dag_mat <- dag(~a:b:c + c:d:e, result="matrix")
dag_ig <- dag(~a:b:c + c:d:e)
vpar(dag_mat)
#> $a
#> [1] "a" "b" "c"
#> 
#> $b
#> [1] "b"
#> 
#> $c
#> [1] "c" "d" "e"
#> 
#> $d
#> [1] "d"
#> 
#> $e
#> [1] "e"
#> 
vpar(dag_ig)
#> $b
#> [1] "b"
#> 
#> $a
#> [1] "a" "b" "c"
#> 
#> $c
#> [1] "c" "d" "e"
#> 
#> $d
#> [1] "d"
#> 
#> $e
#> [1] "e"
#> 
vpar(dag_mat, getv=FALSE)
#> $a
#> [1] "b" "c"
#> 
#> $b
#> character(0)
#> 
#> $c
#> [1] "d" "e"
#> 
#> $d
#> character(0)
#> 
#> $e
#> character(0)
#> 
vpar(dag_ig, getv=FALSE)
#> $b
#> character(0)
#> 
#> $a
#> [1] "b" "c"
#> 
#> $c
#> [1] "d" "e"
#> 
#> $d
#> character(0)
#> 
#> $e
#> character(0)
#> 
## Undirected graphs
ug_mat <- ug(~a:b:c + c:d:e, result="matrix")
ug_ig <- ug(~a:b:c + c:d:e)
if (FALSE) { # \dontrun{
## This will fail because the adjacency matrix is symmetric and the
## graph has undirected edges
vpar(ug_mat)
vpar(ug_ig)
} # }
## When forceCheck is FALSE, it will not be detected that the
#g raphs are undirected.
vpar(ug_mat, forceCheck=FALSE)
#> $a
#> [1] "a" "b" "c"
#> 
#> $b
#> [1] "b" "a" "c"
#> 
#> $c
#> [1] "c" "a" "b" "d" "e"
#> 
#> $d
#> [1] "d" "c" "e"
#> 
#> $e
#> [1] "e" "c" "d"
#> 
vpar(ug_ig, forceCheck=FALSE)
#> $a
#> [1] "a" "b" "c"
#> 
#> $b
#> [1] "b" "a" "c"
#> 
#> $c
#> [1] "c" "a" "b" "d" "e"
#> 
#> $d
#> [1] "d" "c" "e"
#> 
#> $e
#> [1] "e" "c" "d"
#>