dependencies method

List<Node<T>> dependencies({
  1. bool includeThisInputs = true,
  2. int? maxDepth,
  3. Iterable<Node<T>>? ignore,
})

Returns all the dependencies.

  • A dependency Node is all the inputs of all the in depth outputs (respecting maxDepth).
  • If includeThisInputs is true, also include the inputs of this Node, other wise will use only the inputs of the in depth outputs.

Implementation

List<Node<T>> dependencies(
    {bool includeThisInputs = true,
    int? maxDepth,
    Iterable<Node<T>>? ignore}) {
  ignore =
      ignore is List<Node<T>> ? ignore : (ignore?.toList() ?? <Node<T>>[]);

  Iterable<Node<T>> outputs;
  if (maxDepth != null && maxDepth == 1) {
    outputs = ignore.isNotEmpty
        ? this.outputs.where((e) => !ignore!.contains(e))
        : this.outputs;
  } else {
    outputs = outputsInDepth(maxDepth: maxDepth, ignore: ignore);
  }

  var outputsDependencies = outputs
      .where((e) => e != this)
      .expand((e) => e.inputsInDepth(ignore: ignore));

  var dependencies = <Node<T>>[
    if (includeThisInputs) ...inputsInDepth(),
    ...outputsDependencies
  ].where((e) => e != this).toSet().toList();

  return dependencies;
}