transitive.closure {nem} | R Documentation

## Computes the transitive closure of a directed graph

### Description

Computes the transitive closure of a graph. Introduces a direct edge whenever there is a path between two nodes in a digraph.

### Usage

    transitive.closure(g, mat=FALSE, loops=TRUE)

### Arguments

`g` | graphNEL object or adjacency matrix.
`mat` | convert result to adjacency matrix.
`loops` | Add loops from each node to itself?

### Details

This function calculates the transitive closure of a given graph. If the input graph is a 'graphNEL' object, `transitive.reduction` is essentially a wrapper around the `RBGL::transitive.closure`, to make its output more convenient for our purpose. If the input is an adjacency matrix we use the matrix exponential for a quicker way to find the transitive closure.

### Value

returns a graphNEL object or adjacency matrix

### Author(s)

Florian Markowetz <URL: http://genomics.princeton.edu/~florian>

### See Also

`enumerate.models`, `transitive.reduction`

### Examples

       V <- LETTERS[1:3]
       edL <- list(A=list(edges="B"),B=list(edges="C"),C=list(edges=NULL))
       g <- new("graphNEL",nodes=V,edgeL=edL,edgemode="directed")
       gc <- transitive.closure(g,loops=FALSE)

       par(mfrow=c(1,2))
       plot(g,main="NOT transitively closed")
       plot(gc,main="transitively closed")

[Package nem version 2.4.0 Index]