linked-list-typed 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/dist/cjs/index.cjs +2152 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/index.mjs +2143 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/data-structures/base/index.d.ts +2 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -2
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -29
- package/dist/types/data-structures/binary-tree/bst.d.ts +413 -12
- package/dist/types/data-structures/binary-tree/index.d.ts +3 -2
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -3
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -1
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -2
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +270 -2
- package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -14
- package/dist/types/data-structures/graph/directed-graph.d.ts +207 -1
- package/dist/types/data-structures/graph/index.d.ts +2 -1
- package/dist/types/data-structures/graph/map-graph.d.ts +78 -1
- package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -1
- package/dist/types/data-structures/hash/hash-map.d.ts +345 -19
- package/dist/types/data-structures/hash/index.d.ts +0 -1
- package/dist/types/data-structures/heap/heap.d.ts +503 -5
- package/dist/types/data-structures/heap/index.d.ts +2 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +32 -1
- package/dist/types/data-structures/heap/min-heap.d.ts +33 -1
- package/dist/types/data-structures/index.d.ts +7 -7
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -2
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -4
- package/dist/types/data-structures/matrix/index.d.ts +1 -1
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -7
- package/dist/types/data-structures/matrix/navigator.d.ts +54 -13
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -1
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -1
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -2
- package/dist/types/data-structures/queue/deque.d.ts +431 -4
- package/dist/types/data-structures/queue/queue.d.ts +308 -4
- package/dist/types/data-structures/stack/stack.d.ts +306 -2
- package/dist/types/data-structures/tree/tree.d.ts +62 -1
- package/dist/types/data-structures/trie/trie.d.ts +350 -4
- package/dist/types/index.d.ts +11 -2
- package/dist/{interfaces → types/interfaces}/binary-tree.d.ts +3 -3
- package/dist/types/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
- package/dist/{data-structures → types/types/data-structures}/binary-tree/index.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
- package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
- package/dist/{data-structures → types/types/data-structures}/graph/index.d.ts +1 -2
- package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
- package/dist/types/types/data-structures/hash/index.d.ts +2 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
- package/dist/types/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
- package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
- package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
- package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
- package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
- package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
- package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/utils/index.d.ts +2 -0
- package/dist/types/types/utils/utils.d.ts +22 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +209 -22
- package/dist/umd/linked-list-typed.js +2146 -0
- package/dist/umd/linked-list-typed.js.map +1 -0
- package/dist/umd/linked-list-typed.min.js +9 -0
- package/dist/umd/linked-list-typed.min.js.map +1 -0
- package/package.json +25 -5
- package/src/data-structures/binary-tree/avl-tree-counter.ts +8 -11
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +6 -11
- package/src/data-structures/binary-tree/avl-tree.ts +6 -8
- package/src/data-structures/binary-tree/binary-tree.ts +13 -15
- package/src/data-structures/binary-tree/bst.ts +6 -11
- package/src/data-structures/binary-tree/red-black-tree.ts +6 -11
- package/src/data-structures/binary-tree/tree-counter.ts +8 -13
- package/src/data-structures/binary-tree/tree-multi-map.ts +6 -11
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/interfaces/binary-tree.ts +3 -3
- package/tsconfig.base.json +23 -0
- package/tsconfig.json +8 -34
- package/tsconfig.test.json +8 -0
- package/tsconfig.types.json +15 -0
- package/tsup.config.js +28 -0
- package/tsup.node.config.js +37 -0
- package/dist/common/index.js +0 -28
- package/dist/constants/index.js +0 -8
- package/dist/data-structures/base/index.d.ts +0 -2
- package/dist/data-structures/base/index.js +0 -18
- package/dist/data-structures/base/iterable-element-base.js +0 -243
- package/dist/data-structures/base/iterable-entry-base.js +0 -183
- package/dist/data-structures/base/linear-base.js +0 -415
- package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
- package/dist/data-structures/binary-tree/avl-tree-counter.js +0 -374
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +0 -250
- package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -291
- package/dist/data-structures/binary-tree/avl-tree.js +0 -611
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -294
- package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -754
- package/dist/data-structures/binary-tree/binary-tree.js +0 -1925
- package/dist/data-structures/binary-tree/bst.d.ts +0 -413
- package/dist/data-structures/binary-tree/bst.js +0 -903
- package/dist/data-structures/binary-tree/index.js +0 -26
- package/dist/data-structures/binary-tree/red-black-tree.d.ts +0 -208
- package/dist/data-structures/binary-tree/red-black-tree.js +0 -546
- package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -160
- package/dist/data-structures/binary-tree/segment-tree.js +0 -297
- package/dist/data-structures/binary-tree/tree-counter.d.ts +0 -190
- package/dist/data-structures/binary-tree/tree-counter.js +0 -413
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
- package/dist/data-structures/binary-tree/tree-multi-map.js +0 -384
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -340
- package/dist/data-structures/graph/abstract-graph.js +0 -896
- package/dist/data-structures/graph/directed-graph.d.ts +0 -207
- package/dist/data-structures/graph/directed-graph.js +0 -525
- package/dist/data-structures/graph/index.js +0 -20
- package/dist/data-structures/graph/map-graph.d.ts +0 -78
- package/dist/data-structures/graph/map-graph.js +0 -107
- package/dist/data-structures/graph/undirected-graph.d.ts +0 -188
- package/dist/data-structures/graph/undirected-graph.js +0 -424
- package/dist/data-structures/hash/hash-map.d.ts +0 -345
- package/dist/data-structures/hash/hash-map.js +0 -692
- package/dist/data-structures/hash/index.d.ts +0 -1
- package/dist/data-structures/hash/index.js +0 -17
- package/dist/data-structures/heap/heap.d.ts +0 -503
- package/dist/data-structures/heap/heap.js +0 -901
- package/dist/data-structures/heap/index.d.ts +0 -3
- package/dist/data-structures/heap/index.js +0 -19
- package/dist/data-structures/heap/max-heap.d.ts +0 -32
- package/dist/data-structures/heap/max-heap.js +0 -40
- package/dist/data-structures/heap/min-heap.d.ts +0 -33
- package/dist/data-structures/heap/min-heap.js +0 -31
- package/dist/data-structures/index.js +0 -28
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
- package/dist/data-structures/linked-list/doubly-linked-list.js +0 -1111
- package/dist/data-structures/linked-list/index.js +0 -19
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -451
- package/dist/data-structures/linked-list/singly-linked-list.js +0 -850
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -27
- package/dist/data-structures/linked-list/skip-linked-list.js +0 -144
- package/dist/data-structures/matrix/index.js +0 -18
- package/dist/data-structures/matrix/matrix.d.ts +0 -168
- package/dist/data-structures/matrix/matrix.js +0 -448
- package/dist/data-structures/matrix/navigator.d.ts +0 -55
- package/dist/data-structures/matrix/navigator.js +0 -111
- package/dist/data-structures/priority-queue/index.js +0 -19
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
- package/dist/data-structures/priority-queue/max-priority-queue.js +0 -34
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
- package/dist/data-structures/priority-queue/min-priority-queue.js +0 -24
- package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -15
- package/dist/data-structures/priority-queue/priority-queue.js +0 -20
- package/dist/data-structures/queue/deque.d.ts +0 -431
- package/dist/data-structures/queue/deque.js +0 -879
- package/dist/data-structures/queue/index.js +0 -18
- package/dist/data-structures/queue/queue.d.ts +0 -308
- package/dist/data-structures/queue/queue.js +0 -473
- package/dist/data-structures/stack/index.js +0 -17
- package/dist/data-structures/stack/stack.d.ts +0 -306
- package/dist/data-structures/stack/stack.js +0 -401
- package/dist/data-structures/tree/index.js +0 -17
- package/dist/data-structures/tree/tree.d.ts +0 -62
- package/dist/data-structures/tree/tree.js +0 -107
- package/dist/data-structures/trie/index.js +0 -17
- package/dist/data-structures/trie/trie.d.ts +0 -350
- package/dist/data-structures/trie/trie.js +0 -610
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -28
- package/dist/interfaces/binary-tree.js +0 -2
- package/dist/interfaces/doubly-linked-list.js +0 -2
- package/dist/interfaces/graph.js +0 -2
- package/dist/interfaces/heap.js +0 -2
- package/dist/interfaces/index.js +0 -24
- package/dist/interfaces/navigator.js +0 -2
- package/dist/interfaces/priority-queue.js +0 -2
- package/dist/interfaces/segment-tree.js +0 -2
- package/dist/interfaces/singly-linked-list.js +0 -2
- package/dist/types/common.js +0 -2
- package/dist/types/data-structures/base/base.js +0 -2
- package/dist/types/data-structures/base/index.js +0 -17
- package/dist/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/binary-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/bst.js +0 -2
- package/dist/types/data-structures/binary-tree/index.js +0 -25
- package/dist/types/data-structures/binary-tree/red-black-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/segment-tree.js +0 -2
- package/dist/types/data-structures/binary-tree/tree-counter.js +0 -2
- package/dist/types/data-structures/binary-tree/tree-multi-map.js +0 -2
- package/dist/types/data-structures/graph/abstract-graph.js +0 -2
- package/dist/types/data-structures/graph/directed-graph.js +0 -2
- package/dist/types/data-structures/graph/index.js +0 -19
- package/dist/types/data-structures/graph/map-graph.js +0 -2
- package/dist/types/data-structures/graph/undirected-graph.js +0 -2
- package/dist/types/data-structures/hash/hash-map.js +0 -2
- package/dist/types/data-structures/hash/index.js +0 -17
- package/dist/types/data-structures/heap/heap.js +0 -2
- package/dist/types/data-structures/heap/index.js +0 -17
- package/dist/types/data-structures/heap/max-heap.js +0 -2
- package/dist/types/data-structures/heap/min-heap.js +0 -2
- package/dist/types/data-structures/index.js +0 -28
- package/dist/types/data-structures/linked-list/doubly-linked-list.js +0 -2
- package/dist/types/data-structures/linked-list/index.js +0 -19
- package/dist/types/data-structures/linked-list/singly-linked-list.js +0 -2
- package/dist/types/data-structures/linked-list/skip-linked-list.js +0 -2
- package/dist/types/data-structures/matrix/index.js +0 -18
- package/dist/types/data-structures/matrix/matrix.js +0 -2
- package/dist/types/data-structures/matrix/navigator.js +0 -2
- package/dist/types/data-structures/priority-queue/index.js +0 -19
- package/dist/types/data-structures/priority-queue/max-priority-queue.js +0 -2
- package/dist/types/data-structures/priority-queue/min-priority-queue.js +0 -2
- package/dist/types/data-structures/priority-queue/priority-queue.js +0 -2
- package/dist/types/data-structures/queue/deque.js +0 -2
- package/dist/types/data-structures/queue/index.js +0 -18
- package/dist/types/data-structures/queue/queue.js +0 -2
- package/dist/types/data-structures/stack/index.js +0 -17
- package/dist/types/data-structures/stack/stack.js +0 -2
- package/dist/types/data-structures/tree/index.js +0 -17
- package/dist/types/data-structures/tree/tree.js +0 -2
- package/dist/types/data-structures/trie/index.js +0 -17
- package/dist/types/data-structures/trie/trie.js +0 -2
- package/dist/types/index.js +0 -19
- package/dist/types/utils/index.js +0 -18
- package/dist/types/utils/utils.js +0 -2
- package/dist/types/utils/validate-type.js +0 -2
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -18
- package/dist/utils/number.js +0 -24
- package/dist/utils/utils.d.ts +0 -209
- package/dist/utils/utils.js +0 -353
- package/dist/{common → types/common}/index.d.ts +0 -0
- package/dist/{constants → types/constants}/index.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/iterable-element-base.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/iterable-entry-base.d.ts +0 -0
- package/dist/{data-structures → types/data-structures}/base/linear-base.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/doubly-linked-list.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/graph.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/heap.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/index.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/navigator.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/priority-queue.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/segment-tree.d.ts +0 -0
- package/dist/{interfaces → types/interfaces}/singly-linked-list.d.ts +0 -0
- package/dist/types/{common.d.ts → types/common.d.ts} +0 -0
- package/dist/types/{data-structures → types/data-structures}/base/base.d.ts +0 -0
- package/dist/{data-structures → types/types/data-structures}/index.d.ts +7 -7
- package/dist/{data-structures → types/types/data-structures}/linked-list/index.d.ts +0 -0
- package/dist/{data-structures → types/types/data-structures}/matrix/index.d.ts +1 -1
- /package/dist/{data-structures → types/types/data-structures}/priority-queue/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/queue/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/stack/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/tree/index.d.ts +0 -0
- /package/dist/{data-structures → types/types/data-structures}/trie/index.d.ts +0 -0
- /package/dist/types/{utils → types/utils}/validate-type.d.ts +0 -0
- /package/dist/{utils → types/utils}/number.d.ts +0 -0
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* data-structure-typed
|
|
3
|
-
*
|
|
4
|
-
* @author Pablo Zeng
|
|
5
|
-
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
|
-
* @license MIT License
|
|
7
|
-
*/
|
|
8
|
-
import type { GraphOptions, VertexKey } from '../../types';
|
|
9
|
-
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
|
|
10
|
-
import { IGraph } from '../../interfaces';
|
|
11
|
-
export declare class DirectedVertex<V = any> extends AbstractVertex<V> {
|
|
12
|
-
constructor(key: VertexKey, value?: V);
|
|
13
|
-
}
|
|
14
|
-
export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
|
|
15
|
-
src: VertexKey;
|
|
16
|
-
dest: VertexKey;
|
|
17
|
-
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Directed graph implementation.
|
|
21
|
-
* @template V - Vertex value type.
|
|
22
|
-
* @template E - Edge value type.
|
|
23
|
-
* @template VO - Concrete vertex class (extends AbstractVertex<V>).
|
|
24
|
-
* @template EO - Concrete edge class (extends AbstractEdge<E>).
|
|
25
|
-
* @remarks Time O(1), Space O(1)
|
|
26
|
-
* @example examples will be generated by unit test
|
|
27
|
-
*/
|
|
28
|
-
export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V> = DirectedVertex<V>, EO extends DirectedEdge<E> = DirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
|
|
29
|
-
/**
|
|
30
|
-
* Construct a directed graph with runtime defaults.
|
|
31
|
-
* @param options - `GraphOptions<V>` (e.g. `vertexValueInitializer`, `defaultEdgeWeight`).
|
|
32
|
-
* @remarks Time O(1), Space O(1)
|
|
33
|
-
*/
|
|
34
|
-
constructor(options?: Partial<GraphOptions<V>>);
|
|
35
|
-
protected _outEdgeMap: Map<VO, EO[]>;
|
|
36
|
-
get outEdgeMap(): Map<VO, EO[]>;
|
|
37
|
-
set outEdgeMap(v: Map<VO, EO[]>);
|
|
38
|
-
protected _inEdgeMap: Map<VO, EO[]>;
|
|
39
|
-
get inEdgeMap(): Map<VO, EO[]>;
|
|
40
|
-
set inEdgeMap(v: Map<VO, EO[]>);
|
|
41
|
-
/**
|
|
42
|
-
* Construct a directed graph from keys with value initializer `v => v`.
|
|
43
|
-
* @template K - Vertex key type.
|
|
44
|
-
* @param keys - Iterable of vertex keys.
|
|
45
|
-
* @returns DirectedGraph with all keys added.
|
|
46
|
-
* @remarks Time O(V), Space O(V)
|
|
47
|
-
*/
|
|
48
|
-
static fromKeys<K extends VertexKey>(keys: Iterable<K>): DirectedGraph<K, any, DirectedVertex<K>, DirectedEdge<any>>;
|
|
49
|
-
/**
|
|
50
|
-
* Construct a directed graph from `[key, value]` entries.
|
|
51
|
-
* @template V - Vertex value type.
|
|
52
|
-
* @param entries - Iterable of `[key, value]` pairs.
|
|
53
|
-
* @returns DirectedGraph with all vertices added.
|
|
54
|
-
* @remarks Time O(V), Space O(V)
|
|
55
|
-
*/
|
|
56
|
-
static fromEntries<V>(entries: Iterable<[VertexKey, V]>): DirectedGraph<V, any, DirectedVertex<V>, DirectedEdge<any>>;
|
|
57
|
-
/**
|
|
58
|
-
* Create a directed vertex instance. Does not insert into the graph.
|
|
59
|
-
* @param key - Vertex identifier.
|
|
60
|
-
* @param value - Optional payload.
|
|
61
|
-
* @returns Concrete vertex instance.
|
|
62
|
-
* @remarks Time O(1), Space O(1)
|
|
63
|
-
*/
|
|
64
|
-
createVertex(key: VertexKey, value?: VO['value']): VO;
|
|
65
|
-
/**
|
|
66
|
-
* Create a directed edge instance. Does not insert into the graph.
|
|
67
|
-
* @param src - Source vertex key.
|
|
68
|
-
* @param dest - Destination vertex key.
|
|
69
|
-
* @param weight - Edge weight; defaults to `defaultEdgeWeight`.
|
|
70
|
-
* @param value - Edge payload.
|
|
71
|
-
* @returns Concrete edge instance.
|
|
72
|
-
* @remarks Time O(1), Space O(1)
|
|
73
|
-
*/
|
|
74
|
-
createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
|
|
75
|
-
/**
|
|
76
|
-
* Get the unique edge from `src` to `dest`, if present.
|
|
77
|
-
* @param srcOrKey - Source vertex or key.
|
|
78
|
-
* @param destOrKey - Destination vertex or key.
|
|
79
|
-
* @returns Edge instance or `undefined`.
|
|
80
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
81
|
-
*/
|
|
82
|
-
getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* Delete edge `src -> dest` if present.
|
|
85
|
-
* @param srcOrKey - Source vertex or key.
|
|
86
|
-
* @param destOrKey - Destination vertex or key.
|
|
87
|
-
* @returns Removed edge or `undefined`.
|
|
88
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
89
|
-
*/
|
|
90
|
-
deleteEdgeSrcToDest(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | undefined;
|
|
91
|
-
/**
|
|
92
|
-
* Delete an edge by instance or by `(srcKey, destKey)`.
|
|
93
|
-
* @param edgeOrSrcVertexKey - Edge instance or source vertex/key.
|
|
94
|
-
* @param destVertexKey - Optional destination vertex/key when deleting by pair.
|
|
95
|
-
* @returns Removed edge or `undefined`.
|
|
96
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
97
|
-
*/
|
|
98
|
-
deleteEdge(edgeOrSrcVertexKey: EO | VertexKey, destVertexKey?: VertexKey): EO | undefined;
|
|
99
|
-
deleteVertex(vertexOrKey: VO | VertexKey): boolean;
|
|
100
|
-
deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];
|
|
101
|
-
/**
|
|
102
|
-
* Incoming edges of a vertex.
|
|
103
|
-
* @param vertexOrKey - Vertex or key.
|
|
104
|
-
* @returns Array of incoming edges.
|
|
105
|
-
* @remarks Time O(deg_in), Space O(deg_in)
|
|
106
|
-
*/
|
|
107
|
-
incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
|
|
108
|
-
/**
|
|
109
|
-
* Outgoing edges of a vertex.
|
|
110
|
-
* @param vertexOrKey - Vertex or key.
|
|
111
|
-
* @returns Array of outgoing edges.
|
|
112
|
-
* @remarks Time O(deg_out), Space O(deg_out)
|
|
113
|
-
*/
|
|
114
|
-
outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];
|
|
115
|
-
/**
|
|
116
|
-
* Degree (in + out) of a vertex.
|
|
117
|
-
* @param vertexOrKey - Vertex or key.
|
|
118
|
-
* @returns Non-negative integer.
|
|
119
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
120
|
-
*/
|
|
121
|
-
degreeOf(vertexOrKey: VertexKey | VO): number;
|
|
122
|
-
inDegreeOf(vertexOrKey: VertexKey | VO): number;
|
|
123
|
-
outDegreeOf(vertexOrKey: VertexKey | VO): number;
|
|
124
|
-
/**
|
|
125
|
-
* All incident edges of a vertex.
|
|
126
|
-
* @param vertexOrKey - Vertex or key.
|
|
127
|
-
* @returns Array of incident edges.
|
|
128
|
-
* @remarks Time O(deg_in + deg_out), Space O(deg_in + deg_out)
|
|
129
|
-
*/
|
|
130
|
-
edgesOf(vertexOrKey: VertexKey | VO): EO[];
|
|
131
|
-
getEdgeSrc(e: EO): VO | undefined;
|
|
132
|
-
getEdgeDest(e: EO): VO | undefined;
|
|
133
|
-
/**
|
|
134
|
-
* Direct children reachable by one outgoing edge.
|
|
135
|
-
* @param vertex - Vertex or key.
|
|
136
|
-
* @returns Array of neighbor vertices.
|
|
137
|
-
* @remarks Time O(deg_out), Space O(deg_out)
|
|
138
|
-
*/
|
|
139
|
-
getDestinations(vertex: VO | VertexKey | undefined): VO[];
|
|
140
|
-
/**
|
|
141
|
-
* Topological sort if DAG; returns `undefined` if a cycle exists.
|
|
142
|
-
* @param propertyName - `'key'` to map to keys; `'vertex'` to keep instances.
|
|
143
|
-
* @returns Array of keys/vertices, or `undefined` when cycle is found.
|
|
144
|
-
* @remarks Time O(V + E), Space O(V)
|
|
145
|
-
*/
|
|
146
|
-
topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined;
|
|
147
|
-
edgeSet(): EO[];
|
|
148
|
-
getNeighbors(vertexOrKey: VO | VertexKey): VO[];
|
|
149
|
-
/**
|
|
150
|
-
* Resolve an edge's `[src, dest]` endpoints to vertex instances.
|
|
151
|
-
* @param edge - Edge instance.
|
|
152
|
-
* @returns `[src, dest]` or `undefined` if either endpoint is missing.
|
|
153
|
-
* @remarks Time O(1), Space O(1)
|
|
154
|
-
*/
|
|
155
|
-
getEndsOfEdge(edge: EO): [VO, VO] | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* Whether the graph has no vertices and no edges.
|
|
158
|
-
* @remarks Time O(1), Space O(1)
|
|
159
|
-
*/
|
|
160
|
-
isEmpty(): boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Remove all vertices and edges.
|
|
163
|
-
* @remarks Time O(V + E), Space O(1)
|
|
164
|
-
*/
|
|
165
|
-
clear(): void;
|
|
166
|
-
/**
|
|
167
|
-
* Deep clone as the same concrete class.
|
|
168
|
-
* @returns A new graph of the same concrete class (`this` type).
|
|
169
|
-
* @remarks Time O(V + E), Space O(V + E)
|
|
170
|
-
*/
|
|
171
|
-
clone(): this;
|
|
172
|
-
/**
|
|
173
|
-
* Tarjan's algorithm for strongly connected components.
|
|
174
|
-
* @returns `{ dfnMap, lowMap, SCCs }`.
|
|
175
|
-
* @remarks Time O(V + E), Space O(V + E)
|
|
176
|
-
*/
|
|
177
|
-
tarjan(): {
|
|
178
|
-
dfnMap: Map<VO, number>;
|
|
179
|
-
lowMap: Map<VO, number>;
|
|
180
|
-
SCCs: Map<number, VO[]>;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* DFN index map computed by `tarjan()`.
|
|
184
|
-
* @returns Map from vertex to DFN index.
|
|
185
|
-
* @remarks Time O(V), Space O(V)
|
|
186
|
-
*/
|
|
187
|
-
getDFNMap(): Map<VO, number>;
|
|
188
|
-
/**
|
|
189
|
-
* LOW link map computed by `tarjan()`.
|
|
190
|
-
* @returns Map from vertex to LOW value.
|
|
191
|
-
* @remarks Time O(V), Space O(V)
|
|
192
|
-
*/
|
|
193
|
-
getLowMap(): Map<VO, number>;
|
|
194
|
-
/**
|
|
195
|
-
* Strongly connected components computed by `tarjan()`.
|
|
196
|
-
* @returns Map from SCC id to vertices.
|
|
197
|
-
* @remarks Time O(#SCC + V), Space O(V)
|
|
198
|
-
*/
|
|
199
|
-
getSCCs(): Map<number, VO[]>;
|
|
200
|
-
/**
|
|
201
|
-
* Internal hook to attach a directed edge into adjacency maps.
|
|
202
|
-
* @param edge - Edge instance.
|
|
203
|
-
* @returns `true` if inserted; otherwise `false`.
|
|
204
|
-
* @remarks Time O(1) avg, Space O(1)
|
|
205
|
-
*/
|
|
206
|
-
protected _addEdge(edge: EO): boolean;
|
|
207
|
-
}
|