getAllNodes function

List<NodeId> getAllNodes(
  1. Statement statement
)

Implementation

List<NodeId> getAllNodes(Statement statement) {
  if (statement is NodeStatement) {
    return [statement.id];
  } else if (statement is EdgeStatement) {
    final result = getAllNodes(statement.origin);
    EdgeRhs? rhs = statement.rhs;
    while (rhs != null) {
      result.addAll(getAllNodes(rhs.target));

      rhs = rhs.next;
    }
  } else if (statement is Subgraph) {
    return [
      for (final st in statement.stmtList.statements) ...getAllNodes(st),
    ];
  }

  return [];
}