inputsInDepth method

List<Node<T>> inputsInDepth({
  1. int? maxDepth,
  2. bool bfs = false,
  3. Iterable<Node<T>>? ignore,
})

Returns all the inputs in depth, scanning all the inputs of inputs.

Implementation

List<Node<T>> inputsInDepth(
    {int? maxDepth, bool bfs = false, Iterable<Node<T>>? ignore}) {
  final allNodes = <Node<T>>[];

  var initialProcessedNodes = ignore != null
      ? Map.fromEntries(ignore.map((e) => MapEntry(e, 1)))
      : null;

  var graphWalker = GraphWalker<T>(
    processRoots: false,
    bfs: bfs,
    initialProcessedNodes: initialProcessedNodes,
  );

  graphWalker.walkByNodes<bool>(
    [this],
    outputsProvider: (step, node) => node._inputs,
    process: (step) {
      allNodes.add(step.node);
      return null;
    },
    maxDepth: maxDepth,
  );

  return allNodes;
}