transitive.closure: Computes the transitive closure of a directed graph

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/transitive.closure.R

Description

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

Usage

1
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. We use the matrix exponential to find the transitive closure.

Value

returns a graphNEL object or adjacency matrix

Author(s)

Florian Markowetz

See Also

transitive.reduction

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
   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)
    
  if(require(Rgraphviz)){
    par(mfrow=c(1,2))
    plot(g,main="NOT transitively closed")
    plot(gc,main="transitively closed")
  }

Example output

Loading required package: Rgraphviz
Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: grid

nem documentation built on Oct. 31, 2019, 2:12 a.m.