@hpcc-js/graph 3.1.1 → 3.2.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/dist/assets/dagre-D0bY8RPD.js.map +1 -0
- package/dist/assets/graphviz-CMhlTALo.js.map +1 -0
- package/dist/index.js +9822 -191
- package/dist/index.js.map +1 -7
- package/dist/index.umd.cjs +8 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +20 -16
- package/src/GraphData.ts +1 -1
- package/src/GraphLayouts.ts +1 -1
- package/src/graph2/layouts/dagreWorker.ts +8 -48
- package/src/graph2/layouts/forceDirectedWorker.ts +7 -43
- package/src/graph2/layouts/graphvizWorker.ts +13 -77
- package/src/graph2/layouts/workers/dagre.ts +46 -0
- package/src/graph2/layouts/workers/dagreOptions.ts +35 -0
- package/src/graph2/layouts/workers/forceDirected.ts +38 -0
- package/src/graph2/layouts/workers/forceDirectedOptions.ts +30 -0
- package/src/graph2/layouts/workers/graphviz.ts +225 -0
- package/src/graph2/layouts/workers/graphvizOptions.ts +70 -0
- package/types/GraphData.d.ts +1 -1
- package/types/graph2/graphT.d.ts +1 -1
- package/types/graph2/layouts/dagreWorker.d.ts +3 -31
- package/types/graph2/layouts/forceDirectedWorker.d.ts +3 -28
- package/types/graph2/layouts/graphvizWorker.d.ts +3 -52
- package/types/graph2/layouts/workers/dagreOptions.d.ts +30 -0
- package/types/graph2/layouts/workers/forceDirectedOptions.d.ts +27 -0
- package/types/graph2/layouts/workers/graphvizOptions.d.ts +51 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GraphLabel, graphlib, layout } from "dagre";
|
|
2
|
+
import { Data, Options } from "./dagreOptions.js";
|
|
3
|
+
|
|
4
|
+
function dagre(data: Data, options: Options) {
|
|
5
|
+
const subgraphs = data.subgraphs;
|
|
6
|
+
const nodes = data.nodes;
|
|
7
|
+
const links = data.links;
|
|
8
|
+
const hierarchy = data.hierarchy;
|
|
9
|
+
|
|
10
|
+
const digraph = new graphlib.Graph({ multigraph: true, compound: true, directed: options.digraph !== false })
|
|
11
|
+
.setGraph(options)
|
|
12
|
+
.setDefaultNodeLabel(function () { return {}; })
|
|
13
|
+
.setDefaultEdgeLabel(function () { return {}; })
|
|
14
|
+
;
|
|
15
|
+
subgraphs.forEach(sp => {
|
|
16
|
+
digraph.setNode(sp.id, sp);
|
|
17
|
+
});
|
|
18
|
+
nodes.forEach(vp => {
|
|
19
|
+
digraph.setNode(vp.id, vp);
|
|
20
|
+
});
|
|
21
|
+
links.forEach(ep => {
|
|
22
|
+
digraph.setEdge(ep.source.id, ep.target.id, ep, ep.id);
|
|
23
|
+
});
|
|
24
|
+
hierarchy.forEach(h => {
|
|
25
|
+
digraph.setParent(h.child, h.parent);
|
|
26
|
+
});
|
|
27
|
+
layout(digraph, { debugTiming: false } as GraphLabel);
|
|
28
|
+
const deltaX = (-digraph.graph().width / 2) || 0;
|
|
29
|
+
const deltaY = -digraph.graph().height / 2;
|
|
30
|
+
digraph.nodes().forEach(function (u) {
|
|
31
|
+
const vp = digraph.node(u) as any;
|
|
32
|
+
vp.x += deltaX;
|
|
33
|
+
vp.y += deltaY;
|
|
34
|
+
});
|
|
35
|
+
digraph.edges().forEach(function (e) {
|
|
36
|
+
const ep = digraph.edge(e) as any;
|
|
37
|
+
ep.points = ep.points.map(p => [p.x + deltaX, p.y + deltaY]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return { subgraphs, nodes, links };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
self.onmessage = event => {
|
|
44
|
+
const result = dagre.apply(undefined, event.data);
|
|
45
|
+
self.postMessage(result);
|
|
46
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface Subgraph {
|
|
2
|
+
id: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface Node {
|
|
7
|
+
id: string;
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Link {
|
|
12
|
+
id: string;
|
|
13
|
+
source: Node;
|
|
14
|
+
target: Node;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface Hierarchy {
|
|
18
|
+
parent: string;
|
|
19
|
+
child: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Data {
|
|
23
|
+
subgraphs: Subgraph[];
|
|
24
|
+
nodes: Node[];
|
|
25
|
+
links: Link[];
|
|
26
|
+
hierarchy: Hierarchy[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Options {
|
|
30
|
+
rankdir: "TB" | "BT" | "LR" | "RL";
|
|
31
|
+
nodesep: number;
|
|
32
|
+
edgesep: number;
|
|
33
|
+
ranksep: number;
|
|
34
|
+
digraph: boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { forceCenter, forceLink as d3ForceLink, forceManyBody as d3ForceManyBody, forceSimulation } from "d3-force";
|
|
2
|
+
import "es6-promise/auto";
|
|
3
|
+
import { Data, Options } from "./forceDirectedOptions.js";
|
|
4
|
+
|
|
5
|
+
export function forceDirected(data: Data, options: Options) {
|
|
6
|
+
const nodes = data.nodes;
|
|
7
|
+
const links = data.links;
|
|
8
|
+
|
|
9
|
+
const forceLink = d3ForceLink(links)
|
|
10
|
+
.id(d => d.id)
|
|
11
|
+
.distance(options.linkDistance)
|
|
12
|
+
.strength(options.linkStrength)
|
|
13
|
+
;
|
|
14
|
+
|
|
15
|
+
const forceManyBody = d3ForceManyBody()
|
|
16
|
+
.strength(options.repulsionStrength)
|
|
17
|
+
;
|
|
18
|
+
|
|
19
|
+
forceSimulation(nodes)
|
|
20
|
+
.force("link", forceLink)
|
|
21
|
+
.force("charge", forceManyBody)
|
|
22
|
+
.force("center", forceCenter())
|
|
23
|
+
.alpha(options.alpha)
|
|
24
|
+
.alphaMin(options.alphaMin)
|
|
25
|
+
.alphaDecay(options.alphaDecay)
|
|
26
|
+
.velocityDecay(options.velocityDecay)
|
|
27
|
+
.stop()
|
|
28
|
+
.tick(options.iterations)
|
|
29
|
+
;
|
|
30
|
+
|
|
31
|
+
return { nodes, links };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
self.onmessage = event => {
|
|
35
|
+
const result = forceDirected.apply(undefined, event.data);
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
self.postMessage(result);
|
|
38
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface Node {
|
|
2
|
+
id: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface Link {
|
|
7
|
+
id: string;
|
|
8
|
+
source: Node;
|
|
9
|
+
target: Node;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Data {
|
|
13
|
+
nodes: Node[];
|
|
14
|
+
links: Link[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface Options {
|
|
18
|
+
alpha: number;
|
|
19
|
+
alphaMin: number;
|
|
20
|
+
alphaDecay: number;
|
|
21
|
+
velocityDecay: number;
|
|
22
|
+
repulsionStrength: number;
|
|
23
|
+
linkDistance: number;
|
|
24
|
+
linkStrength: number;
|
|
25
|
+
iterations: number;
|
|
26
|
+
pinCentroid: boolean;
|
|
27
|
+
forceStrength: number;
|
|
28
|
+
distanceMin: number;
|
|
29
|
+
distanceMax: number;
|
|
30
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Graphviz } from "@hpcc-js/wasm-graphviz";
|
|
2
|
+
import { Cluster, Data, Engine, isCluster, Layout, LayoutJSON, LayoutSVG, Link, Node, Options } from "./graphvizOptions.js";
|
|
3
|
+
|
|
4
|
+
const clusterTpl = (cluster: Cluster): string => {
|
|
5
|
+
const childTpls: string[] = [];
|
|
6
|
+
cluster.children.forEach(child => {
|
|
7
|
+
if (isCluster(child)) {
|
|
8
|
+
childTpls.push(clusterTpl(child));
|
|
9
|
+
} else {
|
|
10
|
+
childTpls.push(nodeTpl(child));
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return `subgraph cluster_${cluster.id} {
|
|
14
|
+
id="${cluster.id}";
|
|
15
|
+
label="${cluster.text}";
|
|
16
|
+
margin=16;
|
|
17
|
+
${childTpls.join("\n")}
|
|
18
|
+
}`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const nodeTpl = (vc: Node): string => `${vc.id} [id="${vc.id}" label="${vc.text}" width=${pxToInch(vc.width)} height=${pxToInch(vc.height)}]`;
|
|
22
|
+
|
|
23
|
+
const linkTpl = (s, t, id, label) => `${s} -> ${t} [id="${id}", label="${label}"]`;
|
|
24
|
+
|
|
25
|
+
type GVPos = {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type GVBox = {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const pointToPx = (pt: number) => pt * 96 / 72;
|
|
38
|
+
const inchToPx = (inch: number) => inch * 96;
|
|
39
|
+
const pxToInch = (inch: number) => inch / 96;
|
|
40
|
+
|
|
41
|
+
function parseBB(bb?: string): GVBox {
|
|
42
|
+
const [llx, lly, urx, ury] = bb ? bb.split(",").map(p => pointToPx(+p)) : [0, 0, 0, 0];
|
|
43
|
+
const width = urx - llx;
|
|
44
|
+
const height = ury - lly;
|
|
45
|
+
return {
|
|
46
|
+
x: llx - width / 2,
|
|
47
|
+
y: lly - height / 2,
|
|
48
|
+
width,
|
|
49
|
+
height
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function parseBB2(_bb: string, page: GVBox): GVBox {
|
|
54
|
+
const bb = parseBB(_bb);
|
|
55
|
+
return {
|
|
56
|
+
x: -bb.x + page.width,
|
|
57
|
+
y: -bb.y + page.height,
|
|
58
|
+
width: bb.width,
|
|
59
|
+
height: bb.height
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function parsePos(pos: string, page: GVBox): GVPos {
|
|
64
|
+
const [x, y] = pos.split(",").map(p => pointToPx(+p));
|
|
65
|
+
return {
|
|
66
|
+
x: -x + page.width,
|
|
67
|
+
y: -y + page.height
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function parseNode(posStr: string, width: string, height: string, page: GVBox): GVBox {
|
|
72
|
+
const cpos = parsePos(posStr, page);
|
|
73
|
+
const w = inchToPx(+width);
|
|
74
|
+
const h = inchToPx(+height);
|
|
75
|
+
return {
|
|
76
|
+
x: cpos.x,
|
|
77
|
+
y: cpos.y,
|
|
78
|
+
width: w,
|
|
79
|
+
height: h
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function parseLink(l: any, page: GVBox) {
|
|
84
|
+
if (l.pos) {
|
|
85
|
+
const posStr = l.pos.substr(2);
|
|
86
|
+
const posParts = posStr.split(" ");
|
|
87
|
+
const points: Array<[number, number]> = posParts.map(p => parsePos(p, page)).map(pos => [pos.x - page.width / 2, pos.y - page.height / 2]);
|
|
88
|
+
const endpoint = points.shift();
|
|
89
|
+
return [...points, endpoint];
|
|
90
|
+
}
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function doLayoutSVG(mode: Engine, dot: string): Promise<LayoutSVG> {
|
|
95
|
+
const graphviz = await Graphviz.load();
|
|
96
|
+
try {
|
|
97
|
+
return {
|
|
98
|
+
svg: graphviz.layout(dot, "svg", mode)
|
|
99
|
+
};
|
|
100
|
+
} catch (e: any) {
|
|
101
|
+
if (e instanceof Error) {
|
|
102
|
+
return {
|
|
103
|
+
error: e.message,
|
|
104
|
+
errorDot: dot
|
|
105
|
+
};
|
|
106
|
+
} else {
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function doLayoutJSON(mode: Engine, dot: string): Promise<LayoutJSON> {
|
|
113
|
+
const graphviz = await Graphviz.load();
|
|
114
|
+
try {
|
|
115
|
+
return {
|
|
116
|
+
json: JSON.parse(graphviz.layout(dot, "json", mode))
|
|
117
|
+
};
|
|
118
|
+
} catch (e: any) {
|
|
119
|
+
if (e instanceof Error) {
|
|
120
|
+
return {
|
|
121
|
+
error: e.message,
|
|
122
|
+
errorDot: dot
|
|
123
|
+
};
|
|
124
|
+
} else {
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function graphvizLayout(data: Data, options: Options): Promise<Layout> {
|
|
131
|
+
if (data.raw) {
|
|
132
|
+
return doLayoutSVG(options.engine, data.raw);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const clusterIdx: { [id: string]: Cluster } = {};
|
|
136
|
+
const clusters: Cluster[] = [];
|
|
137
|
+
const dotClusters: string[] = [];
|
|
138
|
+
|
|
139
|
+
const nodeIdx: { [id: string]: Node } = {};
|
|
140
|
+
const nodes: Node[] = [];
|
|
141
|
+
const dotNodes: string[] = [];
|
|
142
|
+
|
|
143
|
+
const linkIdx: { [id: string]: Link } = {};
|
|
144
|
+
const links: Link[] = [];
|
|
145
|
+
const dotLinks: string[] = [];
|
|
146
|
+
|
|
147
|
+
function walk(item: Cluster | Node, top: boolean) {
|
|
148
|
+
if (isCluster(item)) {
|
|
149
|
+
clusterIdx[item.id] = item;
|
|
150
|
+
clusters.push(item);
|
|
151
|
+
item.children.forEach(child => walk(child, false));
|
|
152
|
+
if (top) {
|
|
153
|
+
dotClusters.push(clusterTpl(item));
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
nodeIdx[item.id] = item;
|
|
157
|
+
nodes.push(item);
|
|
158
|
+
if (top) {
|
|
159
|
+
dotNodes.push(nodeTpl(item));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
data.items.forEach(item => walk(item, true));
|
|
164
|
+
|
|
165
|
+
data.links.forEach(link => {
|
|
166
|
+
linkIdx[link.id] = link;
|
|
167
|
+
links.push(link);
|
|
168
|
+
dotLinks.push(linkTpl(link.source.id, link.target.id, link.id, link.text));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return doLayoutJSON(options.engine, `\
|
|
172
|
+
digraph G {
|
|
173
|
+
graph [fontname=Verdana,fontsize=11.0];
|
|
174
|
+
graph [rankdir=TB];
|
|
175
|
+
node [shape=rect,fontname=Verdana,fontsize=11.0,fixedsize=true];
|
|
176
|
+
edge [fontname=Verdana,fontsize=11.0];
|
|
177
|
+
|
|
178
|
+
${dotClusters.join("\n")}
|
|
179
|
+
|
|
180
|
+
${dotLinks.join("\n")}
|
|
181
|
+
|
|
182
|
+
${dotNodes.join("\n")}
|
|
183
|
+
}`).then(response => {
|
|
184
|
+
if (response.json) {
|
|
185
|
+
const pageBBox = parseBB(response.json.bb);
|
|
186
|
+
|
|
187
|
+
if (response.json.objects) {
|
|
188
|
+
response.json.objects.forEach(n => {
|
|
189
|
+
if (n.nodes) {
|
|
190
|
+
const bb = parseBB2(n.bb, pageBBox);
|
|
191
|
+
const c = clusterIdx[n.id];
|
|
192
|
+
c.x = bb.x - pageBBox.width / 2;
|
|
193
|
+
c.y = bb.y - pageBBox.height / 2;
|
|
194
|
+
c.width = bb.width;
|
|
195
|
+
c.height = bb.height;
|
|
196
|
+
} else {
|
|
197
|
+
const pos = parseNode(n.pos, n.width, n.height, pageBBox);
|
|
198
|
+
const v = nodeIdx[n.id];
|
|
199
|
+
if (v) {
|
|
200
|
+
v.x = pos.x - pageBBox.width / 2;
|
|
201
|
+
v.y = pos.y - pageBBox.height / 2;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (response.json.edges) {
|
|
207
|
+
response.json.edges.forEach(l => {
|
|
208
|
+
const e = linkIdx[l.id];
|
|
209
|
+
if (e) {
|
|
210
|
+
e.points = parseLink(l, pageBBox);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return { clusters, nodes, links };
|
|
215
|
+
} else {
|
|
216
|
+
return response;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
self.onmessage = event => {
|
|
222
|
+
graphvizLayout.apply(undefined, event.data).then(result => {
|
|
223
|
+
self.postMessage(result);
|
|
224
|
+
});
|
|
225
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type Engine = "circo" | "dot" | "fdp" | "neato" | "osage" | "patchwork" | "twopi";
|
|
2
|
+
|
|
3
|
+
export interface Cluster {
|
|
4
|
+
id: string;
|
|
5
|
+
text: string;
|
|
6
|
+
children: Array<Cluster | Node>;
|
|
7
|
+
|
|
8
|
+
// result ---
|
|
9
|
+
x?: number;
|
|
10
|
+
y?: number;
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Node {
|
|
16
|
+
id: string;
|
|
17
|
+
text: string;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
|
|
21
|
+
// result ---
|
|
22
|
+
x?: number;
|
|
23
|
+
y?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isCluster(item: Cluster | Node): item is Cluster {
|
|
27
|
+
return (item as Cluster).children !== undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Link {
|
|
31
|
+
id: string;
|
|
32
|
+
source: Node;
|
|
33
|
+
target: Node;
|
|
34
|
+
text: string;
|
|
35
|
+
|
|
36
|
+
// result ---
|
|
37
|
+
points?: Array<[number, number]>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Data {
|
|
41
|
+
items: Array<Cluster | Node>;
|
|
42
|
+
links: Link[];
|
|
43
|
+
raw: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface Options {
|
|
47
|
+
engine: Engine;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface LayoutError {
|
|
51
|
+
error?: string;
|
|
52
|
+
errorDot?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface LayoutSVG extends LayoutError {
|
|
56
|
+
svg?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface LayoutJSON extends LayoutError {
|
|
60
|
+
json?: any;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type LayoutSuccess = { clusters: Cluster[], nodes: Node[], links: Link[] };
|
|
64
|
+
export type Layout = LayoutSuccess | LayoutJSON | LayoutSVG;
|
|
65
|
+
|
|
66
|
+
export function isLayoutSuccess(item: any): item is LayoutSuccess {
|
|
67
|
+
return (item as LayoutSuccess)?.clusters !== undefined &&
|
|
68
|
+
(item as LayoutSuccess)?.nodes !== undefined &&
|
|
69
|
+
(item as LayoutSuccess)?.links !== undefined;
|
|
70
|
+
}
|
package/types/GraphData.d.ts
CHANGED
package/types/graph2/graphT.d.ts
CHANGED
|
@@ -228,6 +228,6 @@ export interface GraphT<SG extends SubgraphBaseProps = any, V extends VertexBase
|
|
|
228
228
|
wasmFolder(_: string): this;
|
|
229
229
|
}
|
|
230
230
|
export declare function graphviz(dot: string, engine?: Engine, _scriptDir?: string): {
|
|
231
|
-
terminate: () =>
|
|
231
|
+
terminate: () => any;
|
|
232
232
|
response: Promise<string>;
|
|
233
233
|
};
|
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
text: string;
|
|
4
|
-
}
|
|
5
|
-
export interface Node {
|
|
6
|
-
id: string;
|
|
7
|
-
text: string;
|
|
8
|
-
}
|
|
9
|
-
export interface Link {
|
|
10
|
-
id: string;
|
|
11
|
-
source: Node;
|
|
12
|
-
target: Node;
|
|
13
|
-
}
|
|
14
|
-
export interface Hierarchy {
|
|
15
|
-
parent: string;
|
|
16
|
-
child: string;
|
|
17
|
-
}
|
|
18
|
-
export interface Data {
|
|
19
|
-
subgraphs: Subgraph[];
|
|
20
|
-
nodes: Node[];
|
|
21
|
-
links: Link[];
|
|
22
|
-
hierarchy: Hierarchy[];
|
|
23
|
-
}
|
|
24
|
-
export interface Options {
|
|
25
|
-
rankdir: "TB" | "BT" | "LR" | "RL";
|
|
26
|
-
nodesep: number;
|
|
27
|
-
edgesep: number;
|
|
28
|
-
ranksep: number;
|
|
29
|
-
digraph: boolean;
|
|
30
|
-
}
|
|
1
|
+
import { Data, type Hierarchy, type Options } from "./workers/dagreOptions.ts";
|
|
2
|
+
export { type Hierarchy, type Options };
|
|
31
3
|
export declare function dagre(data: Data, options: Options): {
|
|
32
|
-
terminate: () =>
|
|
4
|
+
terminate: () => any;
|
|
33
5
|
response: Promise<string>;
|
|
34
6
|
};
|
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
text: string;
|
|
4
|
-
}
|
|
5
|
-
export interface Link {
|
|
6
|
-
id: string;
|
|
7
|
-
source: Node;
|
|
8
|
-
target: Node;
|
|
9
|
-
}
|
|
10
|
-
export interface Data {
|
|
11
|
-
nodes: Node[];
|
|
12
|
-
links: Link[];
|
|
13
|
-
}
|
|
14
|
-
export interface Options {
|
|
15
|
-
alpha: number;
|
|
16
|
-
alphaMin: number;
|
|
17
|
-
alphaDecay: number;
|
|
18
|
-
velocityDecay: number;
|
|
19
|
-
repulsionStrength: number;
|
|
20
|
-
linkDistance: number;
|
|
21
|
-
linkStrength: number;
|
|
22
|
-
iterations: number;
|
|
23
|
-
pinCentroid: boolean;
|
|
24
|
-
forceStrength: number;
|
|
25
|
-
distanceMin: number;
|
|
26
|
-
distanceMax: number;
|
|
27
|
-
}
|
|
1
|
+
import { type Data, type Options } from "./workers/forceDirectedOptions.ts";
|
|
2
|
+
export { type Options };
|
|
28
3
|
export declare function forceDirected(data: Data, options: Options): {
|
|
29
|
-
terminate: () =>
|
|
4
|
+
terminate: () => any;
|
|
30
5
|
response: Promise<string>;
|
|
31
6
|
};
|
|
@@ -1,55 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
id: string;
|
|
4
|
-
text: string;
|
|
5
|
-
children: Array<Cluster | Node>;
|
|
6
|
-
x?: number;
|
|
7
|
-
y?: number;
|
|
8
|
-
width?: number;
|
|
9
|
-
height?: number;
|
|
10
|
-
}
|
|
11
|
-
export interface Node {
|
|
12
|
-
id: string;
|
|
13
|
-
text: string;
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
x?: number;
|
|
17
|
-
y?: number;
|
|
18
|
-
}
|
|
19
|
-
export declare function isCluster(item: Cluster | Node): item is Cluster;
|
|
20
|
-
export interface Link {
|
|
21
|
-
id: string;
|
|
22
|
-
source: Node;
|
|
23
|
-
target: Node;
|
|
24
|
-
text: string;
|
|
25
|
-
points?: Array<[number, number]>;
|
|
26
|
-
}
|
|
27
|
-
export interface Data {
|
|
28
|
-
items: Array<Cluster | Node>;
|
|
29
|
-
links: Link[];
|
|
30
|
-
raw: string;
|
|
31
|
-
}
|
|
32
|
-
export interface Options {
|
|
33
|
-
engine: Engine;
|
|
34
|
-
}
|
|
35
|
-
export interface LayoutError {
|
|
36
|
-
error?: string;
|
|
37
|
-
errorDot?: string;
|
|
38
|
-
}
|
|
39
|
-
export interface LayoutSVG extends LayoutError {
|
|
40
|
-
svg?: string;
|
|
41
|
-
}
|
|
42
|
-
export interface LayoutJSON extends LayoutError {
|
|
43
|
-
json?: any;
|
|
44
|
-
}
|
|
45
|
-
export type LayoutSuccess = {
|
|
46
|
-
clusters: Cluster[];
|
|
47
|
-
nodes: Node[];
|
|
48
|
-
links: Link[];
|
|
49
|
-
};
|
|
50
|
-
export type Layout = LayoutSuccess | LayoutJSON | LayoutSVG;
|
|
51
|
-
export declare function isLayoutSuccess(item: any): item is LayoutSuccess;
|
|
1
|
+
import { type Cluster, type Data, type Engine, isLayoutSuccess, type Node, type LayoutError, type Options } from "./workers/graphvizOptions.ts";
|
|
2
|
+
export { type Cluster, type Engine, isLayoutSuccess, type Node, type LayoutError, type Options };
|
|
52
3
|
export declare function graphviz(data: Data, options: Options): {
|
|
53
|
-
terminate: () =>
|
|
4
|
+
terminate: () => any;
|
|
54
5
|
response: Promise<string>;
|
|
55
6
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface Subgraph {
|
|
2
|
+
id: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Node {
|
|
6
|
+
id: string;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Link {
|
|
10
|
+
id: string;
|
|
11
|
+
source: Node;
|
|
12
|
+
target: Node;
|
|
13
|
+
}
|
|
14
|
+
export interface Hierarchy {
|
|
15
|
+
parent: string;
|
|
16
|
+
child: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Data {
|
|
19
|
+
subgraphs: Subgraph[];
|
|
20
|
+
nodes: Node[];
|
|
21
|
+
links: Link[];
|
|
22
|
+
hierarchy: Hierarchy[];
|
|
23
|
+
}
|
|
24
|
+
export interface Options {
|
|
25
|
+
rankdir: "TB" | "BT" | "LR" | "RL";
|
|
26
|
+
nodesep: number;
|
|
27
|
+
edgesep: number;
|
|
28
|
+
ranksep: number;
|
|
29
|
+
digraph: boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface Node {
|
|
2
|
+
id: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Link {
|
|
6
|
+
id: string;
|
|
7
|
+
source: Node;
|
|
8
|
+
target: Node;
|
|
9
|
+
}
|
|
10
|
+
export interface Data {
|
|
11
|
+
nodes: Node[];
|
|
12
|
+
links: Link[];
|
|
13
|
+
}
|
|
14
|
+
export interface Options {
|
|
15
|
+
alpha: number;
|
|
16
|
+
alphaMin: number;
|
|
17
|
+
alphaDecay: number;
|
|
18
|
+
velocityDecay: number;
|
|
19
|
+
repulsionStrength: number;
|
|
20
|
+
linkDistance: number;
|
|
21
|
+
linkStrength: number;
|
|
22
|
+
iterations: number;
|
|
23
|
+
pinCentroid: boolean;
|
|
24
|
+
forceStrength: number;
|
|
25
|
+
distanceMin: number;
|
|
26
|
+
distanceMax: number;
|
|
27
|
+
}
|