Skip to content

Node<TNode>.Traverse.BreadthFirst Method ​

Definition ​

Enumerates over a node and its descendants breadth first.

c#
public static IEnumerable<TNode> BreadthFirst(TNode root, bool includeRoot = true, Func<TNode, bool>? shouldEnumerateDescendants = null);

View source

Parameters ​

NameTypeDescription
rootTNodeThe root node to enumerate over.
includeRootBooleanWhether to include root in the results or not. Defaults to true.
shouldEnumerateDescendantsFunc<TNode, Boolean>Optional function to specify whether the descendants of a given node should be included or not. If not provided then all descendants will be included.

Returns ​

IEnumerable<TNode>

A lazy IEnumerable<T> of the descendants in breadth first order.