topological_sort

topological_sort(
model,
*,
forward: bool = True,
initial: Iterable[int] | None = None,
) → list[int]

Sort the states of a sparse model topologically.

Parameters:
  • model – Sparse model.

  • forward – If True, the states are sorted along the transitions. Otherwise, the states are sorted along the backward transitions.

  • initial – (optional) States from which the sorting starts.

Returns:

List of states in topological order.