Template Function sequant::topological_order

Function Documentation

template<std::ranges::random_access_range Range, typename DepFunc, typename Comp = std::identity>
std::vector<std::size_t> sequant::topological_order(Range &&range, const DepFunc &get_dependencies, Comp comp = {})

Determines the topological ordering (in the computer-science sense) of the provided elements.

Parameters:
  • range – The range of objects whose ordering shall be determined

  • get_dependencies – A function that yields a range of dependencies for the given object. All these dependencies must be (references to) objects in range.

  • comp – If provided, this is used to determine the order of elements for which the topological ordering is not unique

Returns:

The topological ordering as a list of indices into range