breadthFirstTraversal

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

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

Return

A breadth-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.