data-structure-typed 1.49.2 → 1.49.3
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/CHANGELOG.md +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +7 -7
- package/dist/cjs/data-structures/graph/abstract-graph.js +43 -12
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/cjs/data-structures/graph/directed-graph.js +2 -2
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +43 -43
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +49 -49
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +25 -25
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +36 -36
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +33 -33
- package/dist/cjs/data-structures/queue/queue.js +40 -40
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +7 -7
- package/dist/mjs/data-structures/graph/abstract-graph.js +43 -12
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/mjs/data-structures/graph/directed-graph.js +2 -2
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +1 -1
- package/dist/mjs/data-structures/graph/undirected-graph.js +1 -1
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +43 -43
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +47 -47
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +25 -25
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +36 -36
- package/dist/mjs/data-structures/queue/queue.d.ts +33 -33
- package/dist/mjs/data-structures/queue/queue.js +39 -39
- package/dist/umd/data-structure-typed.js +171 -140
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/graph/abstract-graph.ts +55 -14
- package/src/data-structures/graph/directed-graph.ts +3 -2
- package/src/data-structures/graph/undirected-graph.ts +1 -1
- package/src/data-structures/linked-list/doubly-linked-list.ts +53 -53
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +40 -40
- package/src/data-structures/queue/queue.ts +45 -45
- package/test/unit/data-structures/graph/abstract-graph.test.ts +1 -1
- package/test/unit/data-structures/graph/directed-graph.test.ts +48 -3
- package/test/unit/data-structures/graph/undirected-graph.test.ts +48 -4
- package/test/unit/data-structures/heap/heap.test.ts +6 -1
|
@@ -588,7 +588,7 @@ describe('cycles, strongly connected components, bridges, articular points in Di
|
|
|
588
588
|
const cutVertexes = graph.getCutVertexes();
|
|
589
589
|
const dfnMap = graph.getDFNMap();
|
|
590
590
|
const lowMap = graph.getLowMap();
|
|
591
|
-
expect(cycles.
|
|
591
|
+
expect(cycles.length).toBe(2);
|
|
592
592
|
expect(scCs.size).toBe(5);
|
|
593
593
|
expect(bridges.length).toBe(4);
|
|
594
594
|
expect(cutVertexes.length).toBe(4);
|
|
@@ -688,8 +688,53 @@ describe('DirectedGraph getCycles', () => {
|
|
|
688
688
|
graph.addEdge('D', 'E');
|
|
689
689
|
graph.addEdge('E', 'B');
|
|
690
690
|
const cycles = graph.getCycles();
|
|
691
|
-
expect(cycles.
|
|
692
|
-
expect(cycles
|
|
691
|
+
expect(cycles.length).toBe(1);
|
|
692
|
+
expect(cycles[0]).toEqual(["B", "D", "E"]);
|
|
693
693
|
})
|
|
694
|
+
|
|
695
|
+
test('should simple cycles graph getCycles return correct result', () => {
|
|
696
|
+
const graph = new DirectedGraph();
|
|
697
|
+
|
|
698
|
+
graph.addVertex('A');
|
|
699
|
+
graph.addVertex('B');
|
|
700
|
+
graph.addVertex('C');
|
|
701
|
+
graph.addVertex('D');
|
|
702
|
+
|
|
703
|
+
graph.addEdge('A', 'B');
|
|
704
|
+
graph.addEdge('B', 'C');
|
|
705
|
+
graph.addEdge('C', 'A');
|
|
706
|
+
graph.addEdge('A', 'D');
|
|
707
|
+
graph.addEdge('D', 'C');
|
|
708
|
+
const cycles = graph.getCycles();
|
|
709
|
+
expect(cycles.length).toBe(2)
|
|
710
|
+
expect(cycles).toEqual([["A", "B", "C"], ["A", "D", "C"]])
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
test('should 3 cycles graph getCycles return correct result', () => {
|
|
714
|
+
const graph = new DirectedGraph();
|
|
715
|
+
|
|
716
|
+
graph.addVertex('A');
|
|
717
|
+
graph.addVertex('B');
|
|
718
|
+
graph.addVertex('C');
|
|
719
|
+
graph.addVertex('D');
|
|
720
|
+
graph.addVertex('E');
|
|
721
|
+
graph.addVertex('F');
|
|
722
|
+
graph.addVertex('G');
|
|
723
|
+
|
|
724
|
+
graph.addEdge('A', 'B');
|
|
725
|
+
graph.addEdge('A', 'C');
|
|
726
|
+
graph.addEdge('B', 'D');
|
|
727
|
+
graph.addEdge('C', 'D');
|
|
728
|
+
graph.addEdge('D', 'E');
|
|
729
|
+
graph.addEdge('E', 'B');
|
|
730
|
+
graph.addEdge('B', 'F');
|
|
731
|
+
graph.addEdge('F', 'E');
|
|
732
|
+
graph.addEdge('C', 'G');
|
|
733
|
+
graph.addEdge('G', 'A');
|
|
734
|
+
|
|
735
|
+
const cycles = graph.getCycles();
|
|
736
|
+
expect(cycles.length).toBe(3)
|
|
737
|
+
expect(cycles).toEqual([["A", "C", "G"], ["B", "D", "E"], ["B", "F", "E"]]);
|
|
738
|
+
});
|
|
694
739
|
})
|
|
695
740
|
|
|
@@ -237,7 +237,7 @@ describe('cycles, strongly connected components, bridges, articular points in Un
|
|
|
237
237
|
const cutVertexes = graph.getCutVertexes();
|
|
238
238
|
const dfnMap = graph.getDFNMap();
|
|
239
239
|
const lowMap = graph.getLowMap();
|
|
240
|
-
expect(cycles.
|
|
240
|
+
expect(cycles.length).toBe(3);
|
|
241
241
|
expect(scCs.size).toBe(5);
|
|
242
242
|
expect(bridges.length).toBe(4);
|
|
243
243
|
expect(cutVertexes.length).toBe(4);
|
|
@@ -277,8 +277,52 @@ describe('UndirectedGraph getCycles', () => {
|
|
|
277
277
|
graph.addEdge('D', 'E');
|
|
278
278
|
graph.addEdge('E', 'B');
|
|
279
279
|
const cycles = graph.getCycles();
|
|
280
|
-
expect(cycles.
|
|
281
|
-
expect(cycles
|
|
282
|
-
expect(cycles.get(2)).toEqual([{ "key": "B", "value": "B" }, { "key": "D", "value": "D" }, { "key": "E", "value": "E" }]);
|
|
280
|
+
expect(cycles.length).toBe(3);
|
|
281
|
+
expect(cycles).toEqual([["A", "B", "D", "C"], ["A", "B", "E", "D", "C"], ["B", "D", "E"]]);
|
|
283
282
|
})
|
|
283
|
+
|
|
284
|
+
test('should simple cycles graph getCycles return correct result', () => {
|
|
285
|
+
const graph = new UndirectedGraph();
|
|
286
|
+
|
|
287
|
+
graph.addVertex('A');
|
|
288
|
+
graph.addVertex('B');
|
|
289
|
+
graph.addVertex('C');
|
|
290
|
+
graph.addVertex('D');
|
|
291
|
+
|
|
292
|
+
graph.addEdge('A', 'B');
|
|
293
|
+
graph.addEdge('B', 'C');
|
|
294
|
+
graph.addEdge('C', 'A');
|
|
295
|
+
graph.addEdge('A', 'D');
|
|
296
|
+
graph.addEdge('D', 'C');
|
|
297
|
+
const cycles = graph.getCycles();
|
|
298
|
+
expect(cycles.length).toBe(3)
|
|
299
|
+
expect(cycles).toEqual([["A", "B", "C"], ["A", "B", "C", "D"], ["A", "C", "D"]])
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
test('should 3 cycles graph getCycles return correct result', () => {
|
|
303
|
+
const graph = new UndirectedGraph();
|
|
304
|
+
|
|
305
|
+
graph.addVertex('A');
|
|
306
|
+
graph.addVertex('B');
|
|
307
|
+
graph.addVertex('C');
|
|
308
|
+
graph.addVertex('D');
|
|
309
|
+
graph.addVertex('E');
|
|
310
|
+
graph.addVertex('F');
|
|
311
|
+
graph.addVertex('G');
|
|
312
|
+
|
|
313
|
+
graph.addEdge('A', 'B');
|
|
314
|
+
graph.addEdge('A', 'C');
|
|
315
|
+
graph.addEdge('B', 'D');
|
|
316
|
+
graph.addEdge('C', 'D');
|
|
317
|
+
graph.addEdge('D', 'E');
|
|
318
|
+
graph.addEdge('E', 'B');
|
|
319
|
+
graph.addEdge('B', 'F');
|
|
320
|
+
graph.addEdge('F', 'E');
|
|
321
|
+
graph.addEdge('C', 'G');
|
|
322
|
+
graph.addEdge('G', 'A');
|
|
323
|
+
|
|
324
|
+
const cycles = graph.getCycles();
|
|
325
|
+
expect(cycles.length).toBe(10)
|
|
326
|
+
expect(cycles).toEqual([["A", "B", "D", "C"], ["A", "B", "D", "C", "G"], ["A", "B", "E", "D", "C"], ["A", "B", "E", "D", "C", "G"], ["A", "B", "F", "E", "D", "C"], ["A", "B", "F", "E", "D", "C", "G"], ["A", "C", "G"], ["B", "D", "E"], ["B", "D", "E", "F"], ["B", "E", "F"]]);
|
|
327
|
+
});
|
|
284
328
|
})
|
|
@@ -5,7 +5,12 @@ import { logBigOMetricsWrap } from '../../../utils';
|
|
|
5
5
|
describe('Heap Operation Test', () => {
|
|
6
6
|
it('should numeric heap work well', function () {
|
|
7
7
|
const minNumHeap = new MinHeap<number>();
|
|
8
|
-
minNumHeap.add(1);
|
|
8
|
+
minNumHeap.add(1);
|
|
9
|
+
minNumHeap.add(6);
|
|
10
|
+
minNumHeap.add(2);
|
|
11
|
+
minNumHeap.add(0);
|
|
12
|
+
minNumHeap.add(5);
|
|
13
|
+
minNumHeap.add(9);
|
|
9
14
|
expect(minNumHeap.has(1)).toBe(true);
|
|
10
15
|
expect(minNumHeap.has(2)).toBe(true);
|
|
11
16
|
expect(minNumHeap.poll()).toBe(0);
|