@rsconcept/domain 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/cctext/index.d.ts +1 -0
- package/dist/cctext/index.js +42 -0
- package/dist/cctext/index.js.map +1 -0
- package/dist/cctext/language-api.d.ts +43 -0
- package/dist/cctext/language-api.js +252 -0
- package/dist/cctext/language-api.js.map +1 -0
- package/dist/cctext/language.d.ts +58 -0
- package/dist/cctext/language.js +44 -0
- package/dist/cctext/language.js.map +1 -0
- package/dist/graph/graph.d.ts +62 -0
- package/dist/graph/graph.js +385 -0
- package/dist/graph/graph.js.map +1 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/graph/index.js +384 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +5851 -0
- package/dist/index.js.map +1 -0
- package/dist/library/folder-tree.d.ts +32 -0
- package/dist/library/folder-tree.js +136 -0
- package/dist/library/folder-tree.js.map +1 -0
- package/dist/library/index.d.ts +17 -0
- package/dist/library/index.js +2800 -0
- package/dist/library/index.js.map +1 -0
- package/dist/library/library-api.d.ts +6 -0
- package/dist/library/library-api.js +13 -0
- package/dist/library/library-api.js.map +1 -0
- package/dist/library/library.d.ts +56 -0
- package/dist/library/library.js +23 -0
- package/dist/library/library.js.map +1 -0
- package/dist/library/oss-api.d.ts +47 -0
- package/dist/library/oss-api.js +1105 -0
- package/dist/library/oss-api.js.map +1 -0
- package/dist/library/oss-layout-api.d.ts +36 -0
- package/dist/library/oss-layout-api.js +330 -0
- package/dist/library/oss-layout-api.js.map +1 -0
- package/dist/library/oss-layout.d.ts +25 -0
- package/dist/library/oss-layout.js +1 -0
- package/dist/library/oss-layout.js.map +1 -0
- package/dist/library/oss.d.ts +136 -0
- package/dist/library/oss.js +30 -0
- package/dist/library/oss.js.map +1 -0
- package/dist/library/rsengine.d.ts +116 -0
- package/dist/library/rsengine.js +2604 -0
- package/dist/library/rsengine.js.map +1 -0
- package/dist/library/rsform-api.d.ts +74 -0
- package/dist/library/rsform-api.js +879 -0
- package/dist/library/rsform-api.js.map +1 -0
- package/dist/library/rsform.d.ts +206 -0
- package/dist/library/rsform.js +32 -0
- package/dist/library/rsform.js.map +1 -0
- package/dist/library/rsmodel-api.d.ts +43 -0
- package/dist/library/rsmodel-api.js +836 -0
- package/dist/library/rsmodel-api.js.map +1 -0
- package/dist/library/rsmodel.d.ts +52 -0
- package/dist/library/rsmodel.js +25 -0
- package/dist/library/rsmodel.js.map +1 -0
- package/dist/library/structure-planner.d.ts +33 -0
- package/dist/library/structure-planner.js +481 -0
- package/dist/library/structure-planner.js.map +1 -0
- package/dist/parsing/ast.d.ts +49 -0
- package/dist/parsing/ast.js +93 -0
- package/dist/parsing/ast.js.map +1 -0
- package/dist/parsing/index.d.ts +3 -0
- package/dist/parsing/index.js +141 -0
- package/dist/parsing/index.js.map +1 -0
- package/dist/parsing/lezer-tree.d.ts +13 -0
- package/dist/parsing/lezer-tree.js +50 -0
- package/dist/parsing/lezer-tree.js.map +1 -0
- package/dist/rslang/api.d.ts +53 -0
- package/dist/rslang/api.js +846 -0
- package/dist/rslang/api.js.map +1 -0
- package/dist/rslang/ast-annotations.d.ts +18 -0
- package/dist/rslang/ast-annotations.js +56 -0
- package/dist/rslang/ast-annotations.js.map +1 -0
- package/dist/rslang/error.d.ts +85 -0
- package/dist/rslang/error.js +159 -0
- package/dist/rslang/error.js.map +1 -0
- package/dist/rslang/eval/calculator.d.ts +43 -0
- package/dist/rslang/eval/calculator.js +1639 -0
- package/dist/rslang/eval/calculator.js.map +1 -0
- package/dist/rslang/eval/evaluation-cache.d.ts +36 -0
- package/dist/rslang/eval/evaluation-cache.js +310 -0
- package/dist/rslang/eval/evaluation-cache.js.map +1 -0
- package/dist/rslang/eval/evaluator.d.ts +70 -0
- package/dist/rslang/eval/evaluator.js +1514 -0
- package/dist/rslang/eval/evaluator.js.map +1 -0
- package/dist/rslang/eval/value-api.d.ts +48 -0
- package/dist/rslang/eval/value-api.js +490 -0
- package/dist/rslang/eval/value-api.js.map +1 -0
- package/dist/rslang/eval/value.d.ts +36 -0
- package/dist/rslang/eval/value.js +118 -0
- package/dist/rslang/eval/value.js.map +1 -0
- package/dist/rslang/index.d.ts +17 -0
- package/dist/rslang/index.js +4314 -0
- package/dist/rslang/index.js.map +1 -0
- package/dist/rslang/labels.d.ts +16 -0
- package/dist/rslang/labels.js +315 -0
- package/dist/rslang/labels.js.map +1 -0
- package/dist/rslang/parser/expression-generator.d.ts +10 -0
- package/dist/rslang/parser/expression-generator.js +451 -0
- package/dist/rslang/parser/expression-generator.js.map +1 -0
- package/dist/rslang/parser/normalize.d.ts +11 -0
- package/dist/rslang/parser/normalize.js +507 -0
- package/dist/rslang/parser/normalize.js.map +1 -0
- package/dist/rslang/parser/parser.d.ts +5 -0
- package/dist/rslang/parser/parser.js +24 -0
- package/dist/rslang/parser/parser.js.map +1 -0
- package/dist/rslang/parser/parser.terms.d.ts +42 -0
- package/dist/rslang/parser/parser.terms.js +84 -0
- package/dist/rslang/parser/parser.terms.js.map +1 -0
- package/dist/rslang/parser/syntax-errors.d.ts +11 -0
- package/dist/rslang/parser/syntax-errors.js +403 -0
- package/dist/rslang/parser/syntax-errors.js.map +1 -0
- package/dist/rslang/parser/token.d.ts +79 -0
- package/dist/rslang/parser/token.js +95 -0
- package/dist/rslang/parser/token.js.map +1 -0
- package/dist/rslang/semantic/analyzer.d.ts +39 -0
- package/dist/rslang/semantic/analyzer.js +2604 -0
- package/dist/rslang/semantic/analyzer.js.map +1 -0
- package/dist/rslang/semantic/arguments-extractor.d.ts +42 -0
- package/dist/rslang/semantic/arguments-extractor.js +366 -0
- package/dist/rslang/semantic/arguments-extractor.js.map +1 -0
- package/dist/rslang/semantic/type-auditor.d.ts +73 -0
- package/dist/rslang/semantic/type-auditor.js +1570 -0
- package/dist/rslang/semantic/type-auditor.js.map +1 -0
- package/dist/rslang/semantic/typification-api.d.ts +27 -0
- package/dist/rslang/semantic/typification-api.js +320 -0
- package/dist/rslang/semantic/typification-api.js.map +1 -0
- package/dist/rslang/semantic/typification-parser.d.ts +12 -0
- package/dist/rslang/semantic/typification-parser.js +226 -0
- package/dist/rslang/semantic/typification-parser.js.map +1 -0
- package/dist/rslang/semantic/typification.d.ts +119 -0
- package/dist/rslang/semantic/typification.js +74 -0
- package/dist/rslang/semantic/typification.js.map +1 -0
- package/dist/rslang/semantic/value-auditor.d.ts +43 -0
- package/dist/rslang/semantic/value-auditor.js +523 -0
- package/dist/rslang/semantic/value-auditor.js.map +1 -0
- package/dist/rslang/semantic/value-class.d.ts +10 -0
- package/dist/rslang/semantic/value-class.js +9 -0
- package/dist/rslang/semantic/value-class.js.map +1 -0
- package/dist/rslang/typification-graph.d.ts +33 -0
- package/dist/rslang/typification-graph.js +311 -0
- package/dist/rslang/typification-graph.js.map +1 -0
- package/dist/shared/branded.d.ts +7 -0
- package/dist/shared/branded.js +1 -0
- package/dist/shared/branded.js.map +1 -0
- package/dist/shared/hash.d.ts +6 -0
- package/dist/shared/hash.js +18 -0
- package/dist/shared/hash.js.map +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +18 -0
- package/dist/shared/index.js.map +1 -0
- package/package.json +184 -0
- package/src/cctext/index.ts +9 -0
- package/src/cctext/language-api.test.ts +149 -0
- package/src/cctext/language-api.ts +285 -0
- package/src/cctext/language.ts +80 -0
- package/src/graph/graph.test.ts +392 -0
- package/src/graph/graph.ts +433 -0
- package/src/graph/index.ts +1 -0
- package/src/index.ts +96 -0
- package/src/library/folder-tree.test.ts +47 -0
- package/src/library/folder-tree.ts +156 -0
- package/src/library/index.ts +46 -0
- package/src/library/library-api.test.ts +32 -0
- package/src/library/library-api.ts +11 -0
- package/src/library/library.ts +61 -0
- package/src/library/oss-api.ts +449 -0
- package/src/library/oss-layout-api.ts +377 -0
- package/src/library/oss-layout.ts +27 -0
- package/src/library/oss.ts +150 -0
- package/src/library/rsengine.ts +593 -0
- package/src/library/rsform-api.ts +533 -0
- package/src/library/rsform.ts +228 -0
- package/src/library/rsmodel-api.ts +340 -0
- package/src/library/rsmodel.ts +50 -0
- package/src/library/structure-planner.ts +143 -0
- package/src/parsing/ast.ts +136 -0
- package/src/parsing/index.ts +15 -0
- package/src/parsing/lezer-tree.ts +69 -0
- package/src/rslang/api.test.ts +116 -0
- package/src/rslang/api.ts +183 -0
- package/src/rslang/ast-annotations.ts +70 -0
- package/src/rslang/error.ts +129 -0
- package/src/rslang/eval/calculator.test.ts +124 -0
- package/src/rslang/eval/calculator.ts +121 -0
- package/src/rslang/eval/evaluation-cache.ts +257 -0
- package/src/rslang/eval/evaluator.test.ts +352 -0
- package/src/rslang/eval/evaluator.ts +935 -0
- package/src/rslang/eval/value-api.test.ts +105 -0
- package/src/rslang/eval/value-api.ts +444 -0
- package/src/rslang/eval/value.ts +102 -0
- package/src/rslang/index.ts +23 -0
- package/src/rslang/labels.ts +191 -0
- package/src/rslang/parser/expression-generator.test.ts +100 -0
- package/src/rslang/parser/expression-generator.ts +466 -0
- package/src/rslang/parser/normalize.test.ts +99 -0
- package/src/rslang/parser/normalize.ts +462 -0
- package/src/rslang/parser/parser.terms.ts +42 -0
- package/src/rslang/parser/parser.test.ts +153 -0
- package/src/rslang/parser/parser.ts +20 -0
- package/src/rslang/parser/rslang.grammar +251 -0
- package/src/rslang/parser/syntax-errors.ts +209 -0
- package/src/rslang/parser/token.ts +106 -0
- package/src/rslang/semantic/analyzer.test.ts +59 -0
- package/src/rslang/semantic/analyzer.ts +179 -0
- package/src/rslang/semantic/arguments-extractor.ts +327 -0
- package/src/rslang/semantic/type-auditor.test.ts +326 -0
- package/src/rslang/semantic/type-auditor.ts +1049 -0
- package/src/rslang/semantic/typification-api.test.ts +46 -0
- package/src/rslang/semantic/typification-api.ts +321 -0
- package/src/rslang/semantic/typification-parser.test.ts +50 -0
- package/src/rslang/semantic/typification-parser.ts +220 -0
- package/src/rslang/semantic/typification.ts +180 -0
- package/src/rslang/semantic/value-auditor.test.ts +206 -0
- package/src/rslang/semantic/value-auditor.ts +332 -0
- package/src/rslang/semantic/value-class.ts +11 -0
- package/src/rslang/typification-graph.ts +155 -0
- package/src/shared/branded.ts +6 -0
- package/src/shared/hash.ts +17 -0
- package/src/shared/index.ts +2 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
// src/graph/graph.ts
|
|
2
|
+
var GraphNode = class _GraphNode {
|
|
3
|
+
/** Unique identifier of the node. */
|
|
4
|
+
id;
|
|
5
|
+
/** List of outgoing nodes. */
|
|
6
|
+
outputs;
|
|
7
|
+
/** List of incoming nodes. */
|
|
8
|
+
inputs;
|
|
9
|
+
constructor(id) {
|
|
10
|
+
this.id = id;
|
|
11
|
+
this.outputs = [];
|
|
12
|
+
this.inputs = [];
|
|
13
|
+
}
|
|
14
|
+
clone() {
|
|
15
|
+
const result = new _GraphNode(this.id);
|
|
16
|
+
result.outputs = [...this.outputs];
|
|
17
|
+
result.inputs = [...this.inputs];
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
addOutput(node) {
|
|
21
|
+
this.outputs.push(node);
|
|
22
|
+
}
|
|
23
|
+
addInput(node) {
|
|
24
|
+
this.inputs.push(node);
|
|
25
|
+
}
|
|
26
|
+
removeInput(target) {
|
|
27
|
+
const index = this.inputs.findIndex((node) => node === target);
|
|
28
|
+
return index > -1 ? this.inputs.splice(index, 1)[0] : null;
|
|
29
|
+
}
|
|
30
|
+
removeOutput(target) {
|
|
31
|
+
const index = this.outputs.findIndex((node) => node === target);
|
|
32
|
+
return index > -1 ? this.outputs.splice(index, 1)[0] : null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var Graph = class _Graph {
|
|
36
|
+
/** Map of nodes. */
|
|
37
|
+
nodes = /* @__PURE__ */ new Map();
|
|
38
|
+
constructor(arr) {
|
|
39
|
+
if (!arr) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
arr.forEach((edge) => {
|
|
43
|
+
if (edge.length === 1) {
|
|
44
|
+
this.addNode(edge[0]);
|
|
45
|
+
} else {
|
|
46
|
+
this.addEdge(edge[0], edge[1]);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
clone() {
|
|
51
|
+
const result = new _Graph();
|
|
52
|
+
this.nodes.forEach((node) => result.nodes.set(node.id, node.clone()));
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
at(target) {
|
|
56
|
+
return this.nodes.get(target);
|
|
57
|
+
}
|
|
58
|
+
addNode(target) {
|
|
59
|
+
let node = this.nodes.get(target);
|
|
60
|
+
if (!node) {
|
|
61
|
+
node = new GraphNode(target);
|
|
62
|
+
this.nodes.set(target, node);
|
|
63
|
+
}
|
|
64
|
+
return node;
|
|
65
|
+
}
|
|
66
|
+
hasNode(target) {
|
|
67
|
+
return !!this.nodes.get(target);
|
|
68
|
+
}
|
|
69
|
+
removeNode(target) {
|
|
70
|
+
this.nodes.forEach((node) => {
|
|
71
|
+
node.removeInput(target);
|
|
72
|
+
node.removeOutput(target);
|
|
73
|
+
});
|
|
74
|
+
this.nodes.delete(target);
|
|
75
|
+
}
|
|
76
|
+
foldNode(target) {
|
|
77
|
+
const nodeToRemove = this.nodes.get(target);
|
|
78
|
+
if (!nodeToRemove) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
nodeToRemove.inputs.forEach((input) => {
|
|
82
|
+
nodeToRemove.outputs.forEach((output) => {
|
|
83
|
+
this.addEdge(input, output);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
this.removeNode(target);
|
|
87
|
+
}
|
|
88
|
+
removeIsolated() {
|
|
89
|
+
const result = [];
|
|
90
|
+
this.nodes.forEach((node) => {
|
|
91
|
+
if (node.outputs.length === 0 && node.inputs.length === 0) {
|
|
92
|
+
result.push(node);
|
|
93
|
+
this.nodes.delete(node.id);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
addEdge(source, destination) {
|
|
99
|
+
if (this.hasEdge(source, destination)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const sourceNode = this.addNode(source);
|
|
103
|
+
const destinationNode = this.addNode(destination);
|
|
104
|
+
sourceNode.addOutput(destinationNode.id);
|
|
105
|
+
destinationNode.addInput(sourceNode.id);
|
|
106
|
+
}
|
|
107
|
+
removeEdge(source, destination) {
|
|
108
|
+
const sourceNode = this.nodes.get(source);
|
|
109
|
+
const destinationNode = this.nodes.get(destination);
|
|
110
|
+
if (sourceNode && destinationNode) {
|
|
111
|
+
sourceNode.removeOutput(destination);
|
|
112
|
+
destinationNode.removeInput(source);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
hasEdge(source, destination) {
|
|
116
|
+
const sourceNode = this.nodes.get(source);
|
|
117
|
+
if (!sourceNode) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return !!sourceNode.outputs.find((id) => id === destination);
|
|
121
|
+
}
|
|
122
|
+
isReachable(source, destination) {
|
|
123
|
+
return this.expandAllOutputs([source]).includes(destination);
|
|
124
|
+
}
|
|
125
|
+
rootNodes() {
|
|
126
|
+
return [...this.nodes.keys()].filter((id) => !this.nodes.get(id)?.inputs.length);
|
|
127
|
+
}
|
|
128
|
+
expandOutputs(origin) {
|
|
129
|
+
const result = [];
|
|
130
|
+
origin.forEach((id) => {
|
|
131
|
+
const node = this.nodes.get(id);
|
|
132
|
+
if (node) {
|
|
133
|
+
node.outputs.forEach((child) => {
|
|
134
|
+
if (!origin.includes(child) && !result.includes(child)) {
|
|
135
|
+
result.push(child);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
expandInputs(origin) {
|
|
143
|
+
const result = [];
|
|
144
|
+
origin.forEach((id) => {
|
|
145
|
+
const node = this.nodes.get(id);
|
|
146
|
+
if (node) {
|
|
147
|
+
node.inputs.forEach((child) => {
|
|
148
|
+
if (!origin.includes(child) && !result.includes(child)) {
|
|
149
|
+
result.push(child);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
expandAllOutputs(origin) {
|
|
157
|
+
const result = this.expandOutputs(origin);
|
|
158
|
+
if (result.length === 0) {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
const marked = /* @__PURE__ */ new Map();
|
|
162
|
+
origin.forEach((id) => marked.set(id, true));
|
|
163
|
+
let position = 0;
|
|
164
|
+
while (position < result.length) {
|
|
165
|
+
const node = this.nodes.get(result[position]);
|
|
166
|
+
if (node && !marked.get(node.id)) {
|
|
167
|
+
marked.set(node.id, true);
|
|
168
|
+
node.outputs.forEach((child) => {
|
|
169
|
+
if (!marked.get(child) && !result.find((id) => id === child)) {
|
|
170
|
+
result.push(child);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
position += 1;
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
expandAllInputs(origin) {
|
|
179
|
+
const result = this.expandInputs(origin);
|
|
180
|
+
if (result.length === 0) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
const marked = /* @__PURE__ */ new Map();
|
|
184
|
+
origin.forEach((id) => marked.set(id, true));
|
|
185
|
+
let position = 0;
|
|
186
|
+
while (position < result.length) {
|
|
187
|
+
const node = this.nodes.get(result[position]);
|
|
188
|
+
if (node && !marked.get(node.id)) {
|
|
189
|
+
marked.set(node.id, true);
|
|
190
|
+
node.inputs.forEach((child) => {
|
|
191
|
+
if (!marked.get(child) && !result.find((id) => id === child)) {
|
|
192
|
+
result.push(child);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
position += 1;
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
maximizePart(origin) {
|
|
201
|
+
const outputs = this.expandAllOutputs(origin);
|
|
202
|
+
const result = [...origin];
|
|
203
|
+
this.topologicalOrder().filter((id) => outputs.includes(id)).forEach((id) => {
|
|
204
|
+
const node = this.nodes.get(id);
|
|
205
|
+
if (node?.inputs.every((parent) => result.includes(parent))) {
|
|
206
|
+
result.push(id);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
topologicalOrder() {
|
|
212
|
+
const result = [];
|
|
213
|
+
const marked = /* @__PURE__ */ new Set();
|
|
214
|
+
const nodeStack = [];
|
|
215
|
+
this.nodes.forEach((node) => {
|
|
216
|
+
if (marked.has(node.id)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
nodeStack.push(node.id);
|
|
220
|
+
while (nodeStack.length > 0) {
|
|
221
|
+
const item = nodeStack[nodeStack.length - 1];
|
|
222
|
+
if (marked.has(item)) {
|
|
223
|
+
if (!result.find((id) => id === item)) {
|
|
224
|
+
result.push(item);
|
|
225
|
+
}
|
|
226
|
+
nodeStack.pop();
|
|
227
|
+
} else {
|
|
228
|
+
marked.add(item);
|
|
229
|
+
const itemNode = this.nodes.get(item);
|
|
230
|
+
if (itemNode && itemNode.outputs.length > 0) {
|
|
231
|
+
itemNode.outputs.forEach((child) => {
|
|
232
|
+
if (!marked.has(child)) {
|
|
233
|
+
nodeStack.push(child);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
return result.reverse();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Stably reorders the given node ids so that, for this DAG, no node appears before a transitive
|
|
244
|
+
* successor (edges: source → dependent; {@link GraphNode.outputs} lists dependents).
|
|
245
|
+
*/
|
|
246
|
+
sortStable(target) {
|
|
247
|
+
if (target.length <= 1) {
|
|
248
|
+
return [...target];
|
|
249
|
+
}
|
|
250
|
+
const reachable = this.buildTransitiveClosureForSort();
|
|
251
|
+
const testSet = /* @__PURE__ */ new Set();
|
|
252
|
+
const result = [];
|
|
253
|
+
for (const nodeId of [...target].reverse()) {
|
|
254
|
+
const nodeReachable = reachable.get(nodeId) ?? /* @__PURE__ */ new Set();
|
|
255
|
+
const needMove = testSet.has(nodeId);
|
|
256
|
+
for (const childId of nodeReachable) {
|
|
257
|
+
testSet.add(childId);
|
|
258
|
+
}
|
|
259
|
+
if (!needMove) {
|
|
260
|
+
result.push(nodeId);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
let inserted = false;
|
|
264
|
+
for (let index = 0; index < result.length; index++) {
|
|
265
|
+
const parent = result[index];
|
|
266
|
+
const parentReachable = reachable.get(parent) ?? /* @__PURE__ */ new Set();
|
|
267
|
+
if (nodeReachable.has(parent)) {
|
|
268
|
+
if (parentReachable.has(nodeId)) {
|
|
269
|
+
result.push(nodeId);
|
|
270
|
+
} else {
|
|
271
|
+
result.splice(index, 0, nodeId);
|
|
272
|
+
}
|
|
273
|
+
inserted = true;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (!inserted) {
|
|
278
|
+
result.push(nodeId);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
result.reverse();
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
buildTransitiveClosureForSort() {
|
|
285
|
+
const closure = /* @__PURE__ */ new Map();
|
|
286
|
+
for (const node of this.nodes.values()) {
|
|
287
|
+
closure.set(node.id, new Set(node.outputs));
|
|
288
|
+
}
|
|
289
|
+
const order = this.topologicalOrder();
|
|
290
|
+
for (const nodeId of [...order].reverse()) {
|
|
291
|
+
const node = this.at(nodeId);
|
|
292
|
+
if (!node) {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const nodeClosure = closure.get(nodeId) ?? /* @__PURE__ */ new Set();
|
|
296
|
+
for (const parentId of node.inputs) {
|
|
297
|
+
const parentClosure = closure.get(parentId) ?? /* @__PURE__ */ new Set();
|
|
298
|
+
for (const childId of nodeClosure) {
|
|
299
|
+
parentClosure.add(childId);
|
|
300
|
+
}
|
|
301
|
+
closure.set(parentId, parentClosure);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return closure;
|
|
305
|
+
}
|
|
306
|
+
transitiveReduction() {
|
|
307
|
+
const order = this.topologicalOrder();
|
|
308
|
+
const marked = /* @__PURE__ */ new Map();
|
|
309
|
+
order.forEach((nodeID) => {
|
|
310
|
+
if (marked.get(nodeID)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const stack = [];
|
|
314
|
+
stack.push({ id: nodeID, parents: [] });
|
|
315
|
+
while (stack.length > 0) {
|
|
316
|
+
const item = stack.splice(0, 1)[0];
|
|
317
|
+
const node = this.nodes.get(item.id);
|
|
318
|
+
if (node) {
|
|
319
|
+
node.outputs.forEach((child) => {
|
|
320
|
+
item.parents.forEach((parent) => this.removeEdge(parent, child));
|
|
321
|
+
stack.push({ id: child, parents: [item.id, ...item.parents] });
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
marked.set(item.id, true);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Finds a cycle in the graph.
|
|
330
|
+
*
|
|
331
|
+
* @returns {NodeID[] | null} The cycle if found, otherwise `null`.
|
|
332
|
+
* Uses non-recursive DFS.
|
|
333
|
+
*/
|
|
334
|
+
findCycle() {
|
|
335
|
+
const visited = /* @__PURE__ */ new Set();
|
|
336
|
+
const nodeStack = /* @__PURE__ */ new Set();
|
|
337
|
+
const parents = /* @__PURE__ */ new Map();
|
|
338
|
+
for (const nodeId of this.nodes.keys()) {
|
|
339
|
+
if (visited.has(nodeId)) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
const callStack = [];
|
|
343
|
+
callStack.push({ nodeId, parentId: null });
|
|
344
|
+
while (callStack.length > 0) {
|
|
345
|
+
const { nodeId: nodeId2, parentId } = callStack[callStack.length - 1];
|
|
346
|
+
if (visited.has(nodeId2)) {
|
|
347
|
+
nodeStack.delete(nodeId2);
|
|
348
|
+
callStack.pop();
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
visited.add(nodeId2);
|
|
352
|
+
nodeStack.add(nodeId2);
|
|
353
|
+
if (parentId !== null) {
|
|
354
|
+
parents.set(nodeId2, parentId);
|
|
355
|
+
}
|
|
356
|
+
const currentNode = this.nodes.get(nodeId2);
|
|
357
|
+
for (const child of currentNode.outputs) {
|
|
358
|
+
if (!visited.has(child)) {
|
|
359
|
+
callStack.push({ nodeId: child, parentId: nodeId2 });
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (!nodeStack.has(child)) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const cycle = [];
|
|
366
|
+
let current = nodeId2;
|
|
367
|
+
cycle.push(child);
|
|
368
|
+
while (current !== child) {
|
|
369
|
+
cycle.push(current);
|
|
370
|
+
current = parents.get(current);
|
|
371
|
+
}
|
|
372
|
+
cycle.push(child);
|
|
373
|
+
cycle.reverse();
|
|
374
|
+
return cycle;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
export {
|
|
382
|
+
Graph,
|
|
383
|
+
GraphNode
|
|
384
|
+
};
|
|
385
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/graph/graph.ts"],"sourcesContent":["/**\n * Module: Custom graph data structure.\n */\n\n/** Represents single node of a {@link Graph}, as implemented by storing outgoing and incoming connections. */\nexport class GraphNode<NodeID> {\n /** Unique identifier of the node. */\n id: NodeID;\n /** List of outgoing nodes. */\n outputs: NodeID[];\n /** List of incoming nodes. */\n inputs: NodeID[];\n\n constructor(id: NodeID) {\n this.id = id;\n this.outputs = [];\n this.inputs = [];\n }\n\n clone(): GraphNode<NodeID> {\n const result = new GraphNode(this.id);\n result.outputs = [...this.outputs];\n result.inputs = [...this.inputs];\n return result;\n }\n\n addOutput(node: NodeID): void {\n this.outputs.push(node);\n }\n\n addInput(node: NodeID): void {\n this.inputs.push(node);\n }\n\n removeInput(target: NodeID): NodeID | null {\n const index = this.inputs.findIndex(node => node === target);\n return index > -1 ? this.inputs.splice(index, 1)[0] : null;\n }\n\n removeOutput(target: NodeID): NodeID | null {\n const index = this.outputs.findIndex(node => node === target);\n return index > -1 ? this.outputs.splice(index, 1)[0] : null;\n }\n}\n\n/**\n * Represents a Graph.\n *\n * This class is optimized for TermGraph use case and not supposed to be used as generic graph implementation.\n */\nexport class Graph<NodeID = number> {\n /** Map of nodes. */\n nodes = new Map<NodeID, GraphNode<NodeID>>();\n\n constructor(arr?: NodeID[][]) {\n if (!arr) {\n return;\n }\n arr.forEach(edge => {\n if (edge.length === 1) {\n this.addNode(edge[0]);\n } else {\n this.addEdge(edge[0], edge[1]);\n }\n });\n }\n\n clone(): Graph<NodeID> {\n const result = new Graph<NodeID>();\n this.nodes.forEach(node => result.nodes.set(node.id, node.clone()));\n return result;\n }\n\n at(target: NodeID): GraphNode<NodeID> | undefined {\n return this.nodes.get(target);\n }\n\n addNode(target: NodeID): GraphNode<NodeID> {\n let node = this.nodes.get(target);\n if (!node) {\n node = new GraphNode(target);\n this.nodes.set(target, node);\n }\n return node;\n }\n\n hasNode(target: NodeID): boolean {\n return !!this.nodes.get(target);\n }\n\n removeNode(target: NodeID): void {\n this.nodes.forEach(node => {\n node.removeInput(target);\n node.removeOutput(target);\n });\n this.nodes.delete(target);\n }\n\n foldNode(target: NodeID): void {\n const nodeToRemove = this.nodes.get(target);\n if (!nodeToRemove) {\n return;\n }\n nodeToRemove.inputs.forEach(input => {\n nodeToRemove.outputs.forEach(output => {\n this.addEdge(input, output);\n });\n });\n this.removeNode(target);\n }\n\n removeIsolated(): GraphNode<NodeID>[] {\n const result: GraphNode<NodeID>[] = [];\n this.nodes.forEach(node => {\n if (node.outputs.length === 0 && node.inputs.length === 0) {\n result.push(node);\n this.nodes.delete(node.id);\n }\n });\n return result;\n }\n\n addEdge(source: NodeID, destination: NodeID): void {\n if (this.hasEdge(source, destination)) {\n return;\n }\n const sourceNode = this.addNode(source);\n const destinationNode = this.addNode(destination);\n sourceNode.addOutput(destinationNode.id);\n destinationNode.addInput(sourceNode.id);\n }\n\n removeEdge(source: NodeID, destination: NodeID): void {\n const sourceNode = this.nodes.get(source);\n const destinationNode = this.nodes.get(destination);\n if (sourceNode && destinationNode) {\n sourceNode.removeOutput(destination);\n destinationNode.removeInput(source);\n }\n }\n\n hasEdge(source: NodeID, destination: NodeID): boolean {\n const sourceNode = this.nodes.get(source);\n if (!sourceNode) {\n return false;\n }\n return !!sourceNode.outputs.find(id => id === destination);\n }\n\n isReachable(source: NodeID, destination: NodeID): boolean {\n return this.expandAllOutputs([source]).includes(destination);\n }\n\n rootNodes(): NodeID[] {\n return [...this.nodes.keys()].filter(id => !this.nodes.get(id)?.inputs.length);\n }\n\n expandOutputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = [];\n origin.forEach(id => {\n const node = this.nodes.get(id);\n if (node) {\n node.outputs.forEach(child => {\n if (!origin.includes(child) && !result.includes(child)) {\n result.push(child);\n }\n });\n }\n });\n return result;\n }\n\n expandInputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = [];\n origin.forEach(id => {\n const node = this.nodes.get(id);\n if (node) {\n node.inputs.forEach(child => {\n if (!origin.includes(child) && !result.includes(child)) {\n result.push(child);\n }\n });\n }\n });\n return result;\n }\n\n expandAllOutputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = this.expandOutputs(origin);\n if (result.length === 0) {\n return [];\n }\n\n const marked = new Map<NodeID, boolean>();\n origin.forEach(id => marked.set(id, true));\n let position = 0;\n while (position < result.length) {\n const node = this.nodes.get(result[position]);\n if (node && !marked.get(node.id)) {\n marked.set(node.id, true);\n node.outputs.forEach(child => {\n if (!marked.get(child) && !result.find(id => id === child)) {\n result.push(child);\n }\n });\n }\n position += 1;\n }\n return result;\n }\n\n expandAllInputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = this.expandInputs(origin);\n if (result.length === 0) {\n return [];\n }\n\n const marked = new Map<NodeID, boolean>();\n origin.forEach(id => marked.set(id, true));\n let position = 0;\n while (position < result.length) {\n const node = this.nodes.get(result[position]);\n if (node && !marked.get(node.id)) {\n marked.set(node.id, true);\n node.inputs.forEach(child => {\n if (!marked.get(child) && !result.find(id => id === child)) {\n result.push(child);\n }\n });\n }\n position += 1;\n }\n return result;\n }\n\n maximizePart(origin: NodeID[]): NodeID[] {\n const outputs: NodeID[] = this.expandAllOutputs(origin);\n const result = [...origin];\n this.topologicalOrder()\n .filter(id => outputs.includes(id))\n .forEach(id => {\n const node = this.nodes.get(id);\n if (node?.inputs.every(parent => result.includes(parent))) {\n result.push(id);\n }\n });\n return result;\n }\n\n topologicalOrder(): NodeID[] {\n const result: NodeID[] = [];\n const marked = new Set<NodeID>();\n const nodeStack: NodeID[] = [];\n this.nodes.forEach(node => {\n if (marked.has(node.id)) {\n return;\n }\n nodeStack.push(node.id);\n while (nodeStack.length > 0) {\n const item = nodeStack[nodeStack.length - 1];\n if (marked.has(item)) {\n if (!result.find(id => id === item)) {\n result.push(item);\n }\n nodeStack.pop();\n } else {\n marked.add(item);\n const itemNode = this.nodes.get(item);\n if (itemNode && itemNode.outputs.length > 0) {\n itemNode.outputs.forEach(child => {\n if (!marked.has(child)) {\n nodeStack.push(child);\n }\n });\n }\n }\n }\n });\n return result.reverse();\n }\n\n /**\n * Stably reorders the given node ids so that, for this DAG, no node appears before a transitive\n * successor (edges: source → dependent; {@link GraphNode.outputs} lists dependents).\n */\n sortStable(target: NodeID[]): NodeID[] {\n if (target.length <= 1) {\n return [...target];\n }\n\n const reachable = this.buildTransitiveClosureForSort();\n const testSet = new Set<NodeID>();\n const result: NodeID[] = [];\n\n for (const nodeId of [...target].reverse()) {\n const nodeReachable = reachable.get(nodeId) ?? new Set<NodeID>();\n const needMove = testSet.has(nodeId);\n for (const childId of nodeReachable) {\n testSet.add(childId);\n }\n\n if (!needMove) {\n result.push(nodeId);\n continue;\n }\n\n let inserted = false;\n for (let index = 0; index < result.length; index++) {\n const parent = result[index];\n const parentReachable = reachable.get(parent) ?? new Set<NodeID>();\n if (nodeReachable.has(parent)) {\n if (parentReachable.has(nodeId)) {\n result.push(nodeId);\n } else {\n result.splice(index, 0, nodeId);\n }\n inserted = true;\n break;\n }\n }\n if (!inserted) {\n result.push(nodeId);\n }\n }\n\n result.reverse();\n return result;\n }\n\n private buildTransitiveClosureForSort(): Map<NodeID, Set<NodeID>> {\n const closure = new Map<NodeID, Set<NodeID>>();\n for (const node of this.nodes.values()) {\n closure.set(node.id, new Set(node.outputs));\n }\n\n const order = this.topologicalOrder();\n for (const nodeId of [...order].reverse()) {\n const node = this.at(nodeId);\n if (!node) {\n continue;\n }\n const nodeClosure = closure.get(nodeId) ?? new Set<NodeID>();\n for (const parentId of node.inputs) {\n const parentClosure = closure.get(parentId) ?? new Set<NodeID>();\n for (const childId of nodeClosure) {\n parentClosure.add(childId);\n }\n closure.set(parentId, parentClosure);\n }\n }\n\n return closure;\n }\n\n transitiveReduction() {\n const order = this.topologicalOrder();\n const marked = new Map<NodeID, boolean>();\n order.forEach(nodeID => {\n if (marked.get(nodeID)) {\n return;\n }\n const stack: { id: NodeID; parents: NodeID[] }[] = [];\n stack.push({ id: nodeID, parents: [] });\n while (stack.length > 0) {\n const item = stack.splice(0, 1)[0];\n const node = this.nodes.get(item.id);\n if (node) {\n node.outputs.forEach(child => {\n item.parents.forEach(parent => this.removeEdge(parent, child));\n stack.push({ id: child, parents: [item.id, ...item.parents] });\n });\n }\n marked.set(item.id, true);\n }\n });\n }\n\n /**\n * Finds a cycle in the graph.\n *\n * @returns {NodeID[] | null} The cycle if found, otherwise `null`.\n * Uses non-recursive DFS.\n */\n findCycle(): NodeID[] | null {\n const visited = new Set<NodeID>();\n const nodeStack = new Set<NodeID>();\n const parents = new Map<NodeID, NodeID>();\n\n for (const nodeId of this.nodes.keys()) {\n if (visited.has(nodeId)) {\n continue;\n }\n\n const callStack: { nodeId: NodeID; parentId: NodeID | null }[] = [];\n callStack.push({ nodeId: nodeId, parentId: null });\n while (callStack.length > 0) {\n const { nodeId, parentId } = callStack[callStack.length - 1];\n if (visited.has(nodeId)) {\n nodeStack.delete(nodeId);\n callStack.pop();\n continue;\n }\n visited.add(nodeId);\n nodeStack.add(nodeId);\n if (parentId !== null) {\n parents.set(nodeId, parentId);\n }\n\n const currentNode = this.nodes.get(nodeId)!;\n for (const child of currentNode.outputs) {\n if (!visited.has(child)) {\n callStack.push({ nodeId: child, parentId: nodeId });\n continue;\n }\n if (!nodeStack.has(child)) {\n continue;\n }\n const cycle: NodeID[] = [];\n let current = nodeId;\n cycle.push(child);\n while (current !== child) {\n cycle.push(current);\n current = parents.get(current)!;\n }\n cycle.push(child);\n cycle.reverse();\n return cycle;\n }\n }\n }\n return null;\n }\n}\n"],"mappings":";AAKO,IAAM,YAAN,MAAM,WAAkB;AAAA;AAAA,EAE7B;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEA,YAAY,IAAY;AACtB,SAAK,KAAK;AACV,SAAK,UAAU,CAAC;AAChB,SAAK,SAAS,CAAC;AAAA,EACjB;AAAA,EAEA,QAA2B;AACzB,UAAM,SAAS,IAAI,WAAU,KAAK,EAAE;AACpC,WAAO,UAAU,CAAC,GAAG,KAAK,OAAO;AACjC,WAAO,SAAS,CAAC,GAAG,KAAK,MAAM;AAC/B,WAAO;AAAA,EACT;AAAA,EAEA,UAAU,MAAoB;AAC5B,SAAK,QAAQ,KAAK,IAAI;AAAA,EACxB;AAAA,EAEA,SAAS,MAAoB;AAC3B,SAAK,OAAO,KAAK,IAAI;AAAA,EACvB;AAAA,EAEA,YAAY,QAA+B;AACzC,UAA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