1.0.0 • Published 6 years ago

compute-dependency-hierarchy v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Compute Dependency Hierarchy

This module exports a function that takes

  • a layer layername
  • a list of nodes
  • a list of dependency relationships between nodes

It returns an array of layers.

Each layer contains a layer node whose parent more dependent layernodes and the set of nodes at that layer each with a parent of the layer node. Effectively this is an array of trees that can be rendered into a view.

Nodes: A,B,C Relationships A->B,B->C

Result

[
  [
    {
      "id": "layer0",
      "layerdepth": 0,
      "parent": null
    },
    {
      "id": "A",
      "layerdepth": 0,
      "parent": "layer0"
    }
  ],
  [
    {
      "id": "layer1",
      "layerdepth": 1,
      "parent": null
    },
    {
      "id": "B",
      "layerdepth": 1,
      "parent": "layer1"
    }
  ],
  [
    {
      "id": "layer2",
      "layerdepth": 2,
      "parent": null
    },
    {
      "id": "C",
      "layerdepth": 2,
      "parent": "layer2"
    }
  ]
]