fun <T> Collection<T>.iterateGraph(action: (T) -> Collection<T>)

Helper function to iterate over a graph The Collection on which it is called is treated as the set of starting nodes action is called for each node in the graph exactly once, and returns a set of nodes to iterate over. This returned set of nodes may contain duplicates, or nodes which have already been iterated over.

Parameters

action

invoked for each node of the graph, returns the next nodes

Type Parameters

T

the type of node, must properly implement equals and hashcode