graph-typed 1.38.2 → 1.38.4
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/.dependency-cruiser.js +422 -422
- package/.eslintrc.js +59 -59
- package/.prettierrc.js +14 -14
- package/README.md +21 -3
- package/coverage/clover.xml +22 -19
- package/coverage/coverage-final.json +445 -1
- package/coverage/coverage-summary.json +59 -2
- package/coverage/lcov-report/base.css +278 -99
- package/coverage/lcov-report/index.html +69 -65
- package/coverage/lcov-report/index.ts.html +45 -44
- package/coverage/lcov-report/sorter.js +15 -5
- package/dist/data-structures/binary-tree/binary-tree.d.ts +9 -9
- package/dist/data-structures/binary-tree/bst.d.ts +4 -4
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/helpers.d.ts +1 -1
- package/jest.config.js +6 -6
- package/package.json +4 -1
- package/src/data-structures/binary-tree/avl-tree.ts +1 -1
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +1 -1
- package/src/data-structures/binary-tree/binary-tree.ts +21 -21
- package/src/data-structures/binary-tree/bst.ts +7 -7
- package/src/data-structures/binary-tree/tree-multiset.ts +2 -1
- package/src/data-structures/graph/abstract-graph.ts +11 -10
- package/src/data-structures/graph/directed-graph.ts +2 -1
- package/src/data-structures/graph/undirected-graph.ts +5 -4
- package/src/data-structures/hash/hash-map.ts +1 -1
- package/src/data-structures/hash/tree-map.ts +1 -2
- package/src/data-structures/hash/tree-set.ts +1 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/matrix/matrix.ts +1 -1
- package/src/data-structures/matrix/vector2d.ts +1 -2
- package/src/data-structures/queue/deque.ts +4 -5
- package/src/data-structures/queue/queue.ts +1 -1
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/matrix/navigator.ts +1 -1
- package/src/types/helpers.ts +1 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +2 -2
- package/tsconfig.json +1 -2
package/.eslintrc.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
'rules': {
|
|
7
|
-
'react/display-name': 'off',
|
|
8
|
-
'@next/next/no-img-element': 'off',
|
|
9
|
-
'react/no-unescaped-entities': 'off',
|
|
10
|
-
'import/no-anonymous-default-export': 'off',
|
|
11
|
-
'@typescript-eslint/no-unused-vars': 'error',
|
|
12
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
|
13
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
14
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
15
|
-
// add new line above comment
|
|
16
|
-
'lines-around-comment': [
|
|
17
|
-
'error',
|
|
18
|
-
{
|
|
19
|
-
'beforeLineComment': false,
|
|
20
|
-
'beforeBlockComment': true,
|
|
21
|
-
'allowBlockStart': true,
|
|
22
|
-
'allowClassStart': true,
|
|
23
|
-
'allowObjectStart': true,
|
|
24
|
-
'allowArrayStart': true
|
|
25
|
-
}
|
|
2
|
+
'extends': [
|
|
3
|
+
'plugin:@typescript-eslint/recommended',
|
|
4
|
+
'prettier'
|
|
26
5
|
],
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'
|
|
34
|
-
|
|
6
|
+
'rules': {
|
|
7
|
+
'react/display-name': 'off',
|
|
8
|
+
'@next/next/no-img-element': 'off',
|
|
9
|
+
'react/no-unescaped-entities': 'off',
|
|
10
|
+
'import/no-anonymous-default-export': 'off',
|
|
11
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
12
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
13
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
14
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
15
|
+
// add new line above comment
|
|
16
|
+
'lines-around-comment': [
|
|
17
|
+
'error',
|
|
18
|
+
{
|
|
19
|
+
'beforeLineComment': false,
|
|
20
|
+
'beforeBlockComment': true,
|
|
21
|
+
'allowBlockStart': true,
|
|
22
|
+
'allowClassStart': true,
|
|
23
|
+
'allowObjectStart': true,
|
|
24
|
+
'allowArrayStart': true
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
// add new line above return
|
|
28
|
+
'newline-before-return': 'off',
|
|
29
|
+
// add new line below import
|
|
30
|
+
'import/newline-after-import': [
|
|
31
|
+
'error',
|
|
32
|
+
{
|
|
33
|
+
'count': 1
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
'@typescript-eslint/ban-types': [
|
|
37
|
+
'error',
|
|
38
|
+
{
|
|
39
|
+
'extendDefaults': true,
|
|
40
|
+
'types': {
|
|
41
|
+
'{}': false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
'plugins': [
|
|
47
|
+
'import'
|
|
35
48
|
],
|
|
36
|
-
'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
'settings': {
|
|
50
|
+
'import/parsers': {
|
|
51
|
+
'@typescript-eslint/parser': [
|
|
52
|
+
'.ts',
|
|
53
|
+
'.tsx'
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
'import/resolver': {
|
|
57
|
+
'typescript': {
|
|
58
|
+
'alwaysTryTypes': true,
|
|
59
|
+
'project': [
|
|
60
|
+
'./tsconfig.json'
|
|
61
|
+
]
|
|
62
|
+
}
|
|
42
63
|
}
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
'plugins': [
|
|
47
|
-
'import'
|
|
48
|
-
],
|
|
49
|
-
'settings': {
|
|
50
|
-
'import/parsers': {
|
|
51
|
-
'@typescript-eslint/parser': [
|
|
52
|
-
'.ts',
|
|
53
|
-
'.tsx'
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
'import/resolver': {
|
|
57
|
-
'typescript': {
|
|
58
|
-
'alwaysTryTypes': true,
|
|
59
|
-
'project': [
|
|
60
|
-
'./tsconfig.json'
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
64
|
}
|
|
64
|
-
}
|
|
65
65
|
}
|
package/.prettierrc.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
arrowParens: 'avoid',
|
|
3
|
+
bracketSpacing: true,
|
|
4
|
+
htmlWhitespaceSensitivity: 'css',
|
|
5
|
+
insertPragma: false,
|
|
6
|
+
bracketSameLine: false,
|
|
7
|
+
jsxSingleQuote: true,
|
|
8
|
+
printWidth: 120,
|
|
9
|
+
proseWrap: 'preserve',
|
|
10
|
+
quoteProps: 'as-needed',
|
|
11
|
+
requirePragma: false,
|
|
12
|
+
singleQuote: true,
|
|
13
|
+
tabWidth: 2,
|
|
14
|
+
trailingComma: 'none',
|
|
15
|
+
useTabs: false
|
|
16
16
|
}
|
package/README.md
CHANGED
|
@@ -7,29 +7,42 @@
|
|
|
7
7
|

|
|
8
8
|
|
|
9
9
|
# What
|
|
10
|
+
|
|
10
11
|
## Brief
|
|
11
|
-
This is a standalone Graph data structure from the data-structure-typed collection. If you wish to access more data structures or advanced features, you can transition to directly installing the complete [data-structure-typed](https://www.npmjs.com/package/data-structure-typed) package
|
|
12
12
|
|
|
13
|
+
This is a standalone Graph data structure from the data-structure-typed collection. If you wish to access more data
|
|
14
|
+
structures or advanced features, you can transition to directly installing the
|
|
15
|
+
complete [data-structure-typed](https://www.npmjs.com/package/data-structure-typed) package
|
|
13
16
|
|
|
14
17
|
# How
|
|
15
18
|
|
|
16
19
|
## install
|
|
20
|
+
|
|
17
21
|
### npm
|
|
22
|
+
|
|
18
23
|
```bash
|
|
19
24
|
npm i graph-typed --save
|
|
20
25
|
```
|
|
26
|
+
|
|
21
27
|
### yarn
|
|
28
|
+
|
|
22
29
|
```bash
|
|
23
30
|
yarn add graph-typed
|
|
24
31
|
```
|
|
32
|
+
|
|
25
33
|
### methods
|
|
34
|
+
|
|
26
35
|
Directed Graph
|
|
27
36
|

|
|
28
37
|
Undirected Graph
|
|
29
38
|

|
|
39
|
+
|
|
30
40
|
### snippet
|
|
41
|
+
|
|
31
42
|
#### TS
|
|
43
|
+
|
|
32
44
|
##### DirectedGraph
|
|
45
|
+
|
|
33
46
|
```typescript
|
|
34
47
|
import {DirectedGraph, DirectedVertex, DirectedEdge} from 'data-structure-typed';
|
|
35
48
|
// /* or if you prefer */ import {DirectedGraph, DirectedVertex, DirectedEdge} from 'graph-typed';
|
|
@@ -50,7 +63,9 @@ graph.addEdge(edgeBC);
|
|
|
50
63
|
const topologicalOrder = graph.topologicalSort();
|
|
51
64
|
if (topologicalOrder) expect(topologicalOrder).toEqual(['A', 'B', 'C'])
|
|
52
65
|
```
|
|
66
|
+
|
|
53
67
|
##### MapGraph
|
|
68
|
+
|
|
54
69
|
```typescript
|
|
55
70
|
import {MapGraph, MapVertex} from 'data-structure-typed';
|
|
56
71
|
// /* or if you prefer */ import {MapGraph, MapVertex} from 'graph-typed';
|
|
@@ -95,8 +110,11 @@ const surinToSaanenGoatFarmViaDij = mapGraph.dijkstra('Surin', 'Saanen Goat Farm
|
|
|
95
110
|
expect(surinToSaanenGoatFarmViaDij?.minPath.map(v => v.id)).toEqual(expected2);
|
|
96
111
|
expect(surinToSaanenGoatFarmViaDij?.minDist).toBe(25.2);
|
|
97
112
|
```
|
|
113
|
+
|
|
98
114
|
#### JS
|
|
115
|
+
|
|
99
116
|
##### DirectedGraph
|
|
117
|
+
|
|
100
118
|
```typescript
|
|
101
119
|
const {DirectedGraph, DirectedVertex, DirectedEdge} = require('data-structure-typed');
|
|
102
120
|
// /* or if you prefer */ const {DirectedGraph, DirectedVertex, DirectedEdge} = require('graph-typed');
|
|
@@ -117,7 +135,9 @@ graph.addEdge(edgeBC);
|
|
|
117
135
|
const topologicalOrder = graph.topologicalSort();
|
|
118
136
|
if (topologicalOrder) expect(topologicalOrder).toEqual(['A', 'B', 'C'])
|
|
119
137
|
```
|
|
138
|
+
|
|
120
139
|
##### MapGraph
|
|
140
|
+
|
|
121
141
|
```javascript
|
|
122
142
|
const {MapGraph, MapVertex} = require('data-structure-typed');
|
|
123
143
|
// /* or if you prefer */ const {MapGraph, MapVertex} = require('graph-typed');
|
|
@@ -163,7 +183,6 @@ expect(surinToSaanenGoatFarmViaDij?.minPath.map(v => v.id)).toEqual(expected2);
|
|
|
163
183
|
expect(surinToSaanenGoatFarmViaDij?.minDist).toBe(25.2);
|
|
164
184
|
```
|
|
165
185
|
|
|
166
|
-
|
|
167
186
|
## API docs & Examples
|
|
168
187
|
|
|
169
188
|
[API Docs](https://data-structure-typed-docs.vercel.app)
|
|
@@ -365,7 +384,6 @@ expect(surinToSaanenGoatFarmViaDij?.minDist).toBe(25.2);
|
|
|
365
384
|
</tbody>
|
|
366
385
|
</table>
|
|
367
386
|
|
|
368
|
-
|
|
369
387
|
# Why
|
|
370
388
|
|
|
371
389
|
## Complexities
|
package/coverage/clover.xml
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<coverage generated="1696760561670" clover="3.2.0">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
<project timestamp="1696760561670" name="All files">
|
|
4
|
+
<metrics statements="13" coveredstatements="13" conditionals="0" coveredconditionals="0" methods="12"
|
|
5
|
+
coveredmethods="3" elements="25" coveredelements="16" complexity="0" loc="13" ncloc="13" packages="1"
|
|
6
|
+
files="1" classes="1"/>
|
|
7
|
+
<file name="index.ts" path="/Users/revone/projects/data-structure-typed-individuals/graph-typed/src/index.ts">
|
|
8
|
+
<metrics statements="13" coveredstatements="13" conditionals="0" coveredconditionals="0" methods="12"
|
|
9
|
+
coveredmethods="3"/>
|
|
10
|
+
<line num="8" count="1" type="stmt"/>
|
|
11
|
+
<line num="9" count="1" type="stmt"/>
|
|
12
|
+
<line num="10" count="1" type="stmt"/>
|
|
13
|
+
<line num="11" count="1" type="stmt"/>
|
|
14
|
+
<line num="12" count="11" type="stmt"/>
|
|
15
|
+
<line num="13" count="6" type="stmt"/>
|
|
16
|
+
<line num="14" count="6" type="stmt"/>
|
|
17
|
+
<line num="15" count="1" type="stmt"/>
|
|
18
|
+
<line num="16" count="1" type="stmt"/>
|
|
19
|
+
<line num="17" count="1" type="stmt"/>
|
|
20
|
+
<line num="18" count="1" type="stmt"/>
|
|
21
|
+
<line num="19" count="1" type="stmt"/>
|
|
22
|
+
<line num="20" count="1" type="stmt"/>
|
|
23
|
+
</file>
|
|
24
|
+
</project>
|
|
22
25
|
</coverage>
|