sort.causality.graph: Sort the nodes of a acylcic graph

Description Usage Arguments Details Value References See Also Examples

View source: R/sort.R

Description

sort calculates the topological ordering of graph, that is sorts it.

Usage

1
2
## S3 method for class 'causality.graph'
sort(x, decreasing = FALSE, ...)

Arguments

x

causality graph that you wish to calculate the topological ordering of

decreasing

logical value to determine whether or the not sort should be in decreasing order. default is FALSE

...

additional parameters that can be sent through sort generic

Details

sort.causality.graph generates a topological ordering of the given graph by using a depth first search as described in CLRS. A topological sort (or ordering) is a linear ordering of nodes in a PDAG. That is if we have x --> y, then x < y in the sort. This ordering is not unique; a PDAG may have multiple valid orderings.

Value

A character vector that contains the nodes of the graph ordered according to their topological order. In the event that graph is cyclic, a warning is issued and NULL is returned.

References

Cormen, Thomas H., et al. Introduction to Algorithms. The MIT Press, 2014.

See Also

sort is used in various causality functions, including as.dag, is.cyclic/is.acyclic, and as.pattern

Examples

1
2
3
4
sort(sachs.dag)

# sort also works with pdags/patterns
sort(as.pattern(sachs.dag))

tzimiskes/causality documentation built on Sept. 15, 2019, 8:41 p.m.