data-structure-typed 1.18.0 → 1.18.6
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/README.md +193 -66
- package/backup/recursive-type/src/assets/complexities-diff.jpg +0 -0
- package/backup/recursive-type/src/assets/data-structure-complexities.jpg +0 -0
- package/backup/recursive-type/src/assets/logo.png +0 -0
- package/backup/recursive-type/src/assets/overview-diagram-of-data-structures.png +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/aa-tree.ts +3 -0
- package/backup/recursive-type/src/data-structures/binary-tree/avl-tree.ts +288 -0
- package/backup/recursive-type/src/data-structures/binary-tree/b-tree.ts +3 -0
- package/backup/recursive-type/src/data-structures/binary-tree/binary-indexed-tree.ts +78 -0
- package/backup/recursive-type/src/data-structures/binary-tree/binary-tree.ts +1502 -0
- package/backup/recursive-type/src/data-structures/binary-tree/bst.ts +503 -0
- package/backup/recursive-type/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- package/backup/recursive-type/src/data-structures/binary-tree/index.ts +11 -0
- package/backup/recursive-type/src/data-structures/binary-tree/rb-tree.ts +110 -0
- package/backup/recursive-type/src/data-structures/binary-tree/segment-tree.ts +243 -0
- package/backup/recursive-type/src/data-structures/binary-tree/splay-tree.ts +3 -0
- package/backup/recursive-type/src/data-structures/binary-tree/tree-multiset.ts +55 -0
- package/backup/recursive-type/src/data-structures/binary-tree/two-three-tree.ts +3 -0
- package/backup/recursive-type/src/data-structures/diagrams/README.md +5 -0
- package/backup/recursive-type/src/data-structures/graph/abstract-graph.ts +985 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/mst.jpg +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/backup/recursive-type/src/data-structures/graph/diagrams/tarjan.webp +0 -0
- package/backup/recursive-type/src/data-structures/graph/directed-graph.ts +478 -0
- package/backup/recursive-type/src/data-structures/graph/index.ts +3 -0
- package/backup/recursive-type/src/data-structures/graph/undirected-graph.ts +293 -0
- package/backup/recursive-type/src/data-structures/hash/coordinate-map.ts +67 -0
- package/backup/recursive-type/src/data-structures/hash/coordinate-set.ts +56 -0
- package/backup/recursive-type/src/data-structures/hash/hash-table.ts +3 -0
- package/backup/recursive-type/src/data-structures/hash/index.ts +6 -0
- package/backup/recursive-type/src/data-structures/hash/pair.ts +3 -0
- package/backup/recursive-type/src/data-structures/hash/tree-map.ts +3 -0
- package/backup/recursive-type/src/data-structures/hash/tree-set.ts +3 -0
- package/backup/recursive-type/src/data-structures/heap/heap.ts +176 -0
- package/backup/recursive-type/src/data-structures/heap/index.ts +3 -0
- package/backup/recursive-type/src/data-structures/heap/max-heap.ts +31 -0
- package/backup/recursive-type/src/data-structures/heap/min-heap.ts +34 -0
- package/backup/recursive-type/src/data-structures/index.ts +15 -0
- package/backup/recursive-type/src/data-structures/interfaces/abstract-graph.ts +42 -0
- package/backup/recursive-type/src/data-structures/interfaces/avl-tree.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/binary-tree.ts +56 -0
- package/backup/recursive-type/src/data-structures/interfaces/bst.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/directed-graph.ts +15 -0
- package/backup/recursive-type/src/data-structures/interfaces/doubly-linked-list.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/heap.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/index.ts +13 -0
- package/backup/recursive-type/src/data-structures/interfaces/navigator.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/priority-queue.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/segment-tree.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/singly-linked-list.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/tree-multiset.ts +1 -0
- package/backup/recursive-type/src/data-structures/interfaces/undirected-graph.ts +3 -0
- package/backup/recursive-type/src/data-structures/linked-list/doubly-linked-list.ts +573 -0
- package/backup/recursive-type/src/data-structures/linked-list/index.ts +3 -0
- package/backup/recursive-type/src/data-structures/linked-list/singly-linked-list.ts +490 -0
- package/backup/recursive-type/src/data-structures/linked-list/skip-linked-list.ts +3 -0
- package/backup/recursive-type/src/data-structures/matrix/index.ts +4 -0
- package/backup/recursive-type/src/data-structures/matrix/matrix.ts +27 -0
- package/backup/recursive-type/src/data-structures/matrix/matrix2d.ts +208 -0
- package/backup/recursive-type/src/data-structures/matrix/navigator.ts +122 -0
- package/backup/recursive-type/src/data-structures/matrix/vector2d.ts +316 -0
- package/backup/recursive-type/src/data-structures/priority-queue/index.ts +3 -0
- package/backup/recursive-type/src/data-structures/priority-queue/max-priority-queue.ts +49 -0
- package/backup/recursive-type/src/data-structures/priority-queue/min-priority-queue.ts +50 -0
- package/backup/recursive-type/src/data-structures/priority-queue/priority-queue.ts +354 -0
- package/backup/recursive-type/src/data-structures/queue/deque.ts +251 -0
- package/backup/recursive-type/src/data-structures/queue/index.ts +2 -0
- package/backup/recursive-type/src/data-structures/queue/queue.ts +120 -0
- package/backup/recursive-type/src/data-structures/stack/index.ts +1 -0
- package/backup/recursive-type/src/data-structures/stack/stack.ts +98 -0
- package/backup/recursive-type/src/data-structures/tree/index.ts +1 -0
- package/backup/recursive-type/src/data-structures/tree/tree.ts +80 -0
- package/backup/recursive-type/src/data-structures/trie/index.ts +1 -0
- package/backup/recursive-type/src/data-structures/trie/trie.ts +227 -0
- package/backup/recursive-type/src/data-structures/types/abstract-graph.ts +5 -0
- package/backup/recursive-type/src/data-structures/types/avl-tree.ts +8 -0
- package/backup/recursive-type/src/data-structures/types/binary-tree.ts +10 -0
- package/backup/recursive-type/src/data-structures/types/bst.ts +6 -0
- package/backup/recursive-type/src/data-structures/types/directed-graph.ts +8 -0
- package/backup/recursive-type/src/data-structures/types/doubly-linked-list.ts +1 -0
- package/backup/recursive-type/src/data-structures/types/heap.ts +5 -0
- package/backup/recursive-type/src/data-structures/types/index.ts +12 -0
- package/backup/recursive-type/src/data-structures/types/navigator.ts +13 -0
- package/backup/recursive-type/src/data-structures/types/priority-queue.ts +9 -0
- package/backup/recursive-type/src/data-structures/types/segment-tree.ts +1 -0
- package/backup/recursive-type/src/data-structures/types/singly-linked-list.ts +1 -0
- package/backup/recursive-type/src/data-structures/types/tree-multiset.ts +1 -0
- package/backup/recursive-type/src/index.ts +1 -0
- package/backup/recursive-type/src/utils/index.ts +2 -0
- package/backup/recursive-type/src/utils/types/index.ts +1 -0
- package/backup/recursive-type/src/utils/types/utils.ts +6 -0
- package/backup/recursive-type/src/utils/utils.ts +78 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +333 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +1455 -0
- package/dist/data-structures/binary-tree/avl-tree.d.ts +20 -25
- package/dist/data-structures/binary-tree/avl-tree.js +10 -18
- package/dist/data-structures/binary-tree/binary-tree.d.ts +18 -345
- package/dist/data-structures/binary-tree/binary-tree.js +39 -1444
- package/dist/data-structures/binary-tree/bst.d.ts +24 -31
- package/dist/data-structures/binary-tree/bst.js +46 -53
- package/dist/data-structures/binary-tree/index.d.ts +1 -0
- package/dist/data-structures/binary-tree/index.js +1 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +1 -2
- package/dist/data-structures/binary-tree/rb-tree.js +64 -5
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +11 -25
- package/dist/data-structures/binary-tree/tree-multiset.js +29 -31
- package/dist/data-structures/graph/abstract-graph.d.ts +56 -58
- package/dist/data-structures/graph/abstract-graph.js +84 -68
- package/dist/data-structures/graph/directed-graph.d.ts +124 -95
- package/dist/data-structures/graph/directed-graph.js +156 -108
- package/dist/data-structures/graph/undirected-graph.d.ts +83 -58
- package/dist/data-structures/graph/undirected-graph.js +98 -71
- package/dist/data-structures/hash/coordinate-set.d.ts +1 -1
- package/dist/data-structures/index.d.ts +1 -0
- package/dist/data-structures/index.js +1 -0
- package/dist/data-structures/interfaces/abstract-graph.d.ts +22 -0
- package/dist/data-structures/interfaces/abstract-graph.js +2 -0
- package/dist/data-structures/interfaces/avl-tree.d.ts +1 -0
- package/dist/data-structures/interfaces/avl-tree.js +2 -0
- package/dist/data-structures/interfaces/binary-tree.d.ts +26 -0
- package/dist/data-structures/interfaces/binary-tree.js +2 -0
- package/dist/data-structures/interfaces/bst.d.ts +1 -0
- package/dist/data-structures/interfaces/bst.js +2 -0
- package/dist/data-structures/interfaces/directed-graph.d.ts +9 -0
- package/dist/data-structures/interfaces/directed-graph.js +2 -0
- package/dist/data-structures/interfaces/doubly-linked-list.d.ts +1 -0
- package/dist/data-structures/interfaces/doubly-linked-list.js +2 -0
- package/dist/data-structures/interfaces/heap.d.ts +1 -0
- package/dist/data-structures/interfaces/heap.js +2 -0
- package/dist/data-structures/interfaces/index.d.ts +13 -0
- package/dist/data-structures/interfaces/index.js +29 -0
- package/dist/data-structures/interfaces/navigator.d.ts +1 -0
- package/dist/data-structures/interfaces/navigator.js +2 -0
- package/dist/data-structures/interfaces/priority-queue.d.ts +1 -0
- package/dist/data-structures/interfaces/priority-queue.js +2 -0
- package/dist/data-structures/interfaces/segment-tree.d.ts +1 -0
- package/dist/data-structures/interfaces/segment-tree.js +2 -0
- package/dist/data-structures/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/data-structures/interfaces/singly-linked-list.js +2 -0
- package/dist/data-structures/interfaces/tree-multiset.d.ts +1 -0
- package/dist/data-structures/interfaces/tree-multiset.js +2 -0
- package/dist/data-structures/interfaces/undirected-graph.d.ts +2 -0
- package/dist/data-structures/interfaces/undirected-graph.js +2 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/data-structures/priority-queue/priority-queue.js +4 -4
- package/dist/data-structures/queue/deque.d.ts +5 -5
- package/dist/data-structures/queue/deque.js +6 -6
- package/dist/data-structures/queue/queue.d.ts +1 -1
- package/dist/data-structures/stack/stack.d.ts +1 -1
- package/dist/data-structures/types/abstract-binary-tree.d.ts +32 -0
- package/dist/data-structures/types/abstract-binary-tree.js +21 -0
- package/dist/data-structures/types/abstract-graph.d.ts +1 -20
- package/dist/data-structures/types/avl-tree.d.ts +3 -4
- package/dist/data-structures/types/binary-tree.d.ts +3 -10
- package/dist/data-structures/types/bst.d.ts +10 -4
- package/dist/data-structures/types/bst.js +7 -0
- package/dist/data-structures/types/directed-graph.d.ts +5 -9
- package/dist/data-structures/types/directed-graph.js +7 -0
- package/dist/data-structures/types/heap.d.ts +2 -2
- package/dist/data-structures/types/helpers.d.ts +8 -0
- package/dist/data-structures/types/helpers.js +2 -0
- package/dist/data-structures/types/index.d.ts +3 -1
- package/dist/data-structures/types/index.js +3 -1
- package/dist/data-structures/types/navigator.d.ts +2 -2
- package/dist/data-structures/types/priority-queue.d.ts +2 -2
- package/dist/data-structures/types/rb-tree.d.ts +6 -0
- package/dist/data-structures/types/rb-tree.js +8 -0
- package/dist/data-structures/types/tree-multiset.d.ts +5 -4
- package/docs/assets/search.js +1 -1
- package/docs/classes/AVLTree.html +310 -309
- package/docs/classes/AVLTreeNode.html +122 -68
- package/docs/classes/AaTree.html +30 -17
- package/docs/classes/AbstractBinaryTree.html +2023 -0
- package/docs/classes/AbstractBinaryTreeNode.html +491 -0
- package/docs/classes/AbstractEdge.html +84 -39
- package/docs/classes/AbstractGraph.html +235 -119
- package/docs/classes/AbstractVertex.html +87 -35
- package/docs/classes/ArrayDeque.html +43 -30
- package/docs/classes/BST.html +297 -285
- package/docs/classes/BSTNode.html +123 -62
- package/docs/classes/BTree.html +30 -17
- package/docs/classes/BinaryIndexedTree.html +38 -25
- package/docs/classes/BinaryTree.html +596 -589
- package/docs/classes/BinaryTreeNode.html +181 -161
- package/docs/classes/Character.html +33 -20
- package/docs/classes/CoordinateMap.html +38 -25
- package/docs/classes/CoordinateSet.html +39 -26
- package/docs/classes/Deque.html +63 -50
- package/docs/classes/DirectedEdge.html +90 -46
- package/docs/classes/DirectedGraph.html +374 -212
- package/docs/classes/DirectedVertex.html +79 -41
- package/docs/classes/DoublyLinkedList.html +68 -55
- package/docs/classes/DoublyLinkedListNode.html +40 -27
- package/docs/classes/HashTable.html +30 -17
- package/docs/classes/Heap.html +45 -32
- package/docs/classes/HeapItem.html +37 -24
- package/docs/classes/Matrix2D.html +45 -32
- package/docs/classes/MatrixNTI2D.html +33 -20
- package/docs/classes/MaxHeap.html +45 -32
- package/docs/classes/MaxPriorityQueue.html +83 -65
- package/docs/classes/MinHeap.html +45 -32
- package/docs/classes/MinPriorityQueue.html +83 -65
- package/docs/classes/Navigator.html +40 -27
- package/docs/classes/ObjectDeque.html +78 -55
- package/docs/classes/Pair.html +30 -17
- package/docs/classes/PriorityQueue.html +78 -60
- package/docs/classes/Queue.html +45 -32
- package/docs/classes/SegmentTree.html +46 -33
- package/docs/classes/SegmentTreeNode.html +49 -36
- package/docs/classes/SinglyLinkedList.html +65 -52
- package/docs/classes/SinglyLinkedListNode.html +37 -24
- package/docs/classes/SkipLinkedList.html +30 -17
- package/docs/classes/SplayTree.html +30 -17
- package/docs/classes/Stack.html +43 -30
- package/docs/classes/TreeMap.html +30 -17
- package/docs/classes/TreeMultiSet.html +330 -316
- package/docs/classes/TreeMultiSetNode.html +450 -0
- package/docs/classes/TreeNode.html +45 -32
- package/docs/classes/TreeSet.html +30 -17
- package/docs/classes/Trie.html +42 -29
- package/docs/classes/TrieNode.html +40 -27
- package/docs/classes/TwoThreeTree.html +30 -17
- package/docs/classes/UndirectedEdge.html +86 -56
- package/docs/classes/UndirectedGraph.html +286 -165
- package/docs/classes/UndirectedVertex.html +79 -41
- package/docs/classes/Vector2D.html +57 -44
- package/docs/enums/CP.html +36 -23
- package/docs/enums/FamilyPosition.html +48 -35
- package/docs/enums/LoopType.html +42 -29
- package/docs/{interfaces/PriorityQueueOptions.html → enums/RBColor.html} +52 -55
- package/docs/{interfaces/AVLTreeDeleted.html → enums/TopologicalProperty.html} +59 -48
- package/docs/index.html +211 -73
- package/docs/interfaces/{NavigatorParams.html → IBinaryTree.html} +56 -67
- package/docs/interfaces/IBinaryTreeNode.html +396 -0
- package/docs/interfaces/IDirectedGraph.html +36 -23
- package/docs/interfaces/IGraph.html +134 -93
- package/docs/interfaces/{HeapOptions.html → IUNDirectedGraph.html} +38 -57
- package/docs/modules.html +57 -31
- package/docs/types/{ToThunkFn.html → AVLTreeOptions.html} +35 -27
- package/docs/types/AbstractBinaryTreeOptions.html +150 -0
- package/docs/types/AbstractRecursiveBinaryTreeNode.html +146 -0
- package/docs/types/{ResultsByProperty.html → AbstractResultByProperty.html} +35 -22
- package/docs/types/{TreeMultiSetDeletedResult.html → AbstractResultsByProperty.html} +35 -29
- package/docs/types/BSTComparator.html +30 -17
- package/docs/types/{TrlAsyncFn.html → BSTOptions.html} +36 -31
- package/docs/types/BinaryTreeDeletedResult.html +153 -0
- package/docs/types/BinaryTreeNodeId.html +30 -17
- package/docs/types/BinaryTreeNodePropertyName.html +30 -17
- package/docs/types/{BinaryTreeDeleted.html → BinaryTreeOptions.html} +35 -31
- package/docs/types/DFSOrderPattern.html +30 -17
- package/docs/types/DijkstraResult.html +30 -17
- package/docs/types/Direction.html +30 -17
- package/docs/types/{SpecifyOptional.html → EdgeId.html} +34 -28
- package/docs/types/{TrlFn.html → HeapOptions.html} +45 -24
- package/docs/types/IdObject.html +151 -0
- package/docs/types/{BSTDeletedResult.html → KeyValObject.html} +36 -30
- package/docs/types/NavigatorParams.html +175 -0
- package/docs/types/NodeOrPropertyName.html +30 -17
- package/docs/types/PriorityQueueComparator.html +30 -17
- package/docs/types/PriorityQueueDFSOrderPattern.html +30 -17
- package/docs/types/PriorityQueueOptions.html +155 -0
- package/docs/types/{Thunk.html → RBTreeOptions.html} +35 -27
- package/docs/types/RecursiveAVLTreeNode.html +146 -0
- package/docs/types/RecursiveBSTNode.html +146 -0
- package/docs/types/RecursiveBinaryTreeNode.html +146 -0
- package/docs/types/RecursiveTreeMultiSetNode.html +146 -0
- package/docs/types/SegmentTreeNodeVal.html +30 -17
- package/docs/types/TopologicalStatus.html +30 -17
- package/docs/types/TreeMultiSetOptions.html +146 -0
- package/docs/types/Turning.html +30 -17
- package/docs/types/VertexId.html +30 -17
- package/notes/note.md +8 -1
- package/package.json +10 -2
- package/docs/classes/RBTree.html +0 -153
- package/docs/types/ResultByProperty.html +0 -133
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { VertexId } from '../types';
|
|
3
|
+
import { IDirectedGraph } from '../interfaces';
|
|
4
|
+
export declare class DirectedVertex<T = number> extends AbstractVertex<T> {
|
|
4
5
|
/**
|
|
5
|
-
* The constructor function initializes
|
|
6
|
-
* @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is
|
|
7
|
-
* vertex
|
|
6
|
+
* The constructor function initializes a vertex with an optional value.
|
|
7
|
+
* @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is of type `VertexId`, which is
|
|
8
|
+
* typically a unique identifier for each vertex in a graph.
|
|
9
|
+
* @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to specify the value
|
|
10
|
+
* associated with the vertex.
|
|
8
11
|
*/
|
|
9
|
-
constructor(id: VertexId);
|
|
12
|
+
constructor(id: VertexId, val?: T);
|
|
10
13
|
}
|
|
11
|
-
export declare class DirectedEdge extends AbstractEdge {
|
|
14
|
+
export declare class DirectedEdge<T = number> extends AbstractEdge<T> {
|
|
12
15
|
/**
|
|
13
|
-
* The constructor function initializes the source and destination vertices of an edge, with an optional weight
|
|
16
|
+
* The constructor function initializes the source and destination vertices of an edge, along with an optional weight
|
|
17
|
+
* and value.
|
|
14
18
|
* @param {VertexId} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
|
|
15
19
|
* a graph.
|
|
16
|
-
* @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
* @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
|
|
21
|
+
* @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
|
|
22
|
+
* is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
|
|
23
|
+
* If the weight is not provided, it will default to `undefined`.
|
|
24
|
+
* @param {T} [val] - The "val" parameter is an optional parameter of type T. It represents the value associated with
|
|
25
|
+
* the edge.
|
|
26
|
+
*/
|
|
27
|
+
constructor(src: VertexId, dest: VertexId, weight?: number, val?: T);
|
|
22
28
|
private _src;
|
|
23
29
|
get src(): VertexId;
|
|
24
30
|
set src(v: VertexId);
|
|
@@ -26,142 +32,165 @@ export declare class DirectedEdge extends AbstractEdge {
|
|
|
26
32
|
get dest(): VertexId;
|
|
27
33
|
set dest(v: VertexId);
|
|
28
34
|
}
|
|
29
|
-
export declare class DirectedGraph<V extends DirectedVertex, E extends DirectedEdge> extends AbstractGraph<V, E> implements IDirectedGraph<V, E> {
|
|
30
|
-
protected _outEdgeMap: Map<V, E[]>;
|
|
31
|
-
protected _inEdgeMap: Map<V, E[]>;
|
|
35
|
+
export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge> extends AbstractGraph<V, E> implements IDirectedGraph<V, E> {
|
|
32
36
|
constructor();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
private _outEdgeMap;
|
|
38
|
+
get outEdgeMap(): Map<V, E[]>;
|
|
39
|
+
private _inEdgeMap;
|
|
40
|
+
get inEdgeMap(): Map<V, E[]>;
|
|
41
|
+
/**
|
|
42
|
+
* In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
|
|
43
|
+
* This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
|
|
44
|
+
* @param id
|
|
45
|
+
* @param val
|
|
46
|
+
*/
|
|
47
|
+
_createVertex(id: VertexId, val?: V['val']): V;
|
|
48
|
+
/**
|
|
49
|
+
* In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
|
|
50
|
+
* This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
|
|
51
|
+
* @param src
|
|
52
|
+
* @param dest
|
|
53
|
+
* @param weight
|
|
54
|
+
* @param val
|
|
55
|
+
*/
|
|
56
|
+
_createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E;
|
|
57
|
+
/**
|
|
58
|
+
* The function `getEdge` returns the directed edge between two vertices, given their source and destination.
|
|
59
|
+
* @param {V | null | VertexId} srcOrId - The source vertex or its ID. It can be either a
|
|
60
|
+
* DirectedVertex object or a VertexId.
|
|
61
|
+
* @param {V | null | VertexId} destOrId - The `destOrId` parameter is the destination vertex or its
|
|
62
|
+
* ID. It can be either a `DirectedVertex` object or a `VertexId` value.
|
|
63
|
+
* @returns a E object or null.
|
|
40
64
|
*/
|
|
41
65
|
getEdge(srcOrId: V | null | VertexId, destOrId: V | null | VertexId): E | null;
|
|
42
66
|
/**
|
|
43
|
-
* The `addEdge` function adds
|
|
44
|
-
* @param
|
|
45
|
-
*
|
|
46
|
-
* @returns The `addEdge`
|
|
47
|
-
* graph, and `false` if either the source or destination
|
|
67
|
+
* The `addEdge` function adds a directed edge to a graph if the source and destination vertices exist.
|
|
68
|
+
* @param edge - The parameter `edge` is of type `E`, which represents a directed edge in a graph. It
|
|
69
|
+
* contains two properties:
|
|
70
|
+
* @returns The method `addEdge` returns a boolean value. It returns `true` if the edge was successfully added to the
|
|
71
|
+
* graph, and `false` if either the source or destination vertex of the edge is not present in the graph.
|
|
48
72
|
*/
|
|
49
73
|
addEdge(edge: E): boolean;
|
|
50
74
|
/**
|
|
51
|
-
* The function removes an edge between two vertices in a directed graph and returns the removed
|
|
52
|
-
*
|
|
53
|
-
* @param {V | VertexId}
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* edge does not exist
|
|
75
|
+
* The `removeEdgeBetween` function removes an edge between two vertices in a directed graph and returns the removed
|
|
76
|
+
* edge, or null if the edge was not found.
|
|
77
|
+
* @param {V | VertexId} srcOrId - The `srcOrId` parameter represents either a `V`
|
|
78
|
+
* object or a `VertexId` value. It is used to specify the source vertex of the edge that you want to remove.
|
|
79
|
+
* @param {V | VertexId} destOrId - The `destOrId` parameter represents the destination vertex of the
|
|
80
|
+
* edge that you want to remove. It can be either a `V` object or a `VertexId` value.
|
|
81
|
+
* @returns The function `removeEdgeBetween` returns the removed edge (`E`) if it exists, or `null` if
|
|
82
|
+
* the edge does not exist.
|
|
59
83
|
*/
|
|
60
84
|
removeEdgeBetween(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
61
85
|
/**
|
|
62
|
-
* The removeEdge function removes
|
|
63
|
-
* found.
|
|
64
|
-
* @param
|
|
65
|
-
*
|
|
66
|
-
* @returns The
|
|
86
|
+
* The `removeEdge` function removes a directed edge from a graph and returns the removed edge, or null if the edge was
|
|
87
|
+
* not found.
|
|
88
|
+
* @param edge - The `edge` parameter is an object of type `E`, which represents a directed edge in a
|
|
89
|
+
* graph. It has two properties:
|
|
90
|
+
* @returns The function `removeEdge` returns a `E` object if an edge is successfully removed, or `null`
|
|
91
|
+
* if no edge is removed.
|
|
67
92
|
*/
|
|
68
93
|
removeEdge(edge: E): E | null;
|
|
69
94
|
/**
|
|
70
95
|
* The function removeAllEdges removes all edges between two vertices.
|
|
71
|
-
* @param {VertexId | V} src - The `src` parameter
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @returns An empty array is being returned.
|
|
96
|
+
* @param {VertexId | V} src - The `src` parameter can be either a `VertexId` or a `V`.
|
|
97
|
+
* @param {VertexId | V} dest - The `dest` parameter represents the destination vertex of an edge. It
|
|
98
|
+
* can be either a `VertexId` or a `V`.
|
|
99
|
+
* @returns An empty array of DirectedEdge objects is being returned.
|
|
76
100
|
*/
|
|
77
101
|
removeAllEdges(src: VertexId | V, dest: VertexId | V): E[];
|
|
78
102
|
/**
|
|
79
|
-
* The function
|
|
80
|
-
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a
|
|
81
|
-
*
|
|
82
|
-
* @returns The method `incomingEdgesOf` returns an array of
|
|
103
|
+
* The function returns an array of incoming edges of a given vertex or vertex ID.
|
|
104
|
+
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a `V`
|
|
105
|
+
* object or a `VertexId`.
|
|
106
|
+
* @returns The method `incomingEdgesOf` returns an array of `E` objects.
|
|
83
107
|
*/
|
|
84
108
|
incomingEdgesOf(vertexOrId: V | VertexId): E[];
|
|
85
109
|
/**
|
|
86
|
-
* The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
|
|
87
|
-
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can
|
|
88
|
-
*
|
|
89
|
-
* @returns The method `outgoingEdgesOf` returns an array of
|
|
110
|
+
* The function `outgoingEdgesOf` returns an array of outgoing directed edges from a given vertex or vertex ID.
|
|
111
|
+
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a `V`
|
|
112
|
+
* object or a `VertexId`.
|
|
113
|
+
* @returns The method `outgoingEdgesOf` returns an array of `E` objects.
|
|
90
114
|
*/
|
|
91
115
|
outgoingEdgesOf(vertexOrId: V | VertexId): E[];
|
|
92
116
|
/**
|
|
93
|
-
* The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree
|
|
94
|
-
*
|
|
95
|
-
* @
|
|
117
|
+
* The function "degreeOf" returns the total degree of a vertex in a directed graph, which is the sum of its out-degree
|
|
118
|
+
* and in-degree.
|
|
119
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
120
|
+
* `V`.
|
|
121
|
+
* @returns The sum of the out-degree and in-degree of the given vertex or vertex ID.
|
|
96
122
|
*/
|
|
97
123
|
degreeOf(vertexOrId: VertexId | V): number;
|
|
98
124
|
/**
|
|
99
|
-
* The function "inDegreeOf" returns the number of incoming edges for a given vertex.
|
|
100
|
-
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
125
|
+
* The function "inDegreeOf" returns the number of incoming edges for a given vertex or vertex ID in a directed graph.
|
|
126
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
127
|
+
* `V`.
|
|
101
128
|
* @returns The number of incoming edges of the specified vertex or vertex ID.
|
|
102
129
|
*/
|
|
103
130
|
inDegreeOf(vertexOrId: VertexId | V): number;
|
|
104
131
|
/**
|
|
105
|
-
* The function
|
|
106
|
-
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
132
|
+
* The function "outDegreeOf" returns the number of outgoing edges from a given vertex.
|
|
133
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
134
|
+
* `V`.
|
|
107
135
|
* @returns The number of outgoing edges from the specified vertex or vertex ID.
|
|
108
136
|
*/
|
|
109
137
|
outDegreeOf(vertexOrId: VertexId | V): number;
|
|
110
138
|
/**
|
|
111
|
-
* The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
|
|
112
|
-
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
113
|
-
*
|
|
139
|
+
* The function "edgesOf" returns an array of both outgoing and incoming directed edges of a given vertex or vertex ID.
|
|
140
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
141
|
+
* `V`.
|
|
142
|
+
* @returns an array of directed edges.
|
|
114
143
|
*/
|
|
115
144
|
edgesOf(vertexOrId: VertexId | V): E[];
|
|
116
145
|
/**
|
|
117
|
-
* The function "getEdgeSrc" returns the source vertex of
|
|
118
|
-
* @param
|
|
119
|
-
* @returns
|
|
146
|
+
* The function "getEdgeSrc" returns the source vertex of a directed edge, or null if the edge does not exist.
|
|
147
|
+
* @param e - A directed edge object of type E.
|
|
148
|
+
* @returns either a DirectedVertex object or null.
|
|
120
149
|
*/
|
|
121
150
|
getEdgeSrc(e: E): V | null;
|
|
122
151
|
/**
|
|
123
|
-
* The function "getEdgeDest" returns the vertex
|
|
124
|
-
* @param
|
|
125
|
-
*
|
|
152
|
+
* The function "getEdgeDest" returns the destination vertex of a directed edge.
|
|
153
|
+
* @param e - E - This is an object representing a directed edge in a graph. It contains information
|
|
154
|
+
* about the source vertex, destination vertex, and any associated data.
|
|
155
|
+
* @returns either a DirectedVertex object or null.
|
|
126
156
|
*/
|
|
127
157
|
getEdgeDest(e: E): V | null;
|
|
128
158
|
/**
|
|
129
|
-
* The function `getDestinations` returns an array of
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* @returns an array of vertices (V[]).
|
|
159
|
+
* The function `getDestinations` returns an array of directed vertices that are the destinations of outgoing edges
|
|
160
|
+
* from a given vertex.
|
|
161
|
+
* @param {V | VertexId | null} vertex - The `vertex` parameter can be one of the following:
|
|
162
|
+
* @returns an array of DirectedVertex objects.
|
|
134
163
|
*/
|
|
135
164
|
getDestinations(vertex: V | VertexId | null): V[];
|
|
136
|
-
/**--- start find cycles --- */
|
|
137
165
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* The `topologicalSort`
|
|
141
|
-
* order, or null if
|
|
142
|
-
* @returns The function `topologicalSort()` returns an array of vertices in topological order if there is no cycle in
|
|
143
|
-
* the graph. If there is a cycle, it returns `null`.
|
|
166
|
+
* The `topologicalSort` function performs a topological sort on a directed graph and returns the sorted vertices in
|
|
167
|
+
* reverse order, or null if the graph contains a cycle.
|
|
168
|
+
* @returns The function `topologicalSort()` returns an array of `V` or `VertexId` objects in
|
|
169
|
+
* topological order, or `null` if there is a cycle in the graph.
|
|
144
170
|
*/
|
|
145
171
|
topologicalSort(): Array<V | VertexId> | null;
|
|
146
|
-
/**--- end find cycles --- */
|
|
147
172
|
/**
|
|
148
|
-
* The `edgeSet` function returns an array of all
|
|
149
|
-
* @returns The `edgeSet()` method returns an array of
|
|
173
|
+
* The `edgeSet` function returns an array of all directed edges in the graph.
|
|
174
|
+
* @returns The `edgeSet()` method returns an array of `E` objects.
|
|
150
175
|
*/
|
|
151
176
|
edgeSet(): E[];
|
|
177
|
+
/**--- start find cycles --- */
|
|
152
178
|
/**
|
|
153
|
-
* The function `getNeighbors` returns an array of neighboring vertices
|
|
154
|
-
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a
|
|
155
|
-
*
|
|
156
|
-
* @returns an array of
|
|
179
|
+
* The function `getNeighbors` returns an array of neighboring vertices of a given vertex in a directed graph.
|
|
180
|
+
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a `V`
|
|
181
|
+
* object or a `VertexId`.
|
|
182
|
+
* @returns an array of DirectedVertex objects.
|
|
157
183
|
*/
|
|
158
184
|
getNeighbors(vertexOrId: V | VertexId): V[];
|
|
185
|
+
/**--- end find cycles --- */
|
|
159
186
|
/**
|
|
160
|
-
* The function "getEndsOfEdge" returns the source and destination vertices of
|
|
161
|
-
* otherwise it returns null.
|
|
162
|
-
* @param
|
|
163
|
-
* @returns an array containing
|
|
164
|
-
*
|
|
187
|
+
* The function "getEndsOfEdge" returns the source and destination vertices of a directed edge if it exists in the
|
|
188
|
+
* graph, otherwise it returns null.
|
|
189
|
+
* @param edge - A directed edge object with a generic type E.
|
|
190
|
+
* @returns an array containing the starting and ending vertices of the given directed edge, or null if the edge does
|
|
191
|
+
* not exist in the graph.
|
|
165
192
|
*/
|
|
166
193
|
getEndsOfEdge(edge: E): [V, V] | null;
|
|
194
|
+
protected _setOutEdgeMap(value: Map<V, E[]>): void;
|
|
195
|
+
protected _setInEdgeMap(value: Map<V, E[]>): void;
|
|
167
196
|
}
|