@ts-graphviz/common 2.1.0 → 2.1.2
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/CHANGELOG.md +22 -0
- package/lib/common.d.ts +4010 -5
- package/package.json +3 -3
- package/lib/attribute.d.ts +0 -2749
- package/lib/functional.d.ts +0 -9
- package/lib/functional.test.d.ts +0 -1
- package/lib/models-context.d.ts +0 -19
- package/lib/models.d.ts +0 -620
- package/lib/types.d.ts +0 -494
package/lib/functional.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type F<A extends any[], O> = (...args: A) => O;
|
|
2
|
-
export type IO<I, O> = F<[I], O>;
|
|
3
|
-
export declare function pipe<I extends any[], O>(f0: F<I, O>): F<I, O>;
|
|
4
|
-
export declare function pipe<I extends any[], T1, O>(f0: F<I, T1>, f1: IO<T1, O>): F<I, O>;
|
|
5
|
-
export declare function pipe<I extends any[], T1, T2, O>(f0: F<I, T1>, f1: IO<T1, T2>, f2: IO<T2, O>): F<I, O>;
|
|
6
|
-
export declare function pipe<I extends any[], T1, T2, T3, O>(f0: F<I, T1>, f1: IO<T1, T2>, f2: IO<T2, T3>, f3: IO<T3, O>): F<I, O>;
|
|
7
|
-
export declare function pipe<I extends any[], T1, T2, T3, T4, O>(f0: F<I, T1>, f1: IO<T1, T2>, f2: IO<T2, T3>, f3: IO<T3, T4>, f4: IO<T4, O>): F<I, O>;
|
|
8
|
-
export declare const map: <T, O>(selector: (item: T) => O) => (src: Iterable<T>) => O[];
|
|
9
|
-
export declare const filter: <T>(pred: (item: T) => boolean) => (src: Iterable<T>) => T[];
|
package/lib/functional.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/models-context.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { EdgeConstructor, NodeConstructor, RootGraphConstructor, SubgraphConstructor } from './models.js';
|
|
2
|
-
/**
|
|
3
|
-
* @group Models Context
|
|
4
|
-
*/
|
|
5
|
-
export interface ModelsContext {
|
|
6
|
-
Graph: RootGraphConstructor;
|
|
7
|
-
Digraph: RootGraphConstructor;
|
|
8
|
-
Subgraph: SubgraphConstructor;
|
|
9
|
-
Node: NodeConstructor;
|
|
10
|
-
Edge: EdgeConstructor;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @group Models Context
|
|
14
|
-
*/
|
|
15
|
-
export declare const RootModelsContext: ModelsContext;
|
|
16
|
-
/**
|
|
17
|
-
* @group Models Context
|
|
18
|
-
*/
|
|
19
|
-
export declare function createModelsContext(models: Partial<ModelsContext>): ModelsContext;
|
package/lib/models.d.ts
DELETED
|
@@ -1,620 +0,0 @@
|
|
|
1
|
-
import type { Attribute, AttributeKey, ClusterSubgraphAttributeKey, EdgeAttributeKey, GraphAttributeKey, NodeAttributeKey, SubgraphAttributeKey } from './attribute.js';
|
|
2
|
-
import type { ModelsContext } from './models-context.js';
|
|
3
|
-
import type { Compass } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* ASTType is an enumeration of the different types of nodes that can be found in an AST(Abstract Syntax Tree ).
|
|
6
|
-
* @group Models
|
|
7
|
-
*/
|
|
8
|
-
export type ASTType = 'Literal' | 'Dot' | 'Graph' | 'Attribute' | 'Comment' | 'AttributeList' | 'NodeRef' | 'NodeRefGroup' | 'Edge' | 'Node' | 'Subgraph';
|
|
9
|
-
/**
|
|
10
|
-
* Objects that can be Edge destinations satisfy this interface.
|
|
11
|
-
* @group Models
|
|
12
|
-
*/
|
|
13
|
-
export type NodeRef = NodeModel | ForwardRefNode;
|
|
14
|
-
/**
|
|
15
|
-
* @group Models
|
|
16
|
-
*/
|
|
17
|
-
export type NodeRefGroup = NodeRef[];
|
|
18
|
-
/**
|
|
19
|
-
* string or an object implementing EdgeTarget.
|
|
20
|
-
* @group Models
|
|
21
|
-
*/
|
|
22
|
-
export type NodeRefLike = NodeRef | string;
|
|
23
|
-
/**
|
|
24
|
-
* @group Models
|
|
25
|
-
*/
|
|
26
|
-
export type NodeRefGroupLike = NodeRefLike[];
|
|
27
|
-
/**
|
|
28
|
-
* @group Models
|
|
29
|
-
*/
|
|
30
|
-
export type EdgeTarget = NodeRef | NodeRefGroup;
|
|
31
|
-
/**
|
|
32
|
-
* @group Models
|
|
33
|
-
*/
|
|
34
|
-
export type EdgeTargetLike = NodeRefLike | NodeRefGroupLike;
|
|
35
|
-
/**
|
|
36
|
-
* @group Models
|
|
37
|
-
*/
|
|
38
|
-
export type EdgeTargetTuple = [
|
|
39
|
-
from: EdgeTarget,
|
|
40
|
-
to: EdgeTarget,
|
|
41
|
-
...rest: EdgeTarget[]
|
|
42
|
-
];
|
|
43
|
-
/**
|
|
44
|
-
* @group Models
|
|
45
|
-
*/
|
|
46
|
-
export type EdgeTargetLikeTuple = [
|
|
47
|
-
from: EdgeTargetLike,
|
|
48
|
-
to: EdgeTargetLike,
|
|
49
|
-
...rest: EdgeTargetLike[]
|
|
50
|
-
];
|
|
51
|
-
/**
|
|
52
|
-
* An objects of attribute key/value pairs.
|
|
53
|
-
* @group Models
|
|
54
|
-
*/
|
|
55
|
-
export type AttributesObject<T extends AttributeKey> = {
|
|
56
|
-
[K in T]?: Attribute<K>;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* @group Models
|
|
60
|
-
*/
|
|
61
|
-
export type AttributeValue = Attribute<AttributeKey>;
|
|
62
|
-
/**
|
|
63
|
-
* An array of attribute key/value tuple.
|
|
64
|
-
* @group Models
|
|
65
|
-
*/
|
|
66
|
-
export type AttributesEntities<T extends AttributeKey> = readonly [
|
|
67
|
-
T,
|
|
68
|
-
Attribute<T>
|
|
69
|
-
][];
|
|
70
|
-
/**
|
|
71
|
-
* Attribute object that can be set to Edge.
|
|
72
|
-
* @group Models
|
|
73
|
-
*/
|
|
74
|
-
export type EdgeAttributesObject = AttributesObject<EdgeAttributeKey>;
|
|
75
|
-
/**
|
|
76
|
-
* Attribute object that can be set to Node.
|
|
77
|
-
* @group Models
|
|
78
|
-
*/
|
|
79
|
-
export type NodeAttributesObject = AttributesObject<NodeAttributeKey>;
|
|
80
|
-
/**
|
|
81
|
-
* Attribute object that can be set to Graph.
|
|
82
|
-
* @group Models
|
|
83
|
-
*/
|
|
84
|
-
export type GraphAttributesObject = AttributesObject<GraphAttributeKey>;
|
|
85
|
-
/**
|
|
86
|
-
* Attribute object that can be set to Subgraph.
|
|
87
|
-
* @group Models
|
|
88
|
-
*/
|
|
89
|
-
export type SubgraphAttributesObject = AttributesObject<ClusterSubgraphAttributeKey | SubgraphAttributeKey>;
|
|
90
|
-
/**
|
|
91
|
-
* @group Models
|
|
92
|
-
*/
|
|
93
|
-
export type DotObjectType = 'AttributeList' | 'Node' | 'Edge' | 'Subgraph' | 'Graph';
|
|
94
|
-
/**
|
|
95
|
-
* DotObjectModel is an interface that defines a generic type for a {@link DotObjectType}.
|
|
96
|
-
*
|
|
97
|
-
* @template T The type of the {@link DotObjectType}.
|
|
98
|
-
* @group Models
|
|
99
|
-
*/
|
|
100
|
-
export interface DotObjectModel<T extends DotObjectType = DotObjectType> {
|
|
101
|
-
/**
|
|
102
|
-
* The type of the DotObjectType.
|
|
103
|
-
*/
|
|
104
|
-
$$type: T;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @group Models
|
|
108
|
-
*/
|
|
109
|
-
export interface HasComment {
|
|
110
|
-
/** Comments to include when outputting with toDot. */
|
|
111
|
-
comment?: string;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* @group Models
|
|
115
|
-
*/
|
|
116
|
-
export interface HasAttributes<T extends AttributeKey> {
|
|
117
|
-
readonly attributes: AttributesGroupModel<T>;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* @group Models
|
|
121
|
-
*/
|
|
122
|
-
export interface ForwardRefNode extends Partial<Port> {
|
|
123
|
-
readonly id: string;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* DOT object with the property
|
|
127
|
-
* that attributes can be held as a set of keys and values.
|
|
128
|
-
*
|
|
129
|
-
* @typeParam T - The attribute keys to set DOT object.
|
|
130
|
-
* @group Models
|
|
131
|
-
*/
|
|
132
|
-
export interface Attributes<T extends AttributeKey> {
|
|
133
|
-
/** Size of the set of keys and values held by the DOT object. */
|
|
134
|
-
readonly size: number;
|
|
135
|
-
/** The key/value tuples of the object attributes. */
|
|
136
|
-
readonly values: ReadonlyArray<[T, Attribute<T>]>;
|
|
137
|
-
/**
|
|
138
|
-
* Get the value of an attribute by a DOT object by specifying its key.
|
|
139
|
-
*
|
|
140
|
-
* If the value corresponding to the key does not exist, undefined is returned.
|
|
141
|
-
*/
|
|
142
|
-
get<K extends T>(key: K): Attribute<K> | undefined;
|
|
143
|
-
/** Set a value, by specifying the key of the attributes in the DOT object. */
|
|
144
|
-
set<K extends T>(key: K, value: Attribute<K>): void;
|
|
145
|
-
/**
|
|
146
|
-
* Apply keys and values that can be specified for DOT objects collectively.
|
|
147
|
-
*
|
|
148
|
-
* @param attributes - An array of objects or tuples of attribute key/value pairs.
|
|
149
|
-
*/
|
|
150
|
-
apply(attributes: AttributesObject<T> | AttributesEntities<T>): void;
|
|
151
|
-
/** Delete the value of an attribute from a DOT object by specifying a key. */
|
|
152
|
-
delete(key: T): void;
|
|
153
|
-
/** Delete all attributes specified for the DOT object. */
|
|
154
|
-
clear(): void;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* @group Models
|
|
158
|
-
*/
|
|
159
|
-
export interface AttributesGroupModel<T extends AttributeKey> extends Attributes<T>, HasComment {
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* @group Models
|
|
163
|
-
*/
|
|
164
|
-
export type AttributeListKind = 'Graph' | 'Edge' | 'Node';
|
|
165
|
-
/**
|
|
166
|
-
* A list object of attributes commonly specified for nodes, subgraphs, and edges
|
|
167
|
-
* under graph and subgraph.
|
|
168
|
-
*
|
|
169
|
-
* @typeParam K - The type of object is being specified.
|
|
170
|
-
* @typeParam T - The attribute keys to set DOT object.
|
|
171
|
-
* @group Models
|
|
172
|
-
*/
|
|
173
|
-
export interface AttributeListModel<K extends AttributeListKind = AttributeListKind, T extends AttributeKey = AttributeKey> extends Attributes<T>, HasComment, DotObjectModel<'AttributeList'> {
|
|
174
|
-
$$kind: K;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Port on an edge node.
|
|
178
|
-
* @group Models
|
|
179
|
-
*/
|
|
180
|
-
export interface Port {
|
|
181
|
-
port: string;
|
|
182
|
-
compass: Compass;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Model that can be converted to Node in DOT language.
|
|
186
|
-
* @group Models
|
|
187
|
-
*/
|
|
188
|
-
export interface NodeModel extends HasComment, HasAttributes<NodeAttributeKey>, DotObjectModel<'Node'> {
|
|
189
|
-
/** ID of the node */
|
|
190
|
-
readonly id: string;
|
|
191
|
-
/** Returns ForwardRefNode with port and compass specified. */
|
|
192
|
-
port(port: string | Partial<Port>): ForwardRefNode;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Model that can be converted to Edge in DOT language.
|
|
196
|
-
* @group Models
|
|
197
|
-
*/
|
|
198
|
-
export interface EdgeModel extends HasComment, HasAttributes<EdgeAttributeKey>, DotObjectModel<'Edge'> {
|
|
199
|
-
readonly targets: EdgeTargetTuple;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Cluster common attribute interface.
|
|
203
|
-
* @group Models
|
|
204
|
-
*/
|
|
205
|
-
export interface GraphCommonAttributes {
|
|
206
|
-
/** Manage common attributes of graphs in a graph. */
|
|
207
|
-
graph: AttributeListModel<'Graph', SubgraphAttributeKey | ClusterSubgraphAttributeKey>;
|
|
208
|
-
/** Manage common attributes of edges in a graph. */
|
|
209
|
-
edge: AttributeListModel<'Edge', EdgeAttributeKey>;
|
|
210
|
-
/** Manage common attributes of nodes in a graph. */
|
|
211
|
-
node: AttributeListModel<'Node', NodeAttributeKey>;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* DOT model representing a graph/digraph/subgraph.
|
|
215
|
-
* @group Models
|
|
216
|
-
*/
|
|
217
|
-
export interface GraphBaseModel<T extends AttributeKey = AttributeKey> extends HasComment, Attributes<T> {
|
|
218
|
-
readonly id?: string;
|
|
219
|
-
readonly attributes: Readonly<GraphCommonAttributes>;
|
|
220
|
-
/** Node objects in the graph. */
|
|
221
|
-
readonly nodes: ReadonlyArray<NodeModel>;
|
|
222
|
-
/** Edge objects in the graph. */
|
|
223
|
-
readonly edges: ReadonlyArray<EdgeModel>;
|
|
224
|
-
/** Subgraph objects in the graph. */
|
|
225
|
-
readonly subgraphs: ReadonlyArray<SubgraphModel>;
|
|
226
|
-
with(models: Partial<ModelsContext>): void;
|
|
227
|
-
/**
|
|
228
|
-
* Add a Node to the graph.
|
|
229
|
-
*/
|
|
230
|
-
addNode(node: NodeModel): void;
|
|
231
|
-
/**
|
|
232
|
-
* Add Edge to the graph.
|
|
233
|
-
*/
|
|
234
|
-
addEdge(edge: EdgeModel): void;
|
|
235
|
-
/**
|
|
236
|
-
* Add a Subgraph to the graph.
|
|
237
|
-
*/
|
|
238
|
-
addSubgraph(subgraph: SubgraphModel): void;
|
|
239
|
-
/**
|
|
240
|
-
* Check if the Node exists in the graph.
|
|
241
|
-
*/
|
|
242
|
-
existNode(nodeId: string): boolean;
|
|
243
|
-
/**
|
|
244
|
-
* Check if the Edge exists in the graph.
|
|
245
|
-
*/
|
|
246
|
-
existEdge(edge: EdgeModel): boolean;
|
|
247
|
-
/**
|
|
248
|
-
* Check if the Subgraph exists in the graph.
|
|
249
|
-
*/
|
|
250
|
-
existSubgraph(subgraph: SubgraphModel): boolean;
|
|
251
|
-
/**
|
|
252
|
-
* Remove Node from the graph.
|
|
253
|
-
*/
|
|
254
|
-
removeNode(node: NodeModel | string): void;
|
|
255
|
-
/**
|
|
256
|
-
* Remove Edge from the graph.
|
|
257
|
-
*/
|
|
258
|
-
removeEdge(edge: EdgeModel): void;
|
|
259
|
-
/**
|
|
260
|
-
* Remove Subgraph from the graph.
|
|
261
|
-
*/
|
|
262
|
-
removeSubgraph(subgraph: SubgraphModel): void;
|
|
263
|
-
/**
|
|
264
|
-
* Create a Node in the graph.
|
|
265
|
-
*/
|
|
266
|
-
createNode(id: string, attributes?: NodeAttributesObject): NodeModel;
|
|
267
|
-
/**
|
|
268
|
-
* Create a Subgraph and add it to the graph.
|
|
269
|
-
*
|
|
270
|
-
* @param id - Subgraph ID
|
|
271
|
-
* @param attributes - Subgraph attribute object
|
|
272
|
-
*/
|
|
273
|
-
createSubgraph(id?: string, attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
274
|
-
createSubgraph(attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
275
|
-
/**
|
|
276
|
-
* Get Subgraph in cluster by specifying id.
|
|
277
|
-
*
|
|
278
|
-
* If there is no Subgraph with the specified id in the graph, return undefined.
|
|
279
|
-
*/
|
|
280
|
-
getSubgraph(id: string): SubgraphModel | undefined;
|
|
281
|
-
/**
|
|
282
|
-
* Get Node in cluster by specifying id.
|
|
283
|
-
*
|
|
284
|
-
* @description
|
|
285
|
-
* If there is no Node with the specified id in the graph, return undefined.
|
|
286
|
-
*/
|
|
287
|
-
getNode(id: string): NodeModel | undefined;
|
|
288
|
-
/** Create Edge and add it to the graph. */
|
|
289
|
-
createEdge(targets: EdgeTargetLikeTuple, attributes?: EdgeAttributesObject): EdgeModel;
|
|
290
|
-
/**
|
|
291
|
-
* Create a subgraph by specifying its id (or get it if it already exists).
|
|
292
|
-
*
|
|
293
|
-
* By specifying a callback function, the target subgraph can be received and manipulated as an argument.
|
|
294
|
-
*
|
|
295
|
-
* ```ts
|
|
296
|
-
* const G = digraph('G', (g) => {
|
|
297
|
-
* // Create a cluster with id as A.
|
|
298
|
-
* g.subgraph('A', (A) => {
|
|
299
|
-
* // Create a node with id as A1 in cluster A.
|
|
300
|
-
* A.node('A1');
|
|
301
|
-
* });
|
|
302
|
-
* });
|
|
303
|
-
*
|
|
304
|
-
* console.log(toDot(G));
|
|
305
|
-
* // digraph "G" {
|
|
306
|
-
* // subgraph "A" {
|
|
307
|
-
* // "A1";
|
|
308
|
-
* // }
|
|
309
|
-
* // }
|
|
310
|
-
* ```
|
|
311
|
-
*
|
|
312
|
-
* @param id Subgraph ID.
|
|
313
|
-
* @param callback Callbacks for manipulating created or retrieved subgraph.
|
|
314
|
-
*/
|
|
315
|
-
subgraph(id: string, callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
316
|
-
/**
|
|
317
|
-
* Create a subgraph (or get one if it already exists) and adapt the attributes.
|
|
318
|
-
*
|
|
319
|
-
* By specifying a callback function, the target subgraph can be received and manipulated as an argument.
|
|
320
|
-
*
|
|
321
|
-
* ```ts
|
|
322
|
-
* const G = digraph('G', (g) => {
|
|
323
|
-
* // Create a cluster with id as A and specifying its attributes.
|
|
324
|
-
* g.subgraph('A', { [attribute.color]: 'red', [attribute.label]: 'my label' }, (A) => {
|
|
325
|
-
* // Create a node with id as A1 in cluster A.
|
|
326
|
-
* A.node('A1');
|
|
327
|
-
* });
|
|
328
|
-
* });
|
|
329
|
-
*
|
|
330
|
-
* console.log(toDot(G));
|
|
331
|
-
* // digraph "G" {
|
|
332
|
-
* // subgraph "A" {
|
|
333
|
-
* // color = "red";
|
|
334
|
-
* // label = "my label";
|
|
335
|
-
* // "A1";
|
|
336
|
-
* // }
|
|
337
|
-
* // }
|
|
338
|
-
* ```
|
|
339
|
-
*
|
|
340
|
-
* @param id Subgraph ID.
|
|
341
|
-
* @param attributes Object of attributes to be adapted to the subgraph.
|
|
342
|
-
* @param callback Callbacks for manipulating created or retrieved subgraph.
|
|
343
|
-
*/
|
|
344
|
-
subgraph(id: string, attributes: SubgraphAttributesObject, callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
345
|
-
/**
|
|
346
|
-
* Create anonymous subgraphs and and adapt the attributes.
|
|
347
|
-
*
|
|
348
|
-
* By specifying a callback function, the target subgraph can be received and manipulated as an argument.
|
|
349
|
-
*
|
|
350
|
-
* ```ts
|
|
351
|
-
* const G = digraph('G', (g) => {
|
|
352
|
-
* // Create a anonymous cluster and specifying its attributes.
|
|
353
|
-
* g.subgraph({ [attribute.color]: 'red', [attribute.label]: 'my label' }, (A) => {
|
|
354
|
-
* // Create a node with id as A1 in anonymous cluster.
|
|
355
|
-
* A.node('A1');
|
|
356
|
-
* });
|
|
357
|
-
* });
|
|
358
|
-
*
|
|
359
|
-
* console.log(toDot(G));
|
|
360
|
-
* // digraph "G" {
|
|
361
|
-
* // subgraph {
|
|
362
|
-
* // color = "red";
|
|
363
|
-
* // label = "my label";
|
|
364
|
-
* // "A1";
|
|
365
|
-
* // }
|
|
366
|
-
* // }
|
|
367
|
-
* ```
|
|
368
|
-
*
|
|
369
|
-
* @param attributes Object of attributes to be adapted to the subgraph.
|
|
370
|
-
* @param callback Callbacks for manipulating created or retrieved subgraph.
|
|
371
|
-
*/
|
|
372
|
-
subgraph(attributes: SubgraphAttributesObject, callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
373
|
-
/**
|
|
374
|
-
* Create anonymous subgraphs and manipulate them with callback functions.
|
|
375
|
-
*
|
|
376
|
-
* By specifying a callback function, the target subgraph can be received and manipulated as an argument.
|
|
377
|
-
*
|
|
378
|
-
* @param callback Callbacks for manipulating created or retrieved subgraph.
|
|
379
|
-
*/
|
|
380
|
-
subgraph(callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
381
|
-
/**
|
|
382
|
-
* Create a node by specifying its id (or get it if it already exists).
|
|
383
|
-
*
|
|
384
|
-
* By specifying a callback function, the target node can be received and manipulated as an argument.
|
|
385
|
-
*
|
|
386
|
-
* ```ts
|
|
387
|
-
* const G = digraph('G', (g) => {
|
|
388
|
-
* // Create a node with id as A.
|
|
389
|
-
* g.node('A');
|
|
390
|
-
* });
|
|
391
|
-
*
|
|
392
|
-
* console.log(toDot(G));
|
|
393
|
-
* // digraph "G" {
|
|
394
|
-
* // "A";
|
|
395
|
-
* // }
|
|
396
|
-
* ```
|
|
397
|
-
*
|
|
398
|
-
* @param id Node ID.
|
|
399
|
-
* @param callback Callbacks for manipulating created or retrieved node.
|
|
400
|
-
*/
|
|
401
|
-
node(id: string, callback?: (node: NodeModel) => void): NodeModel;
|
|
402
|
-
/**
|
|
403
|
-
* Create a node (or get one if it already exists) and adapt the attributes.
|
|
404
|
-
*
|
|
405
|
-
* By specifying a callback function, the target node can be received and manipulated as an argument.
|
|
406
|
-
*
|
|
407
|
-
* ```ts
|
|
408
|
-
* const G = digraph('G', (g) => {
|
|
409
|
-
* // Create a node by specifying its id and specifying its attributes.
|
|
410
|
-
* g.node('A', {
|
|
411
|
-
* [attribute.color]: 'red',
|
|
412
|
-
* [attribute.label]: 'my label',
|
|
413
|
-
* });
|
|
414
|
-
* });
|
|
415
|
-
*
|
|
416
|
-
* console.log(toDot(G));
|
|
417
|
-
* // digraph "G" {
|
|
418
|
-
* // "A" [
|
|
419
|
-
* // color = "red",
|
|
420
|
-
* // label = "my label",
|
|
421
|
-
* // ];
|
|
422
|
-
* // }
|
|
423
|
-
* ```
|
|
424
|
-
*
|
|
425
|
-
* @param id Node ID.
|
|
426
|
-
* @param attributes Object of attributes to be adapted to the node.
|
|
427
|
-
* @param callback Callbacks for manipulating created or retrieved node.
|
|
428
|
-
*/
|
|
429
|
-
node(id: string, attributes: NodeAttributesObject, callback?: (node: NodeModel) => void): NodeModel;
|
|
430
|
-
/**
|
|
431
|
-
* Set a common attribute for the nodes in the graph.
|
|
432
|
-
*
|
|
433
|
-
* ```ts
|
|
434
|
-
* const G = digraph('G', (g) => {
|
|
435
|
-
* // Set a common attribute for the nodes in the graph.
|
|
436
|
-
* g.node({
|
|
437
|
-
* [attribute.color]: 'red',
|
|
438
|
-
* [attribute.label]: 'my label',
|
|
439
|
-
* });
|
|
440
|
-
* });
|
|
441
|
-
*
|
|
442
|
-
* console.log(toDot(G));
|
|
443
|
-
* // digraph "G" {
|
|
444
|
-
* // node [
|
|
445
|
-
* // color = "red",
|
|
446
|
-
* // label = "my label",
|
|
447
|
-
* // ];
|
|
448
|
-
* // }
|
|
449
|
-
* ```
|
|
450
|
-
*
|
|
451
|
-
* @param attributes Object of attributes to be adapted to the nodes.
|
|
452
|
-
*/
|
|
453
|
-
node(attributes: NodeAttributesObject): void;
|
|
454
|
-
/**
|
|
455
|
-
* Create a edge.
|
|
456
|
-
*
|
|
457
|
-
* By specifying a callback function, the target edge can be received and manipulated as an argument.
|
|
458
|
-
*
|
|
459
|
-
* ```ts
|
|
460
|
-
* const G = digraph('G', (g) => {
|
|
461
|
-
* // Create a edge.
|
|
462
|
-
* g.edge(['a', 'b']);
|
|
463
|
-
* });
|
|
464
|
-
*
|
|
465
|
-
* console.log(toDot(G));
|
|
466
|
-
* // digraph "G" {
|
|
467
|
-
* // "a" -> "b";
|
|
468
|
-
* // }
|
|
469
|
-
* ```
|
|
470
|
-
* @param targets Nodes.
|
|
471
|
-
* @param callback Callbacks for manipulating created or retrieved edge.
|
|
472
|
-
*/
|
|
473
|
-
edge(targets: EdgeTargetLikeTuple, callback?: (edge: EdgeModel) => void): EdgeModel;
|
|
474
|
-
/**
|
|
475
|
-
* Create a edge and adapt the attributes.
|
|
476
|
-
*
|
|
477
|
-
* By specifying a callback function, the target edge can be received and manipulated as an argument.
|
|
478
|
-
*
|
|
479
|
-
* ```ts
|
|
480
|
-
* const G = digraph('G', (g) => {
|
|
481
|
-
* // Create a edge and specifying its attributes.
|
|
482
|
-
* g.edge(['a', 'b'], {
|
|
483
|
-
* [attribute.color]: 'red',
|
|
484
|
-
* [attribute.label]: 'my label',
|
|
485
|
-
* });
|
|
486
|
-
* });
|
|
487
|
-
*
|
|
488
|
-
* console.log(toDot(G));
|
|
489
|
-
* // digraph "G" {
|
|
490
|
-
* // "a" -> "b" [
|
|
491
|
-
* // color = "red",
|
|
492
|
-
* // label = "my label",
|
|
493
|
-
* // ];
|
|
494
|
-
* // }
|
|
495
|
-
* ```
|
|
496
|
-
*
|
|
497
|
-
* @param attributes Object of attributes to be adapted to the edge.
|
|
498
|
-
* @param callback Callbacks for manipulating created or retrieved edge.
|
|
499
|
-
*/
|
|
500
|
-
edge(targets: EdgeTargetLikeTuple, attributes: EdgeAttributesObject, callback?: (edge: EdgeModel) => void): EdgeModel;
|
|
501
|
-
/**
|
|
502
|
-
* Set a common attribute for the edges in the graph.
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* ```ts
|
|
506
|
-
* const G = digraph('G', (g) => {
|
|
507
|
-
* // Set a common attribute for the edges in the graph.
|
|
508
|
-
* g.edge({
|
|
509
|
-
* [attribute.color]: 'red',
|
|
510
|
-
* [attribute.label]: 'my label',
|
|
511
|
-
* });
|
|
512
|
-
* });
|
|
513
|
-
*
|
|
514
|
-
* console.log(toDot(G));
|
|
515
|
-
* // digraph "G" {
|
|
516
|
-
* // edge [
|
|
517
|
-
* // color = "red",
|
|
518
|
-
* // label = "my label",
|
|
519
|
-
* // ];
|
|
520
|
-
* // }
|
|
521
|
-
* ```
|
|
522
|
-
* @param attributes Object of attributes to be adapted to the edges.
|
|
523
|
-
*/
|
|
524
|
-
edge(attributes: EdgeAttributesObject): void;
|
|
525
|
-
/**
|
|
526
|
-
* Set a common attribute for the graph in the graph.
|
|
527
|
-
*
|
|
528
|
-
* ```ts
|
|
529
|
-
* const G = digraph('G', (g) => {
|
|
530
|
-
* g.graph({
|
|
531
|
-
* [attribute.color]: 'red',
|
|
532
|
-
* [attribute.label]: 'my label',
|
|
533
|
-
* });
|
|
534
|
-
* });
|
|
535
|
-
*
|
|
536
|
-
* console.log(toDot(G));
|
|
537
|
-
* // digraph "G" {
|
|
538
|
-
* // graph [
|
|
539
|
-
* // color = "red",
|
|
540
|
-
* // label = "my label",
|
|
541
|
-
* // ];
|
|
542
|
-
* // }
|
|
543
|
-
* ```
|
|
544
|
-
* @param attributes Object of attributes to be adapted to the graph.
|
|
545
|
-
*/
|
|
546
|
-
graph(attributes: SubgraphAttributesObject): void;
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* DOT model representing a subgraph.
|
|
550
|
-
* @group Models
|
|
551
|
-
*/
|
|
552
|
-
export interface SubgraphModel extends GraphBaseModel<SubgraphAttributeKey | ClusterSubgraphAttributeKey>, DotObjectModel<'Subgraph'> {
|
|
553
|
-
/** Determines whether the Subgraph is a SubgraphCluster. */
|
|
554
|
-
isSubgraphCluster(): boolean;
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* DOT model representing a root graphs(digraph and graph).
|
|
558
|
-
* @group Models
|
|
559
|
-
*/
|
|
560
|
-
export interface RootGraphModel extends GraphBaseModel<GraphAttributeKey>, DotObjectModel<'Graph'> {
|
|
561
|
-
directed: boolean;
|
|
562
|
-
/**
|
|
563
|
-
* Strict mode.
|
|
564
|
-
*
|
|
565
|
-
* @description
|
|
566
|
-
* A graph may also be described as strict.
|
|
567
|
-
* This forbids the creation of multi-edges, i.e., there can be at most one edge with a given tail node and head node in the directed case.
|
|
568
|
-
* For undirected graphs, there can be at most one edge connected to the same two nodes.
|
|
569
|
-
* Subsequent edge statements using the same two nodes will identify the edge with the previously defined one and apply any attributes given in the edge statement.
|
|
570
|
-
*/
|
|
571
|
-
strict: boolean;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* @group Models
|
|
575
|
-
*/
|
|
576
|
-
export interface RootGraphConstructor {
|
|
577
|
-
new (id?: string, attributes?: GraphAttributesObject): RootGraphModel;
|
|
578
|
-
new (id?: string, strict?: boolean, attributes?: GraphAttributesObject): RootGraphModel;
|
|
579
|
-
new (strict?: boolean, attributes?: GraphAttributesObject): RootGraphModel;
|
|
580
|
-
new (attributes?: GraphAttributesObject): RootGraphModel;
|
|
581
|
-
new (...args: any[]): RootGraphModel;
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* @group Models
|
|
585
|
-
*/
|
|
586
|
-
export interface SubgraphConstructor {
|
|
587
|
-
new (id?: string, attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
588
|
-
new (attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
589
|
-
new (...args: any[]): SubgraphModel;
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* @group Models
|
|
593
|
-
*/
|
|
594
|
-
export interface NodeConstructor {
|
|
595
|
-
new (id: string, attributes?: NodeAttributesObject): NodeModel;
|
|
596
|
-
new (...args: any[]): NodeModel;
|
|
597
|
-
}
|
|
598
|
-
/**
|
|
599
|
-
* @group Models
|
|
600
|
-
*/
|
|
601
|
-
export interface EdgeConstructor {
|
|
602
|
-
new (targets: EdgeTargetTuple, attributes?: EdgeAttributesObject): EdgeModel;
|
|
603
|
-
new (...args: any[]): EdgeModel;
|
|
604
|
-
}
|
|
605
|
-
/** @hidden */
|
|
606
|
-
export declare function isForwardRefNode(object: unknown): object is ForwardRefNode;
|
|
607
|
-
/** @hidden */
|
|
608
|
-
export declare function isNodeModel(object: unknown): object is NodeModel;
|
|
609
|
-
/** @hidden */
|
|
610
|
-
export declare function isNodeRef(node: unknown): node is NodeRef;
|
|
611
|
-
/** @hidden */
|
|
612
|
-
export declare function isNodeRefLike(node: unknown): node is NodeRefLike;
|
|
613
|
-
/** @hidden */
|
|
614
|
-
export declare function isNodeRefGroupLike(target: NodeRefLike | NodeRefGroupLike): target is NodeRefGroupLike;
|
|
615
|
-
/** @hidden */
|
|
616
|
-
export declare function isCompass(c: string): c is Compass;
|
|
617
|
-
/** @hidden */
|
|
618
|
-
export declare function toNodeRef(target: NodeRefLike): NodeRef;
|
|
619
|
-
/** @hidden */
|
|
620
|
-
export declare function toNodeRefGroup(targets: NodeRefGroupLike): NodeRefGroup;
|