Template Function sequant::topological_order_indexed

Function Documentation

template<typename IndexDepFunc, typename Comp = std::identity>
std::vector<std::size_t> sequant::topological_order_indexed(std::size_t n, const IndexDepFunc &get_dependencies, Comp comp = {})

Determines the topological ordering (in the computer-science sense) of the indices in [0, n), given their dependency edges directly as indices into that same range.

Parameters:
  • n – The number of elements to order

  • get_dependencies – A function that, given an index in [0, n), yields a range of indices in [0, n) that it depends on

  • comp – If provided, a strict weak order over indices used to pick among candidates with no (remaining) dependencies; among candidates that compare equivalent under it (or when no comp is given), the smallest index is chosen, so that the result is always deterministic

Returns:

The topological ordering as a list of indices in [0, n)