roots method

List<Node<T>> roots({
  1. bool bfs = false,
})

Implementation

List<Node<T>> roots({bool bfs = false}) {
  final roots = <Node<T>>[];

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

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

  return roots;
}