← All procedures

dag.filterDAGFromRoot

This function filters a DAG to the nodes that a root can reach.

CLI
Package
@procedures/dag · README
Path
["dag","filterDAGFromRoot"]
CLI
mark dag filterDAGFromRoot --nodes <any[][]> --rootId <string>
As data
{"$proc":["dag","filterDAGFromRoot"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/dag/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["dag","filterDAGFromRoot"], { nodes: [], rootId: "<rootId>" });
console.log(JSON.stringify(result));

From the command line

$ mark dag filterDAGFromRoot --nodes <any[][]> --rootId <string>

As data, in a program

{
  "$proc": ["dag", "filterDAGFromRoot"],
  "input": { "nodes": [], "rootId": "<rootId>" }
}

Input

FieldTypeRequiredDefaultDescription
nodesany[][]yes
rootIdstringyes

Output

The schema does not list fields (any[][]).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "nodes": {
        "type": "array",
        "items": {
          "type": "array",
          "items": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique identifier for this node"
                },
                "dependencies": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Names/IDs of nodes this node depends on"
                },
                "level": {
                  "type": "number",
                  "description": "Topological level (0 = leaves, computed by Kahn's algorithm)"
                },
                "data": {
                  "description": "Optional user data associated with this node"
                }
              },
              "required": [
                "id",
                "dependencies"
              ],
              "additionalProperties": {}
            }
          ],
          "additionalItems": {},
          "minItems": 2,
          "maxItems": 2
        },
        "x-procedures-codec": "map"
      },
      "rootId": {
        "type": "string"
      }
    },
    "required": [
      "nodes",
      "rootId"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "array",
    "items": {
      "type": "array",
      "items": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Unique identifier for this node"
            },
            "dependencies": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Names/IDs of nodes this node depends on"
            },
            "level": {
              "type": "number",
              "description": "Topological level (0 = leaves, computed by Kahn's algorithm)"
            },
            "data": {
              "description": "Optional user data associated with this node"
            }
          },
          "required": [
            "id",
            "dependencies"
          ],
          "additionalProperties": {}
        }
      ],
      "additionalItems": {},
      "minItems": 2,
      "maxItems": 2
    },
    "x-procedures-codec": "map"
  }
}