depthFirstTraversal

inline fun <T : Any> depthFirstTraversal(t: T, crossinline childrenFactory: T.() -> List<T>): Sequence<T>(source)

Generates a depth-first traversal sequence for a given tree or graph structure.

Return

A depth-first traversal sequence for the tree/graph.

Parameters

t

The root element of the tree/graph.

childrenFactory

A lambda that returns the children of a given element.