@@ -75,46 +75,46 @@ export declare class Graph<G, N, E> {
75
75
* undirected.edge("b", "a"); // returns "my-label"
76
76
* ```
77
77
*
78
- * @returns { boolean } `true` if the graph is directed.
78
+ * @returns `true` if the graph is directed.
79
79
*/
80
80
isDirected ( ) : boolean ;
81
81
82
82
/**
83
- * @returns { boolean } `true` if the graph is a [multigraph](https://github.com/dagrejs/graphlib/wiki/API-Reference#multigraphs).
83
+ * @returns `true` if the graph is a [multigraph](https://github.com/dagrejs/graphlib/wiki/API-Reference#multigraphs).
84
84
*/
85
85
isMultigraph ( ) : boolean ;
86
86
87
87
/**
88
- * @returns { boolean } `true` if the graph is [compound](https://github.com/dagrejs/graphlib/wiki/API-Reference#compound-graphs).
88
+ * @returns `true` if the graph is [compound](https://github.com/dagrejs/graphlib/wiki/API-Reference#compound-graphs).
89
89
*/
90
90
isCompound ( ) : boolean ;
91
91
92
92
/**
93
93
* Sets the label for the graph to `label`.
94
94
*/
95
- setGraph ( label : any ) : Graph < G , N , E > ;
95
+ setGraph ( label : G ) : this ;
96
96
97
97
/**
98
98
* @returns The currently assigned label for the graph. If no label has been assigned, returns undefined
99
99
*/
100
- graph ( ) : any | undefined ;
100
+ graph ( ) : G | undefined ;
101
101
102
102
/**
103
103
* Defaults to be set when creating a new node
104
104
*/
105
- _defaultNodeLabelFn ( node ?: NodeIdentifier ) : any | undefined ;
105
+ _defaultNodeLabelFn ( node ?: NodeIdentifier ) : N | undefined ;
106
106
107
107
/**
108
108
* Defaults to be set when creating a new edge
109
109
*/
110
- _defaultEdgeLabelFn ( v : NodeIdentifier , w : NodeIdentifier , name ?: string ) : any | undefined ;
110
+ _defaultEdgeLabelFn ( v : NodeIdentifier , w : NodeIdentifier , name ?: string ) : E | undefined ;
111
111
112
112
/**
113
113
* Sets a new default value that is assigned to nodes that are created without a label.
114
114
* If the value is not a function it is assigned as the label directly.
115
115
* If the value is a function, it is called with the id of the node being created.
116
116
*/
117
- setDefaultNodeLabel ( newDefault : string | ( ( node ?: NodeIdentifier ) => any ) ) : Graph < G , N , E > ;
117
+ setDefaultNodeLabel ( newDefault : string | ( ( node ?: NodeIdentifier ) => N ) ) : this ;
118
118
119
119
/**
120
120
* @returns the number of nodes in the graph.
@@ -138,7 +138,7 @@ export declare class Graph<G, N, E> {
138
138
/**
139
139
* Shortcut to calling `setNode()` on each array element
140
140
*/
141
- setNodes ( vs : NodeIdentifier [ ] , value ?: N ) : Graph < G , N , E > ;
141
+ setNodes ( vs : NodeIdentifier [ ] , value ?: N ) : this ;
142
142
143
143
/**
144
144
* Creates or updates the value for the node v in the graph.
@@ -149,7 +149,7 @@ export declare class Graph<G, N, E> {
149
149
* @param v The node to set
150
150
* @returns the graph, allowing this to be chained with other functions. Takes O(1) time.
151
151
*/
152
- setNode ( v : NodeIdentifier , label ?: N ) : Graph < G , N , E > ;
152
+ setNode ( v : NodeIdentifier , label ?: N ) : this ;
153
153
154
154
/**
155
155
* @returns the label assigned to the node or undefined when not found. Takes O(1) time.
@@ -167,7 +167,7 @@ export declare class Graph<G, N, E> {
167
167
*
168
168
* @returns the graph, allowing this to be chained with other functions. Takes O(|E|) time.
169
169
*/
170
- removeNode ( v : NodeIdentifier ) : Graph < G , N , E > ;
170
+ removeNode ( v : NodeIdentifier ) : this ;
171
171
172
172
/**
173
173
* Sets the parent for `v` to `parent` if it is defined or removes the parent for `v` if `parent` is undefined.
@@ -176,7 +176,7 @@ export declare class Graph<G, N, E> {
176
176
* @param parent The parent to set. Removes the parent when not set.
177
177
* @returns the graph, allowing this to be chained with other functions. Takes O(1) time.
178
178
*/
179
- setParent ( v : NodeIdentifier , parent ?: NodeIdentifier ) : Graph < G , N , E > ;
179
+ setParent ( v : NodeIdentifier , parent ?: NodeIdentifier ) : this ;
180
180
181
181
_removeFromParentsChildList ( v : NodeIdentifier ) : void ;
182
182
@@ -213,6 +213,7 @@ export declare class Graph<G, N, E> {
213
213
214
214
/**
215
215
* @param filter The filter function.
216
+ * @returns A copy of the graph with filtered nodes.
216
217
*/
217
218
filterNodes ( filter : ( id : NodeIdentifier ) => boolean ) : Graph < G , N , E > ;
218
219
@@ -221,7 +222,7 @@ export declare class Graph<G, N, E> {
221
222
* If the value is not a function it is assigned as the label directly.
222
223
* If the value is a function, it is called with the parameters (v, w, name).
223
224
*/
224
- setDefaultEdgeLabel ( newDefault : string | ( ( v :NodeIdentifier , w :NodeIdentifier , name ?: string | number ) => any ) ) : Graph < G , N , E > ;
225
+ setDefaultEdgeLabel ( newDefault : string | ( ( v :NodeIdentifier , w :NodeIdentifier , name ?: string | number ) => E ) ) : this ;
225
226
226
227
/**
227
228
* @returns the number of edges in the graph.
@@ -233,7 +234,7 @@ export declare class Graph<G, N, E> {
233
234
*/
234
235
edges ( ) : Edge < E > [ ] ;
235
236
236
- setPath ( vs : NodeIdentifier [ ] , value ?: string ) : Graph < G , N , E > ;
237
+ setPath ( vs : NodeIdentifier [ ] , value ?: string ) : this ;
237
238
238
239
/**
239
240
* Creates or updates the label for the edge (v, w) with the optionally supplied name.
@@ -251,33 +252,70 @@ export declare class Graph<G, N, E> {
251
252
* @param name
252
253
* @returns Returns the graph, allowing this to be chained with other functions.
253
254
*/
254
- setEdge ( v : NodeIdentifier | Edge < E > , w ?: NodeIdentifier | E , value ?: E , name ?: string | number ) : Graph < G , N , E > ;
255
+ setEdge ( v : NodeIdentifier , w : NodeIdentifier , value ?: E , name ?: string | number ) : this;
256
+ /**
257
+ * Creates or updates the label for the edge (v, w) with the optionally supplied name.
258
+ * If `label` is supplied it is set as the value for the edge. If `label` is not supplied and the edge
259
+ * is created by this call then the default edge label will be assigned.
260
+ * The name parameter is only useful with multi graphs.
261
+ * setEdge(v, w, [value, [name]])
262
+ * setEdge({ v, w, [name] }, [value])
263
+ *
264
+ * Takes O(1) time.
265
+ *
266
+ * @param edge
267
+ * @param value
268
+ * @returns Returns the graph, allowing this to be chained with other functions.
269
+ */
270
+ setEdge ( edge : Edge < E > , value ?: E ) : this;
255
271
256
272
/**
257
273
* The name parameter is only useful with multi graphs. `v` and `w` can be interchanged for undirected graphs.
258
274
*
259
275
* Takes O(1) time.
260
276
*
261
- * @param v
262
- * @param w Required when `v` is not an edge. When the `v` is an object then this is `name` param.
277
+ * @param v The id of the source node
278
+ * @param w The id of the target node
279
+ * @param name
280
+ * @returns the label for the edge (v, w) if the graph has an edge between `v` and `w` with the optional name.
281
+ * Returns `undefined` if there is no such edge in the graph.
282
+ */
283
+ edge ( v : NodeIdentifier , w : NodeIdentifier , name ?: string | number ) : E | undefined ;
284
+ /**
285
+ * The name parameter is only useful with multi graphs. `v` and `w` can be interchanged for undirected graphs.
286
+ *
287
+ * Takes O(1) time.
288
+ *
289
+ * @param edge
263
290
* @param name
264
291
* @returns the label for the edge (v, w) if the graph has an edge between `v` and `w` with the optional name.
265
292
* Returns `undefined` if there is no such edge in the graph.
266
293
*/
267
- edge ( v : Edge < E > | NodeIdentifier , w ?: NodeIdentifier | string , name ?: string | number ) : E | undefined ;
294
+ edge ( edge : Edge < E > , name ?: string | number ) : E | undefined ;
268
295
269
296
/**
270
297
* The name parameter is only useful with [multi graphs](https://github.com/dagrejs/graphlib/wiki/API-Reference#multigraphs).
271
298
* `v` and `w` can be interchanged for undirected graphs.
272
299
*
273
300
* Takes O(1) time.
274
301
*
275
- * @param v
276
- * @param w Required when `v` is not an edge. When the `v` is an object then this is `name` param.
302
+ * @param v The id of the source node
303
+ * @param w The id of the target node
304
+ * @param name
305
+ * @returns `true` if the graph has an edge between `v` and `w` with the optional name.
306
+ */
307
+ hasEdge ( v : NodeIdentifier , w : NodeIdentifier , name ?: string ) : boolean ;
308
+ /**
309
+ * The name parameter is only useful with [multi graphs](https://github.com/dagrejs/graphlib/wiki/API-Reference#multigraphs).
310
+ * `v` and `w` can be interchanged for undirected graphs.
311
+ *
312
+ * Takes O(1) time.
313
+ *
314
+ * @param edge The edge to test
277
315
* @param name
278
316
* @returns `true` if the graph has an edge between `v` and `w` with the optional name.
279
317
*/
280
- hasEdge ( v : Edge < E > | NodeIdentifier , w ?: NodeIdentifier | string , name ?: string ) : boolean ;
318
+ hasEdge ( edge : Edge < E > , name ?: string ) : boolean ;
281
319
282
320
/**
283
321
* Removes the edge (v, w) if the graph has an edge between `v` and `w` with the optional name.
@@ -286,11 +324,22 @@ export declare class Graph<G, N, E> {
286
324
*
287
325
* Takes O(1) time.
288
326
*
289
- * @param v
290
- * @param w Required when `v` is not an edge. When the `v` is an object then this is `name` param.
327
+ * @param edge The edge to remove.
328
+ * @param name
329
+ */
330
+ removeEdge ( edge : Edge < E > , name ?: string ) : this;
331
+ /**
332
+ * Removes the edge (v, w) if the graph has an edge between `v` and `w` with the optional name.
333
+ * If not this function does nothing. The `name` parameter is only useful with multi graphs.
334
+ * `v` and `w` can be interchanged for undirected graphs.
335
+ *
336
+ * Takes O(1) time.
337
+ *
338
+ * @param v The id of the source node
339
+ * @param w The id of the target node
291
340
* @param name
292
341
*/
293
- removeEdge ( v : Edge < E > | NodeIdentifier , w ? : NodeIdentifier | string , name ?: string ) : Graph < G , N , E > ;
342
+ removeEdge ( v : NodeIdentifier , w : NodeIdentifier , name ?: string ) : this ;
294
343
295
344
/**
296
345
* Returns all edges that point to the node `v`.
0 commit comments