tsort {RBGL}R Documentation

topological sort of vertices of a digraph

Description

returns vector of zero-based indices of vertices of a DAG in topological sort order

Usage

tsort(x) # now x assumed to be Bioconductor graph graphNEL

Arguments

x instance of class graphNEL from Bioconductor graph class

Details

calls to the topological_sort algorithm of BGL. will check in BGL whether the input is a DAG and will report to cerr and return zeroes if it is not. Thus this function can be used to check for cycles in a digraph.

Value

a numerical vector enumerating vertices in the topological sort sequence, 0-based

Author(s)

VJ Carey <stvjc@channing.harvard.edu>

Examples

data(FileDep)
nodes(FileDep)[tsort(FileDep)+1]
FD2 <- FileDep
if (interactive()) {
  # now introduce a cycle
  FD2@edgeL[["bar_cpp"]]$edges <- c(8,1)
  tsort(FD2)
  }

[Package Contents]