data-structure-typed 1.17.4 → 1.18.5
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/avl-tree.d.ts +19 -25
- package/dist/data-structures/binary-tree/avl-tree.js +12 -20
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +10 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +135 -161
- package/dist/data-structures/binary-tree/binary-tree.js +192 -164
- package/dist/data-structures/binary-tree/bst.d.ts +21 -21
- package/dist/data-structures/binary-tree/bst.js +33 -36
- package/dist/data-structures/binary-tree/rb-tree.d.ts +1 -2
- package/dist/data-structures/binary-tree/rb-tree.js +68 -5
- package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -39
- package/dist/data-structures/binary-tree/segment-tree.js +34 -47
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +9 -8
- package/dist/data-structures/binary-tree/tree-multiset.js +7 -6
- package/dist/data-structures/graph/abstract-graph.d.ts +56 -71
- package/dist/data-structures/graph/abstract-graph.js +87 -92
- package/dist/data-structures/graph/directed-graph.d.ts +128 -105
- package/dist/data-structures/graph/directed-graph.js +161 -121
- package/dist/data-structures/graph/undirected-graph.d.ts +81 -62
- package/dist/data-structures/graph/undirected-graph.js +99 -78
- package/dist/data-structures/hash/coordinate-map.d.ts +1 -5
- package/dist/data-structures/hash/coordinate-map.js +3 -9
- package/dist/data-structures/hash/coordinate-set.d.ts +2 -6
- package/dist/data-structures/hash/coordinate-set.js +3 -9
- package/dist/data-structures/hash/hash-table.d.ts +2 -1
- package/dist/data-structures/hash/hash-table.js +7 -0
- package/dist/data-structures/hash/pair.d.ts +2 -1
- package/dist/data-structures/hash/pair.js +7 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -1
- package/dist/data-structures/hash/tree-map.js +7 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -1
- package/dist/data-structures/hash/tree-set.js +7 -0
- package/dist/data-structures/heap/heap.d.ts +0 -14
- package/dist/data-structures/heap/heap.js +3 -27
- 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 +27 -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 -3
- package/dist/data-structures/linked-list/doubly-linked-list.js +12 -18
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -2
- package/dist/data-structures/linked-list/singly-linked-list.js +12 -15
- 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/tree/tree.d.ts +12 -4
- package/dist/data-structures/tree/tree.js +44 -12
- package/dist/data-structures/trie/trie.d.ts +3 -3
- package/dist/data-structures/trie/trie.js +10 -10
- package/dist/data-structures/types/abstract-graph.d.ts +1 -20
- package/dist/data-structures/types/avl-tree.d.ts +5 -4
- package/dist/data-structures/types/binary-tree.d.ts +6 -5
- package/dist/data-structures/types/bst.d.ts +4 -3
- 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/doubly-linked-list.d.ts +1 -1
- package/dist/data-structures/types/heap.d.ts +2 -2
- package/dist/data-structures/types/index.d.ts +0 -1
- package/dist/data-structures/types/index.js +0 -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/tree-multiset.d.ts +3 -4
- package/docs/assets/search.js +1 -1
- package/docs/classes/AVLTree.html +552 -405
- package/docs/classes/AVLTreeNode.html +107 -242
- package/docs/classes/AaTree.html +18 -13
- package/docs/classes/AbstractEdge.html +77 -68
- package/docs/classes/AbstractGraph.html +223 -115
- package/docs/classes/AbstractVertex.html +71 -45
- package/docs/classes/ArrayDeque.html +31 -26
- package/docs/classes/BST.html +543 -391
- package/docs/classes/BSTNode.html +107 -236
- package/docs/classes/BTree.html +18 -13
- package/docs/classes/BinaryIndexedTree.html +56 -21
- package/docs/classes/BinaryTree.html +564 -355
- package/docs/classes/BinaryTreeNode.html +146 -199
- package/docs/classes/Character.html +21 -16
- package/docs/classes/CoordinateMap.html +49 -52
- package/docs/classes/CoordinateSet.html +50 -53
- package/docs/classes/Deque.html +51 -68
- package/docs/classes/DirectedEdge.html +98 -103
- package/docs/classes/DirectedGraph.html +449 -210
- package/docs/classes/DirectedVertex.html +63 -52
- package/docs/classes/DoublyLinkedList.html +56 -71
- package/docs/classes/DoublyLinkedListNode.html +28 -23
- package/docs/classes/HashTable.html +155 -0
- package/docs/classes/Heap.html +33 -109
- package/docs/classes/HeapItem.html +25 -20
- package/docs/classes/Matrix2D.html +33 -28
- package/docs/classes/MatrixNTI2D.html +21 -16
- package/docs/classes/MaxHeap.html +33 -114
- package/docs/classes/MaxPriorityQueue.html +71 -61
- package/docs/classes/MinHeap.html +33 -114
- package/docs/classes/MinPriorityQueue.html +71 -61
- package/docs/classes/Navigator.html +28 -23
- package/docs/classes/ObjectDeque.html +66 -51
- package/docs/classes/{RBTree.html → Pair.html} +25 -20
- package/docs/classes/PriorityQueue.html +66 -56
- package/docs/classes/Queue.html +33 -28
- package/docs/classes/SegmentTree.html +129 -57
- package/docs/classes/SegmentTreeNode.html +62 -140
- package/docs/classes/SinglyLinkedList.html +53 -58
- package/docs/classes/SinglyLinkedListNode.html +25 -20
- package/docs/classes/SkipLinkedList.html +18 -13
- package/docs/classes/SplayTree.html +18 -13
- package/docs/classes/Stack.html +31 -26
- package/docs/classes/TreeMap.html +155 -0
- package/docs/classes/TreeMultiSet.html +541 -388
- package/docs/classes/TreeNode.html +125 -35
- package/docs/classes/TreeSet.html +155 -0
- package/docs/classes/Trie.html +30 -25
- package/docs/classes/TrieNode.html +33 -28
- package/docs/classes/TwoThreeTree.html +18 -13
- package/docs/classes/UndirectedEdge.html +87 -80
- package/docs/classes/UndirectedGraph.html +356 -178
- package/docs/classes/UndirectedVertex.html +63 -52
- package/docs/classes/Vector2D.html +45 -40
- package/docs/enums/CP.html +21 -16
- package/docs/enums/FamilyPosition.html +21 -16
- package/docs/enums/LoopType.html +20 -15
- package/docs/{interfaces/AVLTreeDeleted.html → enums/TopologicalProperty.html} +47 -44
- package/docs/index.html +203 -69
- package/docs/interfaces/{PriorityQueueOptions.html → IBinaryTree.html} +49 -40
- package/docs/interfaces/IBinaryTreeNode.html +383 -0
- package/docs/interfaces/IDirectedGraph.html +24 -19
- package/docs/interfaces/IGraph.html +122 -89
- package/docs/interfaces/{HeapOptions.html → IUNDirectedGraph.html} +26 -53
- package/docs/modules.html +33 -23
- package/docs/types/{ToThunkFn.html → AVLTreeDeleted.html} +31 -22
- package/docs/types/BSTComparator.html +18 -13
- package/docs/types/BSTDeletedResult.html +23 -18
- package/docs/types/BinaryTreeDeleted.html +23 -18
- package/docs/types/BinaryTreeNodeId.html +18 -13
- package/docs/types/BinaryTreeNodePropertyName.html +18 -13
- package/docs/types/DFSOrderPattern.html +18 -13
- package/docs/types/DijkstraResult.html +18 -13
- package/docs/types/Direction.html +18 -13
- package/docs/types/{DoublyLinkedListGetBy.html → EdgeId.html} +22 -17
- package/docs/types/{TrlFn.html → HeapOptions.html} +33 -20
- package/docs/types/{TrlAsyncFn.html → NavigatorParams.html} +46 -20
- package/docs/types/NodeOrPropertyName.html +18 -13
- package/docs/types/PriorityQueueComparator.html +18 -13
- package/docs/types/PriorityQueueDFSOrderPattern.html +18 -13
- package/docs/types/{SpecifyOptional.html → PriorityQueueOptions.html} +32 -20
- package/docs/types/RecursiveAVLTreeNode.html +135 -0
- package/docs/types/RecursiveBSTNode.html +135 -0
- package/docs/types/RecursiveBinaryTreeNode.html +135 -0
- package/docs/types/ResultByProperty.html +21 -16
- package/docs/types/ResultsByProperty.html +21 -16
- package/docs/types/SegmentTreeNodeVal.html +18 -13
- package/docs/types/TopologicalStatus.html +18 -13
- package/docs/types/TreeMultiSetDeletedResult.html +23 -18
- package/docs/types/Turning.html +18 -13
- package/docs/types/VertexId.html +18 -13
- package/notes/note.md +12 -1
- package/package.json +11 -3
- package/tsconfig.json +2 -2
- package/docs/interfaces/NavigatorParams.html +0 -197
- package/docs/types/Thunk.html +0 -133
|
@@ -64,12 +64,14 @@ var abstract_graph_1 = require("./abstract-graph");
|
|
|
64
64
|
var DirectedVertex = /** @class */ (function (_super) {
|
|
65
65
|
__extends(DirectedVertex, _super);
|
|
66
66
|
/**
|
|
67
|
-
* The constructor function initializes
|
|
68
|
-
* @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is
|
|
69
|
-
* vertex
|
|
67
|
+
* The constructor function initializes a vertex with an optional value.
|
|
68
|
+
* @param {VertexId} id - The `id` parameter is the identifier for the vertex. It is of type `VertexId`, which is
|
|
69
|
+
* typically a unique identifier for each vertex in a graph.
|
|
70
|
+
* @param {T} [val] - The "val" parameter is an optional parameter of type T. It is used to specify the value
|
|
71
|
+
* associated with the vertex.
|
|
70
72
|
*/
|
|
71
|
-
function DirectedVertex(id) {
|
|
72
|
-
return _super.call(this, id) || this;
|
|
73
|
+
function DirectedVertex(id, val) {
|
|
74
|
+
return _super.call(this, id, val) || this;
|
|
73
75
|
}
|
|
74
76
|
return DirectedVertex;
|
|
75
77
|
}(abstract_graph_1.AbstractVertex));
|
|
@@ -77,16 +79,19 @@ exports.DirectedVertex = DirectedVertex;
|
|
|
77
79
|
var DirectedEdge = /** @class */ (function (_super) {
|
|
78
80
|
__extends(DirectedEdge, _super);
|
|
79
81
|
/**
|
|
80
|
-
* The constructor function initializes the source and destination vertices of an edge, with an optional weight
|
|
82
|
+
* The constructor function initializes the source and destination vertices of an edge, along with an optional weight
|
|
83
|
+
* and value.
|
|
81
84
|
* @param {VertexId} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in
|
|
82
85
|
* a graph.
|
|
83
|
-
* @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
86
|
+
* @param {VertexId} dest - The `dest` parameter is the identifier of the destination vertex for an edge.
|
|
87
|
+
* @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. It
|
|
88
|
+
* is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms.
|
|
89
|
+
* If the weight is not provided, it will default to `undefined`.
|
|
90
|
+
* @param {T} [val] - The "val" parameter is an optional parameter of type T. It represents the value associated with
|
|
91
|
+
* the edge.
|
|
87
92
|
*/
|
|
88
|
-
function DirectedEdge(src, dest, weight) {
|
|
89
|
-
var _this = _super.call(this, weight) || this;
|
|
93
|
+
function DirectedEdge(src, dest, weight, val) {
|
|
94
|
+
var _this = _super.call(this, weight, val) || this;
|
|
90
95
|
_this._src = src;
|
|
91
96
|
_this._dest = dest;
|
|
92
97
|
return _this;
|
|
@@ -111,43 +116,69 @@ var DirectedEdge = /** @class */ (function (_super) {
|
|
|
111
116
|
enumerable: false,
|
|
112
117
|
configurable: true
|
|
113
118
|
});
|
|
114
|
-
/**
|
|
115
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
116
|
-
*/
|
|
117
|
-
DirectedEdge.prototype.getSrc = function () {
|
|
118
|
-
return this._src;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
122
|
-
*/
|
|
123
|
-
DirectedEdge.prototype.getDest = function () {
|
|
124
|
-
return this._dest;
|
|
125
|
-
};
|
|
126
119
|
return DirectedEdge;
|
|
127
120
|
}(abstract_graph_1.AbstractEdge));
|
|
128
121
|
exports.DirectedEdge = DirectedEdge;
|
|
129
122
|
// Strongly connected, One direction connected, Weakly connected
|
|
130
123
|
var DirectedGraph = /** @class */ (function (_super) {
|
|
131
124
|
__extends(DirectedGraph, _super);
|
|
132
|
-
function DirectedGraph() {
|
|
125
|
+
function DirectedGraph(vertexConstructor, edgeConstructor) {
|
|
133
126
|
var _this = _super.call(this) || this;
|
|
134
127
|
_this._outEdgeMap = new Map();
|
|
135
128
|
_this._inEdgeMap = new Map();
|
|
129
|
+
_this._vertexConstructor = vertexConstructor;
|
|
130
|
+
_this._edgeConstructor = edgeConstructor;
|
|
136
131
|
return _this;
|
|
137
132
|
}
|
|
133
|
+
Object.defineProperty(DirectedGraph.prototype, "outEdgeMap", {
|
|
134
|
+
get: function () {
|
|
135
|
+
return this._outEdgeMap;
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(DirectedGraph.prototype, "inEdgeMap", {
|
|
141
|
+
get: function () {
|
|
142
|
+
return this._inEdgeMap;
|
|
143
|
+
},
|
|
144
|
+
enumerable: false,
|
|
145
|
+
configurable: true
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* 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.
|
|
149
|
+
* 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.
|
|
150
|
+
* @param id
|
|
151
|
+
* @param val
|
|
152
|
+
*/
|
|
153
|
+
DirectedGraph.prototype._createVertex = function (id, val) {
|
|
154
|
+
return new this._vertexConstructor(id, val);
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* 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.
|
|
158
|
+
* 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.
|
|
159
|
+
* @param src
|
|
160
|
+
* @param dest
|
|
161
|
+
* @param weight
|
|
162
|
+
* @param val
|
|
163
|
+
*/
|
|
164
|
+
DirectedGraph.prototype._createEdge = function (src, dest, weight, val) {
|
|
165
|
+
if (weight === undefined || weight === null)
|
|
166
|
+
weight = 1;
|
|
167
|
+
return new this._edgeConstructor(src, dest, weight, val);
|
|
168
|
+
};
|
|
138
169
|
/**
|
|
139
|
-
* The function `getEdge` returns the
|
|
140
|
-
* @param {V | null | VertexId} srcOrId - The
|
|
141
|
-
*
|
|
142
|
-
* @param {V | null | VertexId} destOrId - The `destOrId` parameter is
|
|
143
|
-
*
|
|
144
|
-
* @returns
|
|
170
|
+
* The function `getEdge` returns the directed edge between two vertices, given their source and destination.
|
|
171
|
+
* @param {V | null | VertexId} srcOrId - The source vertex or its ID. It can be either a
|
|
172
|
+
* DirectedVertex object or a VertexId.
|
|
173
|
+
* @param {V | null | VertexId} destOrId - The `destOrId` parameter is the destination vertex or its
|
|
174
|
+
* ID. It can be either a `DirectedVertex` object or a `VertexId` value.
|
|
175
|
+
* @returns a E object or null.
|
|
145
176
|
*/
|
|
146
177
|
DirectedGraph.prototype.getEdge = function (srcOrId, destOrId) {
|
|
147
178
|
var edges = [];
|
|
148
179
|
if (srcOrId !== null && destOrId !== null) {
|
|
149
|
-
var src = this.
|
|
150
|
-
var dest_1 = this.
|
|
180
|
+
var src = this._getVertex(srcOrId);
|
|
181
|
+
var dest_1 = this._getVertex(destOrId);
|
|
151
182
|
if (src && dest_1) {
|
|
152
183
|
var srcOutEdges = this._outEdgeMap.get(src);
|
|
153
184
|
if (srcOutEdges) {
|
|
@@ -158,18 +189,18 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
158
189
|
return edges[0] || null;
|
|
159
190
|
};
|
|
160
191
|
/**
|
|
161
|
-
* The `addEdge` function adds
|
|
162
|
-
* @param
|
|
163
|
-
*
|
|
164
|
-
* @returns The `addEdge`
|
|
165
|
-
* graph, and `false` if either the source or destination
|
|
192
|
+
* The `addEdge` function adds a directed edge to a graph if the source and destination vertices exist.
|
|
193
|
+
* @param edge - The parameter `edge` is of type `E`, which represents a directed edge in a graph. It
|
|
194
|
+
* contains two properties:
|
|
195
|
+
* @returns The method `addEdge` returns a boolean value. It returns `true` if the edge was successfully added to the
|
|
196
|
+
* graph, and `false` if either the source or destination vertex of the edge is not present in the graph.
|
|
166
197
|
*/
|
|
167
198
|
DirectedGraph.prototype.addEdge = function (edge) {
|
|
168
199
|
if (!(this.hasVertex(edge.src) && this.hasVertex(edge.dest))) {
|
|
169
200
|
return false;
|
|
170
201
|
}
|
|
171
|
-
var srcVertex = this.
|
|
172
|
-
var destVertex = this.
|
|
202
|
+
var srcVertex = this._getVertex(edge.src);
|
|
203
|
+
var destVertex = this._getVertex(edge.dest);
|
|
173
204
|
// TODO after no-non-null-assertion not ensure the logic
|
|
174
205
|
if (srcVertex && destVertex) {
|
|
175
206
|
var srcOutEdges = this._outEdgeMap.get(srcVertex);
|
|
@@ -193,18 +224,18 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
193
224
|
}
|
|
194
225
|
};
|
|
195
226
|
/**
|
|
196
|
-
* The function removes an edge between two vertices in a directed graph and returns the removed
|
|
197
|
-
*
|
|
198
|
-
* @param {V | VertexId}
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* edge does not exist
|
|
227
|
+
* The `removeEdgeBetween` function removes an edge between two vertices in a directed graph and returns the removed
|
|
228
|
+
* edge, or null if the edge was not found.
|
|
229
|
+
* @param {V | VertexId} srcOrId - The `srcOrId` parameter represents either a `V`
|
|
230
|
+
* object or a `VertexId` value. It is used to specify the source vertex of the edge that you want to remove.
|
|
231
|
+
* @param {V | VertexId} destOrId - The `destOrId` parameter represents the destination vertex of the
|
|
232
|
+
* edge that you want to remove. It can be either a `V` object or a `VertexId` value.
|
|
233
|
+
* @returns The function `removeEdgeBetween` returns the removed edge (`E`) if it exists, or `null` if
|
|
234
|
+
* the edge does not exist.
|
|
204
235
|
*/
|
|
205
236
|
DirectedGraph.prototype.removeEdgeBetween = function (srcOrId, destOrId) {
|
|
206
|
-
var src = this.
|
|
207
|
-
var dest = this.
|
|
237
|
+
var src = this._getVertex(srcOrId);
|
|
238
|
+
var dest = this._getVertex(destOrId);
|
|
208
239
|
var removed = null;
|
|
209
240
|
if (!src || !dest) {
|
|
210
241
|
return null;
|
|
@@ -228,16 +259,17 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
228
259
|
return removed;
|
|
229
260
|
};
|
|
230
261
|
/**
|
|
231
|
-
* The removeEdge function removes
|
|
232
|
-
* found.
|
|
233
|
-
* @param
|
|
234
|
-
*
|
|
235
|
-
* @returns The
|
|
262
|
+
* The `removeEdge` function removes a directed edge from a graph and returns the removed edge, or null if the edge was
|
|
263
|
+
* not found.
|
|
264
|
+
* @param edge - The `edge` parameter is an object of type `E`, which represents a directed edge in a
|
|
265
|
+
* graph. It has two properties:
|
|
266
|
+
* @returns The function `removeEdge` returns a `E` object if an edge is successfully removed, or `null`
|
|
267
|
+
* if no edge is removed.
|
|
236
268
|
*/
|
|
237
269
|
DirectedGraph.prototype.removeEdge = function (edge) {
|
|
238
270
|
var removed = null;
|
|
239
|
-
var src = this.
|
|
240
|
-
var dest = this.
|
|
271
|
+
var src = this._getVertex(edge.src);
|
|
272
|
+
var dest = this._getVertex(edge.dest);
|
|
241
273
|
if (src && dest) {
|
|
242
274
|
var srcOutEdges = this._outEdgeMap.get(src);
|
|
243
275
|
if (srcOutEdges && srcOutEdges.length > 0) {
|
|
@@ -252,95 +284,99 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
252
284
|
};
|
|
253
285
|
/**
|
|
254
286
|
* The function removeAllEdges removes all edges between two vertices.
|
|
255
|
-
* @param {VertexId | V} src - The `src` parameter
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* @returns An empty array is being returned.
|
|
287
|
+
* @param {VertexId | V} src - The `src` parameter can be either a `VertexId` or a `V`.
|
|
288
|
+
* @param {VertexId | V} dest - The `dest` parameter represents the destination vertex of an edge. It
|
|
289
|
+
* can be either a `VertexId` or a `V`.
|
|
290
|
+
* @returns An empty array of DirectedEdge objects is being returned.
|
|
260
291
|
*/
|
|
261
292
|
DirectedGraph.prototype.removeAllEdges = function (src, dest) {
|
|
262
293
|
return [];
|
|
263
294
|
};
|
|
264
295
|
/**
|
|
265
|
-
* The function
|
|
266
|
-
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a
|
|
267
|
-
*
|
|
268
|
-
* @returns The method `incomingEdgesOf` returns an array of
|
|
296
|
+
* The function returns an array of incoming edges of a given vertex or vertex ID.
|
|
297
|
+
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a `V`
|
|
298
|
+
* object or a `VertexId`.
|
|
299
|
+
* @returns The method `incomingEdgesOf` returns an array of `E` objects.
|
|
269
300
|
*/
|
|
270
301
|
DirectedGraph.prototype.incomingEdgesOf = function (vertexOrId) {
|
|
271
|
-
var target = this.
|
|
302
|
+
var target = this._getVertex(vertexOrId);
|
|
272
303
|
if (target) {
|
|
273
|
-
return this.
|
|
304
|
+
return this.inEdgeMap.get(target) || [];
|
|
274
305
|
}
|
|
275
306
|
return [];
|
|
276
307
|
};
|
|
277
308
|
/**
|
|
278
|
-
* The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
|
|
279
|
-
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can
|
|
280
|
-
*
|
|
281
|
-
* @returns The method `outgoingEdgesOf` returns an array of
|
|
309
|
+
* The function `outgoingEdgesOf` returns an array of outgoing directed edges from a given vertex or vertex ID.
|
|
310
|
+
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a `V`
|
|
311
|
+
* object or a `VertexId`.
|
|
312
|
+
* @returns The method `outgoingEdgesOf` returns an array of `E` objects.
|
|
282
313
|
*/
|
|
283
314
|
DirectedGraph.prototype.outgoingEdgesOf = function (vertexOrId) {
|
|
284
|
-
var target = this.
|
|
315
|
+
var target = this._getVertex(vertexOrId);
|
|
285
316
|
if (target) {
|
|
286
317
|
return this._outEdgeMap.get(target) || [];
|
|
287
318
|
}
|
|
288
319
|
return [];
|
|
289
320
|
};
|
|
290
321
|
/**
|
|
291
|
-
* The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree
|
|
292
|
-
*
|
|
293
|
-
* @
|
|
322
|
+
* The function "degreeOf" returns the total degree of a vertex in a directed graph, which is the sum of its out-degree
|
|
323
|
+
* and in-degree.
|
|
324
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
325
|
+
* `V`.
|
|
326
|
+
* @returns The sum of the out-degree and in-degree of the given vertex or vertex ID.
|
|
294
327
|
*/
|
|
295
328
|
DirectedGraph.prototype.degreeOf = function (vertexOrId) {
|
|
296
329
|
return this.outDegreeOf(vertexOrId) + this.inDegreeOf(vertexOrId);
|
|
297
330
|
};
|
|
298
331
|
/**
|
|
299
|
-
* The function "inDegreeOf" returns the number of incoming edges for a given vertex.
|
|
300
|
-
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
332
|
+
* The function "inDegreeOf" returns the number of incoming edges for a given vertex or vertex ID in a directed graph.
|
|
333
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
334
|
+
* `V`.
|
|
301
335
|
* @returns The number of incoming edges of the specified vertex or vertex ID.
|
|
302
336
|
*/
|
|
303
337
|
DirectedGraph.prototype.inDegreeOf = function (vertexOrId) {
|
|
304
338
|
return this.incomingEdgesOf(vertexOrId).length;
|
|
305
339
|
};
|
|
306
340
|
/**
|
|
307
|
-
* The function
|
|
308
|
-
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
341
|
+
* The function "outDegreeOf" returns the number of outgoing edges from a given vertex.
|
|
342
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
343
|
+
* `V`.
|
|
309
344
|
* @returns The number of outgoing edges from the specified vertex or vertex ID.
|
|
310
345
|
*/
|
|
311
346
|
DirectedGraph.prototype.outDegreeOf = function (vertexOrId) {
|
|
312
347
|
return this.outgoingEdgesOf(vertexOrId).length;
|
|
313
348
|
};
|
|
314
349
|
/**
|
|
315
|
-
* The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
|
|
316
|
-
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
317
|
-
*
|
|
350
|
+
* The function "edgesOf" returns an array of both outgoing and incoming directed edges of a given vertex or vertex ID.
|
|
351
|
+
* @param {VertexId | V} vertexOrId - The parameter `vertexOrId` can be either a `VertexId` or a
|
|
352
|
+
* `V`.
|
|
353
|
+
* @returns an array of directed edges.
|
|
318
354
|
*/
|
|
319
355
|
DirectedGraph.prototype.edgesOf = function (vertexOrId) {
|
|
320
356
|
return __spreadArray(__spreadArray([], __read(this.outgoingEdgesOf(vertexOrId)), false), __read(this.incomingEdgesOf(vertexOrId)), false);
|
|
321
357
|
};
|
|
322
358
|
/**
|
|
323
|
-
* The function "getEdgeSrc" returns the source vertex of
|
|
324
|
-
* @param
|
|
325
|
-
* @returns
|
|
359
|
+
* The function "getEdgeSrc" returns the source vertex of a directed edge, or null if the edge does not exist.
|
|
360
|
+
* @param e - A directed edge object of type E.
|
|
361
|
+
* @returns either a DirectedVertex object or null.
|
|
326
362
|
*/
|
|
327
363
|
DirectedGraph.prototype.getEdgeSrc = function (e) {
|
|
328
|
-
return this.
|
|
364
|
+
return this._getVertex(e.src);
|
|
329
365
|
};
|
|
330
366
|
/**
|
|
331
|
-
* The function "getEdgeDest" returns the vertex
|
|
332
|
-
* @param
|
|
333
|
-
*
|
|
367
|
+
* The function "getEdgeDest" returns the destination vertex of a directed edge.
|
|
368
|
+
* @param e - E - This is an object representing a directed edge in a graph. It contains information
|
|
369
|
+
* about the source vertex, destination vertex, and any associated data.
|
|
370
|
+
* @returns either a DirectedVertex object or null.
|
|
334
371
|
*/
|
|
335
372
|
DirectedGraph.prototype.getEdgeDest = function (e) {
|
|
336
|
-
return this.
|
|
373
|
+
return this._getVertex(e.dest);
|
|
337
374
|
};
|
|
338
375
|
/**
|
|
339
|
-
* The function `getDestinations` returns an array of
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* @returns an array of vertices (V[]).
|
|
376
|
+
* The function `getDestinations` returns an array of directed vertices that are the destinations of outgoing edges
|
|
377
|
+
* from a given vertex.
|
|
378
|
+
* @param {V | VertexId | null} vertex - The `vertex` parameter can be one of the following:
|
|
379
|
+
* @returns an array of DirectedVertex objects.
|
|
344
380
|
*/
|
|
345
381
|
DirectedGraph.prototype.getDestinations = function (vertex) {
|
|
346
382
|
var e_1, _a;
|
|
@@ -367,14 +403,11 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
367
403
|
}
|
|
368
404
|
return destinations;
|
|
369
405
|
};
|
|
370
|
-
/**--- start find cycles --- */
|
|
371
406
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* The `topologicalSort`
|
|
375
|
-
* order, or null if
|
|
376
|
-
* @returns The `topologicalSort()` function returns an array of vertices (`V[]`) in topological order if there is no
|
|
377
|
-
* cycle in the graph. If there is a cycle, it returns `null`.
|
|
407
|
+
* The `topologicalSort` function performs a topological sort on a directed graph and returns the sorted vertices in
|
|
408
|
+
* reverse order, or null if the graph contains a cycle.
|
|
409
|
+
* @returns The function `topologicalSort()` returns an array of `V` or `VertexId` objects in
|
|
410
|
+
* topological order, or `null` if there is a cycle in the graph.
|
|
378
411
|
*/
|
|
379
412
|
DirectedGraph.prototype.topologicalSort = function () {
|
|
380
413
|
var e_2, _a, e_3, _b;
|
|
@@ -383,7 +416,7 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
383
416
|
// When judging whether there is a cycle in the directed graph, all nodes with **in degree = 0** are enqueued
|
|
384
417
|
var statusMap = new Map();
|
|
385
418
|
try {
|
|
386
|
-
for (var _c = __values(this.
|
|
419
|
+
for (var _c = __values(this.vertices), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
387
420
|
var entry = _d.value;
|
|
388
421
|
statusMap.set(entry[1], 0);
|
|
389
422
|
}
|
|
@@ -424,7 +457,7 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
424
457
|
sorted.push(cur);
|
|
425
458
|
};
|
|
426
459
|
try {
|
|
427
|
-
for (var _e = __values(this.
|
|
460
|
+
for (var _e = __values(this.vertices), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
428
461
|
var entry = _f.value;
|
|
429
462
|
if (statusMap.get(entry[1]) === 0) {
|
|
430
463
|
dfs(entry[1]);
|
|
@@ -442,10 +475,9 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
442
475
|
return null;
|
|
443
476
|
return sorted.reverse();
|
|
444
477
|
};
|
|
445
|
-
/**--- end find cycles --- */
|
|
446
478
|
/**
|
|
447
|
-
* The `edgeSet` function returns an array of all
|
|
448
|
-
* @returns The `edgeSet()` method returns an array of
|
|
479
|
+
* The `edgeSet` function returns an array of all directed edges in the graph.
|
|
480
|
+
* @returns The `edgeSet()` method returns an array of `E` objects.
|
|
449
481
|
*/
|
|
450
482
|
DirectedGraph.prototype.edgeSet = function () {
|
|
451
483
|
var edges = [];
|
|
@@ -454,22 +486,23 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
454
486
|
});
|
|
455
487
|
return edges;
|
|
456
488
|
};
|
|
489
|
+
/**--- start find cycles --- */
|
|
457
490
|
/**
|
|
458
|
-
* The function `getNeighbors` returns an array of neighboring vertices
|
|
459
|
-
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a
|
|
460
|
-
*
|
|
461
|
-
* @returns an array of
|
|
491
|
+
* The function `getNeighbors` returns an array of neighboring vertices of a given vertex in a directed graph.
|
|
492
|
+
* @param {V | VertexId} vertexOrId - The parameter `vertexOrId` can be either a `V`
|
|
493
|
+
* object or a `VertexId`.
|
|
494
|
+
* @returns an array of DirectedVertex objects.
|
|
462
495
|
*/
|
|
463
496
|
DirectedGraph.prototype.getNeighbors = function (vertexOrId) {
|
|
464
497
|
var e_5, _a;
|
|
465
498
|
var neighbors = [];
|
|
466
|
-
var vertex = this.
|
|
499
|
+
var vertex = this._getVertex(vertexOrId);
|
|
467
500
|
if (vertex) {
|
|
468
501
|
var outEdges = this.outgoingEdgesOf(vertex);
|
|
469
502
|
try {
|
|
470
503
|
for (var outEdges_1 = __values(outEdges), outEdges_1_1 = outEdges_1.next(); !outEdges_1_1.done; outEdges_1_1 = outEdges_1.next()) {
|
|
471
504
|
var outEdge = outEdges_1_1.value;
|
|
472
|
-
var neighbor = this.
|
|
505
|
+
var neighbor = this._getVertex(outEdge.dest);
|
|
473
506
|
// TODO after no-non-null-assertion not ensure the logic
|
|
474
507
|
if (neighbor) {
|
|
475
508
|
neighbors.push(neighbor);
|
|
@@ -486,19 +519,20 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
486
519
|
}
|
|
487
520
|
return neighbors;
|
|
488
521
|
};
|
|
522
|
+
/**--- end find cycles --- */
|
|
489
523
|
/**
|
|
490
|
-
* The function "getEndsOfEdge" returns the source and destination vertices of
|
|
491
|
-
* otherwise it returns null.
|
|
492
|
-
* @param
|
|
493
|
-
* @returns an array containing
|
|
494
|
-
*
|
|
524
|
+
* The function "getEndsOfEdge" returns the source and destination vertices of a directed edge if it exists in the
|
|
525
|
+
* graph, otherwise it returns null.
|
|
526
|
+
* @param edge - A directed edge object with a generic type E.
|
|
527
|
+
* @returns an array containing the starting and ending vertices of the given directed edge, or null if the edge does
|
|
528
|
+
* not exist in the graph.
|
|
495
529
|
*/
|
|
496
530
|
DirectedGraph.prototype.getEndsOfEdge = function (edge) {
|
|
497
531
|
if (!this.hasEdge(edge.src, edge.dest)) {
|
|
498
532
|
return null;
|
|
499
533
|
}
|
|
500
|
-
var v1 = this.
|
|
501
|
-
var v2 = this.
|
|
534
|
+
var v1 = this._getVertex(edge.src);
|
|
535
|
+
var v2 = this._getVertex(edge.dest);
|
|
502
536
|
if (v1 && v2) {
|
|
503
537
|
return [v1, v2];
|
|
504
538
|
}
|
|
@@ -506,6 +540,12 @@ var DirectedGraph = /** @class */ (function (_super) {
|
|
|
506
540
|
return null;
|
|
507
541
|
}
|
|
508
542
|
};
|
|
543
|
+
DirectedGraph.prototype._setOutEdgeMap = function (value) {
|
|
544
|
+
this._outEdgeMap = value;
|
|
545
|
+
};
|
|
546
|
+
DirectedGraph.prototype._setInEdgeMap = function (value) {
|
|
547
|
+
this._inEdgeMap = value;
|
|
548
|
+
};
|
|
509
549
|
return DirectedGraph;
|
|
510
550
|
}(abstract_graph_1.AbstractGraph));
|
|
511
551
|
exports.DirectedGraph = DirectedGraph;
|