/// <summary> /// Initializes a new instance of the <see cref="IterativeDeepeningDepthFirstSearch{TNode, TEdge}"/> class. /// </summary> /// <param name="source">The node to initiate the search from.</param> /// <param name="isTarget">A predicate for identifying the target node of the search.</param> public IterativeDeepeningDepthFirstSearch(TNode source, Predicate <TNode> isTarget) { // NB: we don't throw for default structs - which could be valid (struct with a single Id field with value 0, for example) if (source == null) { throw new ArgumentNullException(nameof(source)); } this.source = source; this.isTarget = isTarget ?? throw new ArgumentNullException(nameof(isTarget)); this.currentDepthLimit = 0; this.currentSearch = new LimitedDepthFirstSearch <TNode, TEdge>(source, isTarget, currentDepthLimit); }
/// <inheritdoc /> public void NextStep() { if (IsConcluded) { throw new InvalidOperationException("Search is concluded"); } if (currentSearch.State == LimitedDepthFirstSearch <TNode, TEdge> .States.CutOff) { currentSearch = new LimitedDepthFirstSearch <TNode, TEdge>(source, isTarget, ++currentDepthLimit); } currentSearch.NextStep(); }