g2dag: Graph to DAG

View source: R/utils.R

g2dagR Documentation

Graph to DAG

Description

Converts a general graph to a dag with minimum distance to the original graph. The general idea is to transitively close the graph to detect cycles and remove them based on the rule "the more outgoing edges a node has, the more likely it is that incoming edges from a cycle will be deleted, and vice versa. However, this is too rigorous and deletes too many edges, which do not lead to a cycle. These edges are added back in the final step.

Usage

g2dag(g, tc = FALSE)

Arguments

g

graph as adjacency matrix

tc

if TRUE computes the transitive closure

Value

dag as adjacency matrix

Author(s)

Ken Adams

Examples

g <- matrix(c(1,0,1,0, 1,1,0,0, 0,1,1,0, 1,1,0,1), 4, 4)
rownames(g) <- colnames(g) <- LETTERS[seq_len(4)]
dag <- g2dag(g)

cbg-ethz/dce documentation built on Oct. 29, 2022, 8:14 a.m.