@haragei/dag
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "@haragei/dag", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Aleksandar Ružičić", | ||
@@ -10,3 +10,6 @@ "license": "MIT", | ||
"graph", | ||
"cycle detection" | ||
"cycle detection", | ||
"topological ordering", | ||
"toposort", | ||
"task scheduling" | ||
], | ||
@@ -13,0 +16,0 @@ "homepage": "https://github.com/haragei-dev/dag", |
@@ -119,4 +119,8 @@ # @haragei/dag | ||
- [`.getNodeOrder()`](#getnodeordernodes-t-t) | ||
- [`.sortNodes()`](#sortnodes-t-t) | ||
- [`.sortNodes()`](#sortnodesnodes-t-t) | ||
Subgraphs: | ||
- [`.subGraphs()`](#subgraphs-t) | ||
- [`.parallelize()`](#parallelize-parallelcollectiont) | ||
Predecessors / Successors: | ||
@@ -333,3 +337,3 @@ - [`.getImmediatePredecessorsOf()`](#getimmediatepredecessorsofnodes-t-sett) | ||
#### `sort(nodes: T[]): T[]` | ||
#### `sortNodes(nodes: T[]): T[]` | ||
@@ -346,2 +350,35 @@ Sorts the given array of nodes, in place by their topological order. | ||
#### `subGraphs(): T[][]` | ||
Returns an array of node arrays, where each inner array represents a subgraph. | ||
The nodes in each subgraph are topologically ordered. | ||
**Returns:** An array of independent subgraphs. | ||
#### `parallelize(): ParallelCollection<T>` | ||
Returns a set of all subgraphs in the graph. | ||
Each subgraph is represented either as a single node, or as an array which | ||
is meant to be processed sequentially and its items are either a single node | ||
or a Set of nodes that can be processed in parallel. | ||
**Example:** | ||
```typescript | ||
const dag = new DAG<string>(['Z']); | ||
dag.addEdge('A', 'B'); | ||
dag.addEdge('A', 'C'); | ||
dag.addEdge('B', 'D'); | ||
dag.addEdge('C', 'D'); | ||
dag.addEdge('X', 'Y'); | ||
console.log(dag.parallelize()); | ||
// Set(3) { [ 'A', Set(2) { 'B', 'C' }, 'D' ], [ 'X', 'Y' ], 'Z' } | ||
``` | ||
**Returns:** A set of all subgraphs in the graph, parallelized. | ||
#### `getImmediatePredecessorsOf(...nodes: T[]): Set<T>` | ||
@@ -348,0 +385,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
153950
46
514