Learn R Programming

gRbase (version 1.6-12)

triangulate: Triangulation of an undirected graph

Description

This function will triangulate an undirected graph by adding fill-ins.

Usage

triangulate(object, ...)
## S3 method for class 'graphNEL':
triangulate(object, nLevels = NULL, result="graphNEL", ...)
## S3 method for class 'matrix':
triangulate(object, nLevels = NULL, result="matrix", ...)
## S3 method for class 'Matrix':
triangulate(object, nLevels = NULL, result="Matrix", ...)
triangulateMAT(amat, nLevels=rep(2, ncol(amat)), result=NULL, ...)

Arguments

object
An undirected graph represented either as a graphNEL object, a (dense) matrix, a (sparse) dgCMatrix
nLevels
The number of levels of the variables (nodes) when these are discrete. Used in determining the triangulation using a "minimum clique weight heuristic". See section 'details'.
result
The type (representation) of the result. Possible values are "graphNEL", "matrix", "Matrix" (the latter meaning a sparse dgCMatrix).
...
Additional arguments, currently not used.
amat
Adjacency matrix; a (dense) matrix, or a (sparse) dgCMatrix.

Value

  • A triangulated graph represented either as a graphNEL, a (dense) matrix or a (sparse) dgCMatrix.

Details

The workhorse is the triangulateMAT function. The triangulation is made so as the total state space is kept low by applying a minimum clique weight heuristic: When a fill-in is necessary, the algorithm will search for an edge to add such that the complete set to be formed will have as small a state-space as possible. It is in this connection that the nLevels values are used. Default (when nLevels=NULL) is to take nLevels=2 for all nodes. If nLevels is the same for all nodes then the heuristic aims at keeping the clique sizes small.

See Also

ug dag mcs, mcsMAT rip, ripMAT, moralize, moralizeMAT

Examples

Run this code
## graphNEL
uG1 <- ug(~a:b+b:c+c:d+d:e+e:f+f:a)
tuG1 <- triangulate(uG1)

## adjacency matrix
uG2 <- ug(~a:b+b:c+c:d+d:e+e:f+f:a, result="matrix")
tuG2 <- triangulate(uG2)

## adjacency matrix (sparse)
uG2 <- ug(~a:b+b:c+c:d+d:e+e:f+f:a, result="Matrix")
tuG2 <- triangulate(uG2)

Run the code above in your browser using DataLab