Learn R Programming

thamesmix (version 0.1.3)

alltopsorts_recursion: all topological orderings of a DAG

Description

This function computes all topological orderings of a graph using the recursive algorithm described in Knuth and Szwarcfiter (1974).

Usage

alltopsorts_recursion(n, adj_list)

Value

Returns a list of topological orderings.

Arguments

n

number of nodes in the DAG

adj_list

edges given as an adjacency list

References

Knuth, D. E. and J. L. Szwarcfiter (1974). A structured program to generate all topological sorting arrangements. Information Processing Letters 2(6), 153–157.

Examples

Run this code
n = 4
alltopsorts_recursion(n, list(c(1,3),c(2,4)))


Run the code above in your browser using DataLab