diff --git a/ICD.Common.Utils/RecursionUtils.cs b/ICD.Common.Utils/RecursionUtils.cs index fe2a4fd..554053d 100644 --- a/ICD.Common.Utils/RecursionUtils.cs +++ b/ICD.Common.Utils/RecursionUtils.cs @@ -87,6 +87,42 @@ namespace ICD.Common.Utils yield return item; } + /// + /// Returns true if there is a path from the given root to the given child node. + /// + /// + /// + /// + /// + /// + public static bool BreadthFirstSearch(T root, T child, Func> getChildren) + { + if (getChildren == null) + throw new ArgumentNullException("getChildren"); + + return BreadthFirstSearchPath(root, child, getChildren) != null; + } + + /// + /// Returns true if there is a path from the given root to the given child node. + /// + /// + /// + /// + /// + /// + /// + public static bool BreadthFirstSearch(T root, T destination, Func> getChildren, IEqualityComparer comparer) + { + if (getChildren == null) + throw new ArgumentNullException("getChildren"); + + if (comparer == null) + throw new ArgumentNullException("comparer"); + + return BreadthFirstSearchPath(root, destination, getChildren, comparer) != null; + } + /// /// Returns all of the nodes in the tree via breadth-first search. ///