newton.utils.topological_sort#

newton.utils.topological_sort(joints, use_dfs=True)[source]#

Topological sort of a list of joints connecting rigid bodies.

Parameters:
  • joints (List[Tuple[int, int]]) – A list of joint pairs (parent, child).

  • use_dfs (bool) – If True, use depth-first search for topological sorting. If False, use Kahn’s algorithm. Default is True.

Returns:

A list of joint indices in topological order.

Return type:

List[int]