1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.partitionCycles = exports.getCycle = void 0;
|
4 | function getCycle(ancestors, nodeId) {
|
5 | if (!ancestors.includes(nodeId)) {
|
6 | return null;
|
7 | }
|
8 |
|
9 | return ancestors.slice(ancestors.indexOf(nodeId));
|
10 | }
|
11 | exports.getCycle = getCycle;
|
12 | function partitionCycles(nodeId, allCyclesTheNodeIsPartOf) {
|
13 | const cyclesStartWithThisNode = [];
|
14 | const cyclesWithThisNode = [];
|
15 | for (const cycle of allCyclesTheNodeIsPartOf) {
|
16 | const nodeStartsCycle = cycle[0] === nodeId;
|
17 | if (nodeStartsCycle) {
|
18 | cyclesStartWithThisNode.push(cycle);
|
19 | }
|
20 | else {
|
21 | cyclesWithThisNode.push(cycle);
|
22 | }
|
23 | }
|
24 | return { cyclesStartWithThisNode, cyclesWithThisNode };
|
25 | }
|
26 | exports.partitionCycles = partitionCycles;
|
27 |
|
\ | No newline at end of file |