Learn R Programming

gRim (version 0.3.4)

getEdges: Find edges in a graph or edges not in an undirected graph.

Description

Returns the edges of a graph (or edges not in a graph) where the graph can be either an igraph object, a list of generators or an adjacency matrix.

Usage

getEdges(object, type = "unrestricted", ingraph = TRUE, discrete = NULL, ...)

Value

A p * 2 matrix with edges.

Arguments

object

An object representing a graph; either a generator list, an igraph object or an adjacency matrix.

type

Either "unrestricted" or "decomposable"

ingraph

If TRUE the result is the edges in the graph; if FALSE the result is the edges not in the graph.

discrete

This argument is relevant only if object specifies a marked graph in which some vertices represent discrete variables and some represent continuous variables.

...

Additional arguments; currently not used.

Author

Søren Højsgaard, sorenh@math.aau.dk

Details

When ingraph=TRUE: If type="decomposable" then getEdges() returns those edges e for which the graph with e removed is decomposable.

When ingraph=FALSE: Likewise, if type="decomposable" then getEdges() returns those edges e for which the graph with e added is decomposable.

The functions getInEdges() and getInEdges() are just wrappers for calls to getEdges().

The workhorses are getInEdgesMAT() and getOutEdgesMAT() and these work on adjacency matrices.

Regarding the argument discrete, please see the documentation of mcs_marked.

See Also

edgeList, nonEdgeList.

Examples

Run this code

gg     <- ug(~a:b:d + a:c:d + c:e, result="igraph")
glist  <- getCliques(gg)
adjmat <- as(gg, "matrix")

#### On a glist
getEdges(glist)
getEdges(glist, type="decomposable")
# Deleting (a,d) would create a 4-cycle

getEdges(glist, ingraph=FALSE)
getEdges(glist, type="decomposable", ingraph=FALSE)
# Adding (e,b) would create a 4-cycle

#### On a graphNEL
getEdges(gg)
getEdges(gg, type="decomposable")
# Deleting (a,d) would create a 4-cycle

getEdges(gg, ingraph=FALSE)
getEdges(gg, type="decomposable", ingraph=FALSE)
# Adding (e,b) would create a 4-cycle

#### On an adjacency matrix
getEdges(adjmat)
getEdges(adjmat, type="decomposable")
# Deleting (a,d) would create a 4-cycle

getEdges(adjmat, ingraph=FALSE)
getEdges(adjmat, type="decomposable", ingraph=FALSE)
# Adding (e,b) would create a 4-cycle


## Marked graphs; vertices a,b are discrete; c,d are continuous
UG <- ug(~a:b:c + b:c:d, result="igraph")
disc <- c("a", "b")
getEdges(UG)
getEdges(UG, discrete=disc)
## Above: same results; there are 5 edges in the graph

getEdges(UG, type="decomposable")
## Above: 4 edges can be removed and will give a decomposable graph
##(only removing the edge (b,c) would give a non-decomposable model)

getEdges(UG, type="decomposable", discrete=c("a","b"))
## Above: 3 edges can be removed and will give a strongly decomposable
## graph. Removing (b,c) would create a 4--cycle and removing (a,b)
## would create a forbidden path; a path with only continuous vertices
## between two discrete vertices.

Run the code above in your browser using DataLab