@raikuxq/alg-ds 1.1.5 → 1.2.0
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 +67 -92
- package/lib/{algorithms → app/algorithms}/binary-search.d.ts +0 -0
- package/lib/app/algorithms/binary-search.js +27 -0
- package/lib/{algorithms → app/algorithms}/factorial.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/factorial.js +1 -1
- package/lib/{algorithms → app/algorithms}/fibonacci.d.ts +0 -0
- package/lib/app/algorithms/fibonacci.js +17 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/AbstractGraphIterator.d.ts +0 -0
- package/lib/app/algorithms/graph/iterator/AbstractGraphIterator.js +83 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorBFS.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorBFS.js +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDFS.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDFS.js +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.js +3 -5
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/BFSIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/BFSIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DFSIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DFSIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DijkstraIterationStrategy.d.ts +0 -0
- package/lib/{data-structures/Graph/strategy → app/algorithms/graph/iterator-strategy}/DijkstraIterationStrategy.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.d.ts +2 -2
- package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.js +1 -1
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/hasPath.d.ts +0 -0
- package/lib/app/algorithms/graph/searching/hasPath.js +30 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/searching/shortestPath.d.ts +0 -0
- package/lib/app/algorithms/graph/searching/shortestPath.js +30 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/transposing/transposeDirectedGraph.d.ts +0 -0
- package/lib/{data-structures/Graph → app/algorithms/graph}/transposing/transposeDirectedGraph.js +3 -3
- package/lib/{algorithms → app/algorithms}/memoize.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/memoize.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/bubble-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/bubble-sort.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/insertion-sort.d.ts +0 -0
- package/lib/app/algorithms/sorts/insertion-sort.js +25 -0
- package/lib/{algorithms → app/algorithms}/sorts/merge-sort.d.ts +0 -0
- package/lib/app/algorithms/sorts/merge-sort.js +61 -0
- package/lib/{algorithms → app/algorithms}/sorts/quick-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/quick-sort.js +1 -1
- package/lib/{algorithms → app/algorithms}/sorts/select-sort.d.ts +0 -0
- package/lib/{algorithms → app/algorithms}/sorts/select-sort.js +1 -1
- package/lib/app/algorithms/transpose-matrix.d.ts +5 -0
- package/lib/app/algorithms/transpose-matrix.js +18 -0
- package/lib/{constants.d.ts → app/constants.d.ts} +0 -0
- package/lib/{constants.js → app/constants.js} +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchTree.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/BinarySearchTree/BinarySearchTree.js +7 -4
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.js +3 -2
- package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.d.ts +6 -0
- package/lib/app/data-structures/BinaryTree/_helpers/createBinaryTree.js +22 -0
- package/lib/{data-structures → app/data-structures}/Graph/AbstractGraph.d.ts +0 -0
- package/lib/app/data-structures/Graph/AbstractGraph.js +143 -0
- package/lib/{data-structures → app/data-structures}/Graph/DirectedGraph.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/Graph/DirectedGraph.js +5 -4
- package/lib/{data-structures → app/data-structures}/Graph/GraphEdge.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/Graph/GraphEdge.js +1 -1
- package/lib/{data-structures → app/data-structures}/Graph/UndirectedGraph.d.ts +0 -0
- package/lib/app/data-structures/Graph/UndirectedGraph.js +103 -0
- package/lib/app/data-structures/Graph/_helpers/createGraph.d.ts +6 -0
- package/lib/app/data-structures/Graph/_helpers/createGraph.js +22 -0
- package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.d.ts +7 -0
- package/lib/app/data-structures/Graph/_helpers/createGraphFromMatrix.js +42 -0
- package/lib/{data-structures/Graph/demo → app/data-structures/Graph/_helpers}/generateRandomGraph.d.ts +0 -0
- package/lib/app/data-structures/Graph/_helpers/generateRandomGraph.js +67 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTable.d.ts +0 -0
- package/lib/app/data-structures/HashTable/HashTable.js +171 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTableNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/HashTable/HashTableNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedList.d.ts +2 -2
- package/lib/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +241 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/AbstractLinkedList/AbstractLinkedNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedList.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedList.js +4 -3
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/DoubleLinkedList/DoubleLinkedNode.js +1 -1
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedList.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedList.js +3 -2
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedNode.d.ts +0 -0
- package/lib/{data-structures → app/data-structures}/LinkedList/SingleLinkedList/SingleLinkedNode.js +1 -1
- package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.d.ts +3 -0
- package/lib/app/data-structures/LinkedList/_helpers/createLinkedList.js +19 -0
- package/lib/{data-structures → app/data-structures}/LoopedArray/LoopedArray.d.ts +0 -3
- package/lib/{data-structures → app/data-structures}/LoopedArray/LoopedArray.js +17 -9
- package/lib/{data-structures → app/data-structures}/Queue/Queue.d.ts +0 -0
- package/lib/app/data-structures/Queue/Queue.js +85 -0
- package/lib/{data-structures → app/data-structures}/Stack/Stack.d.ts +0 -0
- package/lib/app/data-structures/Stack/Stack.js +85 -0
- package/lib/app/exceptions/CollectionIsEmptyException.d.ts +4 -0
- package/lib/app/exceptions/CollectionIsEmptyException.js +28 -0
- package/lib/app/exceptions/CollectionIsFullException.d.ts +4 -0
- package/lib/app/exceptions/CollectionIsFullException.js +28 -0
- package/lib/app/exceptions/IndexOutOfBoundsException.d.ts +4 -0
- package/lib/app/exceptions/IndexOutOfBoundsException.js +28 -0
- package/lib/app/exceptions/IsAlreadyExistsException.d.ts +4 -0
- package/lib/app/exceptions/IsAlreadyExistsException.js +28 -0
- package/lib/app/exceptions/IsNotFoundException.d.ts +4 -0
- package/lib/app/exceptions/IsNotFoundException.js +28 -0
- package/lib/app/exceptions/ValueOutOfRangeException.d.ts +4 -0
- package/lib/app/exceptions/ValueOutOfRangeException.js +28 -0
- package/lib/app/exceptions/base/IllegalArgumentException.d.ts +3 -0
- package/lib/app/exceptions/base/IllegalArgumentException.js +27 -0
- package/lib/app/exceptions/base/IllegalStateException.d.ts +3 -0
- package/lib/app/exceptions/base/IllegalStateException.js +27 -0
- package/lib/{types → app/types}/EnumBinarySearchTreeType.d.ts +0 -0
- package/lib/{types → app/types}/EnumBinarySearchTreeType.js +1 -1
- package/lib/app/types/EnumGraphTraversalType.d.ts +5 -0
- package/lib/app/types/EnumGraphTraversalType.js +10 -0
- package/lib/{types → app/types}/EnumGraphType.d.ts +0 -0
- package/lib/{types → app/types}/EnumGraphType.js +1 -1
- package/lib/{types → app/types}/EnumLinkedListType.d.ts +0 -0
- package/lib/{types → app/types}/EnumLinkedListType.js +1 -1
- package/lib/{types → app/types}/EnumRandomGenerationFormat.d.ts +0 -0
- package/lib/{types → app/types}/EnumRandomGenerationFormat.js +1 -1
- package/lib/app/types/EnumSortType.d.ts +7 -0
- package/lib/app/types/EnumSortType.js +12 -0
- package/lib/{types → app/types}/EnumTreeTraversalType.d.ts +0 -0
- package/lib/{types → app/types}/EnumTreeTraversalType.js +1 -1
- package/lib/{types → app/types}/FnCompareTwo.d.ts +0 -0
- package/lib/{types → app/types}/FnCompareTwo.js +1 -1
- package/lib/{types → app/types}/FnToMemoize.d.ts +0 -0
- package/lib/{types → app/types}/FnToMemoize.js +1 -1
- package/lib/{types → app/types}/IArrayFacade.d.ts +0 -0
- package/lib/{types → app/types}/IArrayFacade.js +1 -1
- package/lib/{types → app/types}/IBiDirectIterable.d.ts +0 -0
- package/lib/{types → app/types}/IBiDirectIterable.js +1 -1
- package/lib/{types → app/types}/IBiDirectIterator.d.ts +0 -0
- package/lib/{types → app/types}/IBiDirectIterator.js +1 -1
- package/lib/{types → app/types}/IBinaryTree.d.ts +0 -0
- package/lib/{types → app/types}/IBinaryTree.js +1 -1
- package/lib/{types → app/types}/IConvertableToArray.d.ts +0 -0
- package/lib/{types → app/types}/IConvertableToArray.js +1 -1
- package/lib/{types → app/types}/IGraph.d.ts +0 -0
- package/lib/{types → app/types}/IGraph.js +1 -1
- package/lib/{types → app/types}/IGraphIterationStrategy.d.ts +0 -0
- package/lib/{types → app/types}/IGraphIterationStrategy.js +1 -1
- package/lib/{types → app/types}/IGraphIterator.d.ts +0 -0
- package/lib/{types → app/types}/IGraphIterator.js +1 -1
- package/lib/{types → app/types}/IIterable.d.ts +0 -0
- package/lib/{types → app/types}/IIterable.js +1 -1
- package/lib/{types → app/types}/IIterator.d.ts +0 -0
- package/lib/{types → app/types}/IIterator.js +1 -1
- package/lib/{types → app/types}/IKeyValueStorage.d.ts +0 -0
- package/lib/{types → app/types}/IKeyValueStorage.js +1 -1
- package/lib/{types → app/types}/ILinearStorage.d.ts +0 -0
- package/lib/{types → app/types}/ILinearStorage.js +1 -1
- package/lib/{types → app/types}/ILinearStorageRA.d.ts +0 -0
- package/lib/{types → app/types}/ILinearStorageRA.js +1 -1
- package/lib/{types → app/types}/ILinkedList.d.ts +0 -0
- package/lib/{types → app/types}/ILinkedList.js +1 -1
- package/lib/app/types/TypeArrayMatrix.d.ts +1 -0
- package/lib/app/types/TypeArrayMatrix.js +3 -0
- package/lib/{utils.d.ts → app/utils.d.ts} +8 -0
- package/lib/{utils.js → app/utils.js} +21 -2
- package/lib/exports/algorithms.d.ts +15 -15
- package/lib/exports/algorithms.js +16 -16
- package/lib/exports/constants.d.ts +1 -1
- package/lib/exports/constants.js +2 -2
- package/lib/exports/data-structures.d.ts +10 -10
- package/lib/exports/data-structures.js +11 -11
- package/lib/exports/helpers.d.ts +5 -5
- package/lib/exports/helpers.js +6 -6
- package/lib/exports/sorts.d.ts +5 -5
- package/lib/exports/sorts.js +6 -6
- package/lib/exports/types.d.ts +16 -0
- package/lib/exports/types.js +34 -0
- package/lib/exports/utils.d.ts +2 -2
- package/lib/exports/utils.js +3 -3
- package/lib/exports.d.ts +47 -38
- package/lib/exports.js +56 -40
- package/lib/index.js +1 -2
- package/package.json +11 -6
- package/lib/algorithms/binary-search.js +0 -27
- package/lib/algorithms/fibonacci.js +0 -17
- package/lib/algorithms/sorts/insertion-sort.js +0 -25
- package/lib/algorithms/sorts/merge-sort.js +0 -61
- package/lib/algorithms/transpose-matrix.d.ts +0 -5
- package/lib/algorithms/transpose-matrix.js +0 -20
- package/lib/data-structures/Graph/AbstractGraph.js +0 -141
- package/lib/data-structures/Graph/UndirectedGraph.js +0 -102
- package/lib/data-structures/Graph/demo/generateRandomGraph.js +0 -72
- package/lib/data-structures/Graph/iterator/AbstractGraphIterator.js +0 -90
- package/lib/data-structures/Graph/searching/hasPath.js +0 -29
- package/lib/data-structures/Graph/searching/shortestPath.js +0 -29
- package/lib/data-structures/HashTable/HashTable.js +0 -169
- package/lib/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.js +0 -236
- package/lib/data-structures/Queue/Queue.js +0 -83
- package/lib/data-structures/Stack/Stack.js +0 -83
- package/lib/helpers/createBinaryTree.d.ts +0 -6
- package/lib/helpers/createBinaryTree.js +0 -22
- package/lib/helpers/createGraph.d.ts +0 -6
- package/lib/helpers/createGraph.js +0 -24
- package/lib/helpers/createGraphFromMatrix.d.ts +0 -7
- package/lib/helpers/createGraphFromMatrix.js +0 -37
- package/lib/helpers/createLinkedList.d.ts +0 -3
- package/lib/helpers/createLinkedList.js +0 -21
- package/lib/types/ArrayMatrix.d.ts +0 -1
- package/lib/types/ArrayMatrix.js +0 -3
package/README.md
CHANGED
|
@@ -2,30 +2,15 @@ Common algorithms and data structures.
|
|
|
2
2
|
|
|
3
3
|
Written in TypeScript, tested with Jest.
|
|
4
4
|
|
|
5
|
+
# Documentation
|
|
6
|
+
Documentation app available here: [https://raikuxq-algorithms.netlify.app/guide](https://raikuxq-algorithms.netlify.app/guide)
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
# Usage as package
|
|
7
10
|
Install by using any of these commands:
|
|
8
11
|
+ `yarn add @raikuxq/alg-ds`
|
|
9
12
|
+ `npm install @raikuxq/alg-ds --save`
|
|
10
13
|
|
|
11
|
-
## Import from root
|
|
12
|
-
`import { <anything> } from '@raikuxq/alg-ds'`
|
|
13
|
-
|
|
14
|
-
## Import from sub-paths
|
|
15
|
-
### Data structures
|
|
16
|
-
`import {Stack, Queue, SingleLinkedList, DoubleLinkedList, RandBinarySearchTree, BinarySearchTree, DirectedGraph, UndirectedGraph, LoopedArray, HashTable, } from '@raikuxq/alg-ds/lib/exports/data-structures'`
|
|
17
|
-
### Sorting algorithms
|
|
18
|
-
`import {bubbleSort, insertionSort, mergeSort, selectSort, quickSort} from '@raikuxq/alg-ds/lib/exports/data-structures `
|
|
19
|
-
### Other algorithms
|
|
20
|
-
`import {binarySearch, factorial, memoizedFactorial, memoizedFibonacci, fibonacci, transposeMatrix, GraphIteratorDFS, presenterAdjacencyLists, presenterAdjacencyMatrix, hasPath, shortestPath, DijkstraIterationStrategy, DFSIterationStrategy, BFSIterationStrategy, GraphIteratorBFS, GraphIteratorDijkstra, transposeDirectedGraph} from '@raikuxq/alg-ds/lib/exports/algorithms'`
|
|
21
|
-
### Helpers
|
|
22
|
-
`import {createGraph, createGraphFromMatrix, createBinaryTree, createLinkedList, generateRandomGraph} from '@raikuxq/alg-ds/lib/exports/helpers`
|
|
23
|
-
### Utils
|
|
24
|
-
`import {perf, getMinIndex, getMinIndexFromIndex, memoize, perfAsync, roundNumber, randomizeNumberInRange, swapArrayItems} from '@raikuxq/alg-ds/lib/exports/utils'`
|
|
25
|
-
### Constants
|
|
26
|
-
`import {EDGE_NOT_EXISTS_STATE, EDGE_EXISTS_STATE} from '@raikuxq/alg-ds/lib/exports/constants'`
|
|
27
|
-
|
|
28
|
-
|
|
29
14
|
|
|
30
15
|
# Usage as repository
|
|
31
16
|
|
|
@@ -46,8 +31,9 @@ Clone this repository and install dependencies by using `yarn` command.
|
|
|
46
31
|
|
|
47
32
|
# Navigation
|
|
48
33
|
+ [Algorithms](#algorithms)
|
|
34
|
+
+ [Utils](#utils)
|
|
35
|
+
+ [Math](#math)
|
|
49
36
|
+ [Sorting algorithms](#sorting-algorithms)
|
|
50
|
-
+ [Iterators](#iterators)
|
|
51
37
|
+ [Linear data structures](#linear-data-structures)
|
|
52
38
|
+ [Linked list](#linked-list)
|
|
53
39
|
+ [Looped array](#looped-array)
|
|
@@ -61,100 +47,89 @@ Clone this repository and install dependencies by using `yarn` command.
|
|
|
61
47
|
|
|
62
48
|
# Algorithms
|
|
63
49
|
|
|
64
|
-
##
|
|
65
|
-
[memoize](src/algorithms/memoize.ts) — Memoization util function.
|
|
50
|
+
## Utils
|
|
51
|
+
[memoize](src/app/algorithms/memoize.ts) — Memoization util function.
|
|
66
52
|
|
|
67
|
-
|
|
53
|
+
## Searching
|
|
54
|
+
[binary-search](src/app/algorithms/binary-search.ts) [[ tests ](test/unit/algorithms/binary-search.test.ts)] — Binary searching algorithm. Time: O(log(n)).
|
|
68
55
|
|
|
69
|
-
|
|
56
|
+
## Math
|
|
57
|
+
[factorial](src/app/algorithms/factorial.ts) [[ tests ](test/unit/algorithms/factorial.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
70
58
|
|
|
71
|
-
[fibonacci](src/algorithms/fibonacci.ts) [[ tests ](test/unit/algorithms/fibonacci.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
59
|
+
[fibonacci](src/app/algorithms/fibonacci.ts) [[ tests ](test/unit/algorithms/fibonacci.test.ts)] — Recursive O(n!) and memoized O(n) factorial implementation.
|
|
72
60
|
|
|
73
|
-
[transpose-matrix](src/algorithms/transpose-matrix.ts) [[ tests ](test/unit/algorithms/transpose-matrix.test.ts)] — Transpose N*N matrix util function.
|
|
61
|
+
[transpose-matrix](src/app/algorithms/transpose-matrix.ts) [[ tests ](test/unit/algorithms/transpose-matrix.test.ts)] — Transpose N*N matrix util function.
|
|
74
62
|
|
|
75
63
|
|
|
76
64
|
## Sorting algorithms
|
|
77
|
-
[bubble-sort](src/algorithms/sorts/bubble-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
78
|
-
|
|
79
|
-
[selection-sort](src/algorithms/sorts/select-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n^2) best. Memory: O(1) worst.
|
|
65
|
+
[bubble-sort](src/app/algorithms/sorts/bubble-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
80
66
|
|
|
81
|
-
[
|
|
67
|
+
[selection-sort](src/app/algorithms/sorts/select-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n^2) best. Memory: O(1) worst.
|
|
82
68
|
|
|
83
|
-
[
|
|
69
|
+
[insertion-sort](src/app/algorithms/sorts/insertion-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n^2) avg, O(n) best. Memory: O(1) worst.
|
|
84
70
|
|
|
85
|
-
[
|
|
71
|
+
[merge-sort](src/app/algorithms/sorts/merge-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n*log(n)) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(n) worst.
|
|
86
72
|
|
|
73
|
+
[quick-sort](src/app/algorithms/sorts/quick-sort.ts) [[ tests ](test/unit/algorithms/sorts.test.ts)] — Time: O(n^2) worst, O(n*log(n)) avg, O(n*log(n)) best. Memory: O(1) worst.
|
|
87
74
|
|
|
88
75
|
|
|
89
76
|
|
|
90
|
-
# Iterators
|
|
91
|
-
|
|
92
|
-
### Interfaces
|
|
93
|
-
[IIterable](src/types/IIterable.ts) — Allows to create an iterator instance.
|
|
94
|
-
|
|
95
|
-
[IBiDirectIterable](src/types/IBiDirectIterable.ts) — Allows to create a bi-direct iterator instance.
|
|
96
|
-
Extends [IIterable](src/types/IIterable.ts) interface.
|
|
97
|
-
|
|
98
|
-
[IIterator](src/types/IIterator.ts) — Allows only next navigation.
|
|
99
|
-
|
|
100
|
-
[IBiDirectIterator](src/types/IBiDirectIterator.ts) — Allows both next and prev navigation.
|
|
101
|
-
Extends [IIterator](src/types/IIterator.ts) interface.
|
|
102
77
|
|
|
103
78
|
|
|
104
79
|
# Linear data structures
|
|
105
80
|
|
|
106
81
|
### Interfaces
|
|
107
|
-
[ILinearStorage](src/types/ILinearStorage.ts) — Contains common methods of linear data structures.
|
|
82
|
+
[ILinearStorage](src/app/types/ILinearStorage.ts) — Contains common methods of linear data structures.
|
|
108
83
|
|
|
109
|
-
[ILinearStorageRA](src/types/ILinearStorageRA.ts) — Allows random access (from end, from start, by index).
|
|
110
|
-
Extends [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
84
|
+
[ILinearStorageRA](src/app/types/ILinearStorageRA.ts) — Allows random access (from end, from start, by index).
|
|
85
|
+
Extends [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
111
86
|
|
|
112
|
-
[IConvertableToArray](src/types/IConvertableToArray.ts) — Contain methods for converting from/into array.
|
|
87
|
+
[IConvertableToArray](src/app/types/IConvertableToArray.ts) — Contain methods for converting from/into array.
|
|
113
88
|
|
|
114
89
|
|
|
115
90
|
## Linked List
|
|
116
91
|
|
|
117
92
|
### Interfaces
|
|
118
|
-
[ILinkedList](src/types/ILinkedList.ts) — Contains basic linked lists operations.
|
|
119
|
-
Extends [ILinearStorageRA](src/types/ILinearStorageRA.ts) and [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
93
|
+
[ILinkedList](src/app/types/ILinkedList.ts) — Contains basic linked lists operations.
|
|
94
|
+
Extends [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) and [IConvertableToArray](src/app/types/IConvertableToArray.ts) interface.
|
|
120
95
|
|
|
121
96
|
### Implementation
|
|
122
|
-
[AbstractLinkedList](src/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts) — Common logic for both single and double linked lists.
|
|
123
|
-
Implements [ILinearStorageRA](src/types/ILinearStorageRA.ts) interface.
|
|
97
|
+
[AbstractLinkedList](src/app/data-structures/LinkedList/AbstractLinkedList/AbstractLinkedList.ts) — Common logic for both single and double linked lists.
|
|
98
|
+
Implements [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) interface.
|
|
124
99
|
|
|
125
|
-
[SingleLinkedList](src/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts)
|
|
100
|
+
[SingleLinkedList](src/app/data-structures/LinkedList/SingleLinkedList/SingleLinkedList.ts)
|
|
126
101
|
[ [ tests ] ](test/unit/data-structures/linked-list/linked-list.test.ts)
|
|
127
102
|
— Extends abstract linked list with implementation of one-way linking.
|
|
128
|
-
Implements [IIterable](src/types/IIterable.ts) interface.
|
|
103
|
+
Implements [IIterable](src/app/types/IIterable.ts) interface.
|
|
129
104
|
|
|
130
|
-
[DoubleLinkedList](src/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts)
|
|
105
|
+
[DoubleLinkedList](src/app/data-structures/LinkedList/DoubleLinkedList/DoubleLinkedList.ts)
|
|
131
106
|
[ [ tests ] ](test/unit/data-structures/linked-list/linked-list.test.ts)
|
|
132
107
|
— Extends abstract linked list with implementation of two-way linking.
|
|
133
|
-
Implements [IBiDirectIterable](src/types/IBiDirectIterable.ts) interface.
|
|
108
|
+
Implements [IBiDirectIterable](src/app/types/IBiDirectIterable.ts) interface.
|
|
134
109
|
|
|
135
110
|
|
|
136
111
|
## Looped Array
|
|
137
112
|
|
|
138
113
|
### Interfaces
|
|
139
|
-
[IArrayFacade](src/types/IArrayFacade.ts) — Contains basic array operations.
|
|
140
|
-
Extends [ILinearStorageRA](src/types/ILinearStorageRA.ts) interface.
|
|
141
|
-
Extends [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
114
|
+
[IArrayFacade](src/app/types/IArrayFacade.ts) — Contains basic array operations.
|
|
115
|
+
Extends [ILinearStorageRA](src/app/types/ILinearStorageRA.ts) interface.
|
|
116
|
+
Extends [IConvertableToArray](src/app/types/IConvertableToArray.ts) interface.
|
|
142
117
|
|
|
143
118
|
### Implementation
|
|
144
|
-
[LoopedArray](src/data-structures/LoopedArray/LoopedArray.ts)[ [ tests ]](test/unit/data-structures/looped-array/looped-array.test.ts)
|
|
119
|
+
[LoopedArray](src/app/data-structures/LoopedArray/LoopedArray.ts)[ [ tests ]](test/unit/data-structures/looped-array/looped-array.test.ts)
|
|
145
120
|
— Overwrites data on capacity overflow.
|
|
146
121
|
|
|
147
122
|
## Stack
|
|
148
123
|
|
|
149
124
|
### Implementation
|
|
150
|
-
[Stack](src/data-structures/Stack/Stack.ts) [[ tests ](test/unit/data-structures/stack/stack.test.ts)]
|
|
151
|
-
— LIFO data structure. Implements [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
125
|
+
[Stack](src/app/data-structures/Stack/Stack.ts) [[ tests ](test/unit/data-structures/stack/stack.test.ts)]
|
|
126
|
+
— LIFO data structure. Implements [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
152
127
|
|
|
153
128
|
## Queue
|
|
154
129
|
|
|
155
130
|
### Implementation
|
|
156
|
-
[Queue](src/data-structures/Queue/Queue.ts) [[ tests ](test/unit/data-structures/queue/queue.test.ts)]
|
|
157
|
-
— FIFO data structure. Implements [ILinearStorage](src/types/ILinearStorage.ts) interface.
|
|
131
|
+
[Queue](src/app/data-structures/Queue/Queue.ts) [[ tests ](test/unit/data-structures/queue/queue.test.ts)]
|
|
132
|
+
— FIFO data structure. Implements [ILinearStorage](src/app/types/ILinearStorage.ts) interface.
|
|
158
133
|
|
|
159
134
|
|
|
160
135
|
|
|
@@ -162,96 +137,96 @@ Extends [IConvertableToArray](src/types/IConvertableToArray.ts) interface.
|
|
|
162
137
|
|
|
163
138
|
## Hash Table
|
|
164
139
|
### Interfaces
|
|
165
|
-
[IKeyValueStorage](src/types/IKeyValueStorage.ts) — Contains basic key-value storages operations.
|
|
140
|
+
[IKeyValueStorage](src/app/types/IKeyValueStorage.ts) — Contains basic key-value storages operations.
|
|
166
141
|
|
|
167
142
|
### Implementation
|
|
168
|
-
[HashTableNode](src/data-structures/HashTable/HashTableNode.ts) — Contains key, data and isDeleted properties.
|
|
143
|
+
[HashTableNode](src/app/data-structures/HashTable/HashTableNode.ts) — Contains key, data and isDeleted properties.
|
|
169
144
|
|
|
170
|
-
[HashTable](src/data-structures/HashTable/HashTable.ts) [ [ tests ] ](test/unit/data-structures/hash-table/hash-table.test.ts) — Implementation of open addressing hash table using quadratic probing
|
|
145
|
+
[HashTable](src/app/data-structures/HashTable/HashTable.ts) [ [ tests ] ](test/unit/data-structures/hash-table/hash-table.test.ts) — Implementation of open addressing hash table using quadratic probing
|
|
171
146
|
|
|
172
147
|
|
|
173
148
|
|
|
174
149
|
## Graph
|
|
175
150
|
### Interfaces
|
|
176
|
-
[IGraph](src/types/IGraph.ts) — Contains basic graph operations.
|
|
151
|
+
[IGraph](src/app/types/IGraph.ts) — Contains basic graph operations.
|
|
177
152
|
|
|
178
|
-
[IGraphIterator](src/types/IGraphIterator.ts) — Extends default iterator with init and getPath methods.
|
|
153
|
+
[IGraphIterator](src/app/types/IGraphIterator.ts) — Extends default iterator with init and getPath methods.
|
|
179
154
|
|
|
180
|
-
[IGraphIterationStrategy](src/types/IGraphIterationStrategy.ts) — Iteration strategies which are used in shortest-path, has-path.
|
|
155
|
+
[IGraphIterationStrategy](src/app/types/IGraphIterationStrategy.ts) — Iteration strategies which are used in shortest-path, has-path.
|
|
181
156
|
|
|
182
157
|
### Implementation
|
|
183
|
-
[GraphEdge](src/data-structures/Graph/GraphEdge.ts) — Contains from/to links and edge weight.
|
|
158
|
+
[GraphEdge](src/app/data-structures/Graph/GraphEdge.ts) — Contains from/to links and edge weight.
|
|
184
159
|
|
|
185
|
-
[AbstractGraph](src/data-structures/Graph/AbstractGraph.ts) — Common logic for both directed and undirected graphs.
|
|
160
|
+
[AbstractGraph](src/app/data-structures/Graph/AbstractGraph.ts) — Common logic for both directed and undirected graphs.
|
|
186
161
|
|
|
187
162
|
|
|
188
|
-
[DirectedGraph](src/data-structures/Graph/DirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
163
|
+
[DirectedGraph](src/app/data-structures/Graph/DirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
189
164
|
— In case of directed graph A->B and B->A edges are not the same.
|
|
190
165
|
|
|
191
|
-
[UndirectedGraph](src/data-structures/Graph/UndirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
166
|
+
[UndirectedGraph](src/app/data-structures/Graph/UndirectedGraph.ts) [ [ tests ] ](test/unit/data-structures/graph/graph.test.ts)
|
|
192
167
|
— In case of undirected graph A->B and B->A are equal.
|
|
193
168
|
|
|
194
169
|
|
|
195
170
|
### Graph Iterators
|
|
196
171
|
|
|
197
|
-
[BreadthFirstSearchIterator](src/
|
|
172
|
+
[BreadthFirstSearchIterator](src/app/algorithms/graph/iterator/GraphIteratorBFS.ts)
|
|
198
173
|
— Traversal method for unweighted graphs, built on queue.
|
|
199
174
|
|
|
200
|
-
[DepthFirstSearchIterator](src/
|
|
175
|
+
[DepthFirstSearchIterator](src/app/algorithms/graph/iterator/GraphIteratorDFS.ts)
|
|
201
176
|
— Traversal method for unweighted graphs, built on stack.
|
|
202
177
|
|
|
203
|
-
[DijkstraMethodIterator](src/
|
|
178
|
+
[DijkstraMethodIterator](src/app/algorithms/graph/iterator/GraphIteratorDijkstra.ts)
|
|
204
179
|
— Traversal method for weighted graphs, built on finding the minimal cost.
|
|
205
180
|
|
|
206
181
|
|
|
207
182
|
### Graph Presenter
|
|
208
|
-
[presenter-adjacency-lists](src/
|
|
183
|
+
[presenter-adjacency-lists](src/app/algorithms/graph/presenter/presenterAdjacencyLists.ts) [[ tests ](test/unit/data-structures/graph/graph.presenter.lists.test.ts)]
|
|
209
184
|
— Representation of graph as an adjacency list (using Map).
|
|
210
185
|
|
|
211
|
-
[presenter-adjacency-matrix](src/
|
|
186
|
+
[presenter-adjacency-matrix](src/app/algorithms/graph/presenter/presenterAdjacencyMatrix.ts) [[ tests ](test/unit/data-structures/graph/graph.presenter.matrix.test.ts)]
|
|
212
187
|
— Representation of graph as an adjacency matrix (using Array N*N).
|
|
213
188
|
|
|
214
189
|
|
|
215
190
|
### Graph Searching
|
|
216
|
-
[has-path (BFS/DFS)](src/
|
|
191
|
+
[has-path (BFS/DFS)](src/app/algorithms/graph/searching/hasPath.ts) [[ tests ](test/unit/data-structures/graph/graph.has-path.test.ts)]
|
|
217
192
|
— Search for the existence of a path between two vertices.
|
|
218
193
|
|
|
219
|
-
[shortest-path (BFS/Dijkstra)](src/
|
|
194
|
+
[shortest-path (BFS/Dijkstra)](src/app/algorithms/graph/searching/shortestPath.ts) [[ tests ](test/unit/data-structures/graph/graph.shortest-path.test.ts)]
|
|
220
195
|
— Search for one of several shortest paths between two vertices.
|
|
221
196
|
|
|
222
197
|
### Graph Creators
|
|
223
|
-
[create-graph-from-matrix](src/
|
|
198
|
+
[create-graph-from-matrix](src/app/data-structures/Graph/_helpers/createGraphFromMatrix.ts) [[ tests ](test/unit/data-structures/graph/graph.create-from-matrix.test.ts)]
|
|
224
199
|
— Convert a matrix N*N into a graph instance.
|
|
225
200
|
|
|
226
201
|
|
|
227
202
|
### Graph Transposing
|
|
228
|
-
[transpose-directed-graph](src/
|
|
203
|
+
[transpose-directed-graph](src/app/algorithms/graph/transposing/transposeDirectedGraph.ts) [ [ tests ](test/unit/data-structures/graph/graph.transpose.test.ts)]
|
|
229
204
|
— Transpose a directed graph (undirected graphs are symmetrical already).
|
|
230
205
|
|
|
231
206
|
|
|
232
207
|
|
|
233
208
|
## Binary trees
|
|
234
|
-
[IBinaryTree](src/types/IBinaryTree.ts) — Contains basic binary tree operations.
|
|
209
|
+
[IBinaryTree](src/app/types/IBinaryTree.ts) — Contains basic binary tree operations.
|
|
235
210
|
|
|
236
211
|
### Implementation
|
|
237
212
|
|
|
238
|
-
[AbstractBinaryNode](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts) — Contains left/right/parent links and node data.
|
|
213
|
+
[AbstractBinaryNode](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryNode.ts) — Contains left/right/parent links and node data.
|
|
239
214
|
|
|
240
|
-
[AbstractBinaryTree](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts) — Common logic for all types of binary trees.
|
|
215
|
+
[AbstractBinaryTree](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts) — Common logic for all types of binary trees.
|
|
241
216
|
|
|
242
217
|
|
|
243
|
-
[BinarySearchNode](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts) — Same as abstract binary node.
|
|
218
|
+
[BinarySearchNode](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts) — Same as abstract binary node.
|
|
244
219
|
|
|
245
|
-
[BinarySearchTree](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts) — Implementation of unbalanced binary search tree.
|
|
220
|
+
[BinarySearchTree](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts) — Implementation of unbalanced binary search tree.
|
|
246
221
|
Each node in left subtree is smaller and each node in right subtree is larger than the node data.
|
|
247
|
-
Extends [AbstractSearchTree](src/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts).
|
|
222
|
+
Extends [AbstractSearchTree](src/app/data-structures/BinaryTree/AbstractBinaryTree/AbstractBinaryTree.ts).
|
|
248
223
|
|
|
249
224
|
|
|
250
225
|
|
|
251
|
-
[RandBinarySearchNode](src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts) — Have a rank attribute.
|
|
252
|
-
Extends [BinarySearchNode](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts).
|
|
226
|
+
[RandBinarySearchNode](src/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchNode.ts) — Have a rank attribute.
|
|
227
|
+
Extends [BinarySearchNode](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchNode.ts).
|
|
253
228
|
|
|
254
|
-
[RandBinarySearchTree](src/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts)
|
|
229
|
+
[RandBinarySearchTree](src/app/data-structures/BinaryTree/RandBinarySearchTree/RandBinarySearchTree.ts)
|
|
255
230
|
— Implementation of randomized binary search tree, which gives expected log(N) height.
|
|
256
231
|
Insertion have a 1/N+1 probability of inserting into root.
|
|
257
|
-
Extends [BinarySearchTree](src/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts).
|
|
232
|
+
Extends [BinarySearchTree](src/app/data-structures/BinaryTree/BinarySearchTree/BinarySearchTree.ts).
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.binarySearch = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Find element's index in sorted array
|
|
6
|
+
* Time complexity: O(log(n))
|
|
7
|
+
*/
|
|
8
|
+
exports.binarySearch = function (elements, searchElement) {
|
|
9
|
+
var length = elements.length;
|
|
10
|
+
var leftIndex = 0;
|
|
11
|
+
var rightIndex = length - 1;
|
|
12
|
+
while (leftIndex <= rightIndex) {
|
|
13
|
+
var midIndex = Math.ceil((leftIndex + rightIndex) / 2);
|
|
14
|
+
var midEl = elements[midIndex];
|
|
15
|
+
if (searchElement == midEl) {
|
|
16
|
+
return midIndex;
|
|
17
|
+
}
|
|
18
|
+
else if (midEl > searchElement) {
|
|
19
|
+
rightIndex = midIndex - 1;
|
|
20
|
+
}
|
|
21
|
+
else if (midEl < searchElement) {
|
|
22
|
+
leftIndex = midIndex + 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmluYXJ5LXNlYXJjaC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9iaW5hcnktc2VhcmNoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOzs7R0FHRztBQUNVLFFBQUEsWUFBWSxHQUFHLFVBQzFCLFFBQXVCLEVBQ3ZCLGFBQXFCO0lBRXJCLElBQU0sTUFBTSxHQUFXLFFBQVEsQ0FBQyxNQUFNLENBQUM7SUFFdkMsSUFBSSxTQUFTLEdBQUcsQ0FBQyxDQUFDO0lBQ2xCLElBQUksVUFBVSxHQUFXLE1BQU0sR0FBRyxDQUFDLENBQUM7SUFFcEMsT0FBTyxTQUFTLElBQUksVUFBVSxFQUFFO1FBQzlCLElBQU0sUUFBUSxHQUFXLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxTQUFTLEdBQUcsVUFBVSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUM7UUFDakUsSUFBTSxLQUFLLEdBQVcsUUFBUSxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBRXpDLElBQUksYUFBYSxJQUFJLEtBQUssRUFBRTtZQUMxQixPQUFPLFFBQVEsQ0FBQztTQUNqQjthQUFNLElBQUksS0FBSyxHQUFHLGFBQWEsRUFBRTtZQUNoQyxVQUFVLEdBQUcsUUFBUSxHQUFHLENBQUMsQ0FBQztTQUMzQjthQUFNLElBQUksS0FBSyxHQUFHLGFBQWEsRUFBRTtZQUNoQyxTQUFTLEdBQUcsUUFBUSxHQUFHLENBQUMsQ0FBQztTQUMxQjtLQUNGO0lBRUQsT0FBTyxJQUFJLENBQUM7QUFDZCxDQUFDLENBQUMifQ==
|
|
File without changes
|
|
@@ -14,4 +14,4 @@ exports.factorial = function (x) {
|
|
|
14
14
|
exports.memoizedFactorial = memoize_1.memoize(function (n) {
|
|
15
15
|
return n > 1 ? n * exports.memoizedFactorial(n - 1) : n;
|
|
16
16
|
});
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yaWFsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2ZhY3RvcmlhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxQ0FBb0M7QUFHcEM7O0dBRUc7QUFDVSxRQUFBLFNBQVMsR0FBRyxVQUFDLENBQVM7SUFDakMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLEdBQUcsaUJBQVMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUMxQyxDQUFDLENBQUM7QUFFRjs7R0FFRztBQUNVLFFBQUEsaUJBQWlCLEdBQWdDLGlCQUFPLENBQ25FLFVBQUMsQ0FBUztJQUNSLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLHlCQUFpQixDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ2xELENBQUMsQ0FDRixDQUFDIn0=
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.memoizedFibonacci = exports.fibonacci = void 0;
|
|
4
|
+
var memoize_1 = require("./memoize");
|
|
5
|
+
/**
|
|
6
|
+
* Time complexity: O(n!)
|
|
7
|
+
*/
|
|
8
|
+
exports.fibonacci = function (n) {
|
|
9
|
+
return n > 1 ? exports.fibonacci(n - 1) + exports.fibonacci(n - 2) : n;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Time complexity: O(n) - due to caching
|
|
13
|
+
*/
|
|
14
|
+
exports.memoizedFibonacci = memoize_1.memoize(function (n) {
|
|
15
|
+
return n > 1 ? exports.memoizedFibonacci(n - 1) + exports.memoizedFibonacci(n - 2) : n;
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlib25hY2NpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2ZpYm9uYWNjaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSxxQ0FBb0M7QUFFcEM7O0dBRUc7QUFDVSxRQUFBLFNBQVMsR0FBRyxVQUFDLENBQVM7SUFDakMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxpQkFBUyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsR0FBRyxpQkFBUyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3pELENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1UsUUFBQSxpQkFBaUIsR0FBZ0MsaUJBQU8sQ0FDbkUsVUFBQyxDQUFTO0lBQ1IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyx5QkFBaUIsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEdBQUcseUJBQWlCLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFDekUsQ0FBQyxDQUNGLENBQUMifQ==
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/AbstractGraphIterator.d.ts
RENAMED
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
+
r[k] = a[j];
|
|
7
|
+
return r;
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
var IsNotFoundException_1 = require("../../../exceptions/IsNotFoundException");
|
|
11
|
+
var IllegalStateException_1 = require("../../../exceptions/base/IllegalStateException");
|
|
12
|
+
var AbstractGraphIterator = /** @class */ (function () {
|
|
13
|
+
/**
|
|
14
|
+
* Creates empty instance
|
|
15
|
+
*/
|
|
16
|
+
function AbstractGraphIterator(graph) {
|
|
17
|
+
this.graph = graph;
|
|
18
|
+
this.visited = new Map();
|
|
19
|
+
this.parents = new Map();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
AbstractGraphIterator.prototype.initIterator = function (from) {
|
|
25
|
+
if (!this.graph.hasVertex(from)) {
|
|
26
|
+
throw new IsNotFoundException_1.default("Start vertex does not exist");
|
|
27
|
+
}
|
|
28
|
+
this.initIteratorImpl(from);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
AbstractGraphIterator.prototype.hasNext = function () {
|
|
34
|
+
return this.hasNextImpl();
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
AbstractGraphIterator.prototype.next = function () {
|
|
40
|
+
if (!this.hasNext()) {
|
|
41
|
+
throw new IllegalStateException_1.default("Next element does not exist");
|
|
42
|
+
}
|
|
43
|
+
return this.nextImpl();
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* @inheritDoc
|
|
47
|
+
*/
|
|
48
|
+
AbstractGraphIterator.prototype.current = function () {
|
|
49
|
+
try {
|
|
50
|
+
return this.currentImpl();
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
throw new IllegalStateException_1.default("Current element does not exist");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
AbstractGraphIterator.prototype.getPath = function (from, to) {
|
|
60
|
+
var path = new Array();
|
|
61
|
+
var isLinkedDirectly = this.graph.hasEdge(from, to);
|
|
62
|
+
var currentVertex = this.parents.get(to);
|
|
63
|
+
if (isLinkedDirectly) {
|
|
64
|
+
return [from, to];
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
while (currentVertex) {
|
|
68
|
+
if (currentVertex === from) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
path.push(currentVertex);
|
|
72
|
+
currentVertex = this.parents.get(currentVertex);
|
|
73
|
+
}
|
|
74
|
+
if (path.length === 0) {
|
|
75
|
+
throw new IllegalStateException_1.default("There is no path found");
|
|
76
|
+
}
|
|
77
|
+
return __spreadArrays([from], path.reverse(), [to]);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return AbstractGraphIterator;
|
|
81
|
+
}());
|
|
82
|
+
exports.default = AbstractGraphIterator;
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWJzdHJhY3RHcmFwaEl0ZXJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2dyYXBoL2l0ZXJhdG9yL0Fic3RyYWN0R3JhcGhJdGVyYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFFQSwrRUFBMEU7QUFDMUUsd0ZBQW1GO0FBRW5GO0lBTUU7O09BRUc7SUFDSCwrQkFBc0IsS0FBZ0I7UUFDcEMsSUFBSSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUM7UUFDbkIsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLEdBQUcsRUFBRSxDQUFDO1FBQ3pCLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxHQUFHLEVBQUUsQ0FBQztJQUMzQixDQUFDO0lBT0Q7O09BRUc7SUFDSSw0Q0FBWSxHQUFuQixVQUFvQixJQUF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DQUFDO1FBRXpDLElBQUksZ0JBQWdCLEVBQUU7WUFDcEIsT0FBTyxDQUFDLElBQUksRUFBRSxFQUFFLENBQUMsQ0FBQztTQUNuQjthQUFNO1lBQ0wsT0FBTyxhQUFhLEVBQUU7Z0JBQ3BCLElBQUksYUFBYSxLQUFLLElBQUksRUFBRTtvQkFDMUIsTUFBTTtpQkFDUDtnQkFFRCxJQUFJLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxDQUFDO2dCQUN6QixhQUFhLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsYUFBYSxDQUFDLENBQUM7YUFDakQ7WUFFRCxJQUFJLElBQUksQ0FBQyxNQUFNLEtBQUssQ0FBQyxFQUFFO2dCQUNyQixNQUFNLElBQUksK0JBQXFCLENBQUMsd0JBQXdCLENBQUMsQ0FBQzthQUMzRDtZQUVELHVCQUFRLElBQUksR0FBSyxJQUFJLENBQUMsT0FBTyxFQUFFLEdBQUUsRUFBRSxHQUFFO1NBQ3RDO0lBQ0gsQ0FBQztJQUNILDRCQUFDO0FBQUQsQ0FBQyxBQXRGRCxJQXNGQyJ9
|
|
File without changes
|
|
@@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var Queue_1 = require("
|
|
16
|
+
var Queue_1 = require("../../../data-structures/Queue/Queue");
|
|
17
17
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
18
18
|
/**
|
|
19
19
|
* Breadth first graph traversal
|
|
@@ -67,4 +67,4 @@ var GraphIteratorBFS = /** @class */ (function (_super) {
|
|
|
67
67
|
return GraphIteratorBFS;
|
|
68
68
|
}(AbstractGraphIterator_1.default));
|
|
69
69
|
exports.default = GraphIteratorBFS;
|
|
70
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
70
|
+
//# sourceMappingURL=data:application/json;base64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LENBQUM7UUFDOUIsSUFBTSxhQUFhLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUUxRCxhQUFhLENBQUMsT0FBTyxDQUFDLFVBQUMsUUFBUTtZQUM3QixJQUFNLFlBQVksR0FBRyxDQUFDLEtBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFFBQVEsQ0FBQyxDQUFDO1lBRWpELElBQUksWUFBWSxFQUFFO2dCQUNoQixLQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztnQkFDMUIsS0FBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFDO2dCQUNqQyxLQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsSUFBSSxDQUFDLENBQUM7YUFDbEM7UUFDSCxDQUFDLENBQUMsQ0FBQztRQUVILE9BQU8sSUFBSSxDQUFDO0lBQ2QsQ0FBQztJQUNILHVCQUFDO0FBQUQsQ0FBQyxBQXBERCxDQUFpRCwrQkFBcUIsR0FvRHJFIn0=
|
|
File without changes
|
|
@@ -13,7 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
var Stack_1 = require("
|
|
16
|
+
var Stack_1 = require("../../../data-structures/Stack/Stack");
|
|
17
17
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
18
18
|
/**
|
|
19
19
|
* Deep first graph traversal
|
|
@@ -67,4 +67,4 @@ var GraphIteratorDFS = /** @class */ (function (_super) {
|
|
|
67
67
|
return GraphIteratorDFS;
|
|
68
68
|
}(AbstractGraphIterator_1.default));
|
|
69
69
|
exports.default = GraphIteratorDFS;
|
|
70
|
-
//# sourceMappingURL=data:application/json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SUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLEVBQUUsQ0FBQztRQUM5QixJQUFNLGFBQWEsR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyxDQUFDO1FBRTFELGFBQWEsQ0FBQyxPQUFPLENBQUMsVUFBQyxRQUFRO1lBQzdCLElBQU0sWUFBWSxHQUFHLENBQUMsS0FBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLENBQUM7WUFFakQsSUFBSSxZQUFZLEVBQUU7Z0JBQ2hCLEtBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFDO2dCQUMxQixLQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEVBQUUsSUFBSSxDQUFDLENBQUM7Z0JBQ2pDLEtBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQzthQUNsQztRQUNILENBQUMsQ0FBQyxDQUFDO1FBRUgsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBQ0gsdUJBQUM7QUFBRCxDQUFDLEFBcERELENBQWlELCtCQUFxQixHQW9EckUifQ==
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.d.ts
RENAMED
|
File without changes
|
package/lib/{data-structures/Graph → app/algorithms/graph}/iterator/GraphIteratorDijkstra.js
RENAMED
|
@@ -14,6 +14,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
var AbstractGraphIterator_1 = require("./AbstractGraphIterator");
|
|
17
|
+
var IllegalStateException_1 = require("../../../exceptions/base/IllegalStateException");
|
|
17
18
|
/**
|
|
18
19
|
* Dijkstra method graph traversal
|
|
19
20
|
*/
|
|
@@ -41,7 +42,7 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
41
42
|
return aCost - bCost;
|
|
42
43
|
});
|
|
43
44
|
if (priorityList[0] === undefined) {
|
|
44
|
-
throw new
|
|
45
|
+
throw new IllegalStateException_1.default("No more vertices found");
|
|
45
46
|
}
|
|
46
47
|
return priorityList[0];
|
|
47
48
|
};
|
|
@@ -50,9 +51,6 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
50
51
|
*/
|
|
51
52
|
GraphIteratorDijkstra.prototype.initIteratorImpl = function (startVertex) {
|
|
52
53
|
var _this = this;
|
|
53
|
-
if (!this.graph.hasVertex(startVertex)) {
|
|
54
|
-
throw new Error("Start vertex does not exist");
|
|
55
|
-
}
|
|
56
54
|
this.visited.set(startVertex, true);
|
|
57
55
|
this.costs.set(startVertex, 0);
|
|
58
56
|
this.graph.getVertexNeighbors(startVertex).forEach(function (neighbor) {
|
|
@@ -96,4 +94,4 @@ var GraphIteratorDijkstra = /** @class */ (function (_super) {
|
|
|
96
94
|
return GraphIteratorDijkstra;
|
|
97
95
|
}(AbstractGraphIterator_1.default));
|
|
98
96
|
exports.default = GraphIteratorDijkstra;
|
|
99
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR3JhcGhJdGVyYXRvckRpamtzdHJhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2FwcC9hbGdvcml0aG1zL2dyYXBoL2l0ZXJhdG9yL0dyYXBoSXRlcmF0b3JEaWprc3RyYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7QUFDQSxpRUFBNEQ7QUFDNUQsd0ZBQW1GO0FBRW5GOztHQUVHO0FBQ0g7SUFBc0QseUNBQXdCO0lBRzVFOztPQUVHO0lBQ0gsK0JBQW1CLEtBQWdCO1F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0FBQyxDQUFDO1FBQzFELElBQU0sUUFBUSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBRXRDLGFBQWEsQ0FBQyxPQUFPLENBQUMsVUFBQyxRQUFXO1lBQ2hDLElBQU0sVUFBVSxHQUFHLEtBQUksQ0FBQyxLQUFLLENBQUMsYUFBYSxDQUFDLElBQUksRUFBRSxRQUFRLENBQUMsQ0FBQztZQUM1RCxJQUFNLG1CQUFtQixHQUFHLEtBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLFFBQVEsQ0FBQyxJQUFJLFFBQVEsQ0FBQztZQUNqRSxJQUFNLGVBQWUsR0FBRyxDQUFDLFFBQVEsSUFBSSxDQUFDLENBQUMsR0FBRyxVQUFVLENBQUM7WUFFckQsSUFBSSxlQUFlLEdBQUcsbUJBQW1CLEVBQUU7Z0JBQ3pDLEtBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLFFBQVEsRUFBRSxlQUFlLENBQUMsQ0FBQztnQkFDMUMsS0FBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFDO2FBQ2xDO1FBQ0gsQ0FBQyxDQUFDLENBQUM7UUFFSCxPQUFPLElBQUksQ0FBQztJQUNkLENBQUM7SUFDSCw0QkFBQztBQUFELENBQUMsQUFuRkQsQ0FBc0QsK0JBQXFCLEdBbUYxRSJ9
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var BFSIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return BFSIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = BFSIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQkZTSXRlcmF0aW9uU3RyYXRlZ3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvaXRlcmF0b3Itc3RyYXRlZ3kvQkZTSXRlcmF0aW9uU3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxpRUFBNEQ7QUFFNUQ7SUFBQTtJQUtBLENBQUM7SUFIUSw2Q0FBYyxHQUFyQixVQUFzQixLQUFnQjtRQUNwQyxPQUFPLElBQUksMEJBQWdCLENBQUksS0FBSyxDQUFDLENBQUM7SUFDeEMsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FBQyxBQUxELElBS0MifQ==
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var DFSIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return DFSIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = DFSIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiREZTSXRlcmF0aW9uU3RyYXRlZ3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvaXRlcmF0b3Itc3RyYXRlZ3kvREZTSXRlcmF0aW9uU3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFHQSxpRUFBNEQ7QUFFNUQ7SUFBQTtJQUtBLENBQUM7SUFIUSw2Q0FBYyxHQUFyQixVQUFzQixLQUFnQjtRQUNwQyxPQUFPLElBQUksMEJBQWdCLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDckMsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FBQyxBQUxELElBS0MifQ==
|
|
File without changes
|
|
@@ -10,4 +10,4 @@ var DijkstraIterationStrategy = /** @class */ (function () {
|
|
|
10
10
|
return DijkstraIterationStrategy;
|
|
11
11
|
}());
|
|
12
12
|
exports.default = DijkstraIterationStrategy;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRGlqa3N0cmFJdGVyYXRpb25TdHJhdGVneS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9hcHAvYWxnb3JpdGhtcy9ncmFwaC9pdGVyYXRvci1zdHJhdGVneS9EaWprc3RyYUl0ZXJhdGlvblN0cmF0ZWd5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBR0EsMkVBQXNFO0FBRXRFO0lBQUE7SUFLQSxDQUFDO0lBSFEsa0RBQWMsR0FBckIsVUFBc0IsS0FBZ0I7UUFDcEMsT0FBTyxJQUFJLCtCQUFxQixDQUFDLEtBQUssQ0FBQyxDQUFDO0lBQzFDLENBQUM7SUFDSCxnQ0FBQztBQUFELENBQUMsQUFMRCxJQUtDIn0=
|
package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.d.ts
RENAMED
|
File without changes
|
package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyLists.js
RENAMED
|
@@ -25,4 +25,4 @@ exports.presenterAdjacencyLists = function (graph) {
|
|
|
25
25
|
return map;
|
|
26
26
|
}, new Map());
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJlc2VudGVyQWRqYWNlbmN5TGlzdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2FsZ29yaXRobXMvZ3JhcGgvcHJlc2VudGVyL3ByZXNlbnRlckFkamFjZW5jeUxpc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBOzs7Ozs7Ozs7Ozs7Ozs7O0lBZ0JJO0FBQ1MsUUFBQSx1QkFBdUIsR0FBRyxVQUNyQyxLQUFnQjtJQUVoQixPQUFPLEtBQUssQ0FBQyxRQUFRLEVBQUUsQ0FBQyxNQUFNLENBQUMsVUFBQyxHQUFxQixFQUFFLE1BQVM7UUFDOUQsSUFBTSxTQUFTLEdBQUcsS0FBSyxDQUFDLGtCQUFrQixDQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQ25ELEdBQUcsQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLFNBQVMsQ0FBQyxDQUFDO1FBRTNCLE9BQU8sR0FBRyxDQUFDO0lBQ2IsQ0FBQyxFQUFFLElBQUksR0FBRyxFQUFFLENBQUMsQ0FBQztBQUNoQixDQUFDLENBQUMifQ==
|
package/lib/{data-structures/Graph → app/algorithms/graph}/presenter/presenterAdjacencyMatrix.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import IGraph from "../../../types/IGraph";
|
|
2
|
-
import {
|
|
2
|
+
import { TypeArrayMatrix } from "../../../types/TypeArrayMatrix";
|
|
3
3
|
/**
|
|
4
4
|
* Get graph adjacency matrix N x N
|
|
5
5
|
*
|
|
@@ -29,4 +29,4 @@ import { ArrayMatrix } from "../../../types/ArrayMatrix";
|
|
|
29
29
|
* Maria | 1 | 0 | 1 |
|
|
30
30
|
* John | 0 | 1 | 0 |
|
|
31
31
|
*/
|
|
32
|
-
export declare const presenterAdjacencyMatrix: <T>(graph: IGraph<T>) =>
|
|
32
|
+
export declare const presenterAdjacencyMatrix: <T>(graph: IGraph<T>) => TypeArrayMatrix;
|