directed-graph-typed 1.39.6 → 1.41.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.
Files changed (96) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.js +0 -1
  2. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -3
  3. package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -11
  4. package/dist/data-structures/binary-tree/binary-tree.d.ts +13 -20
  5. package/dist/data-structures/binary-tree/binary-tree.js +30 -31
  6. package/dist/data-structures/binary-tree/bst.d.ts +2 -2
  7. package/dist/data-structures/binary-tree/bst.js +4 -4
  8. package/dist/data-structures/binary-tree/rb-tree.d.ts +95 -11
  9. package/dist/data-structures/binary-tree/rb-tree.js +379 -18
  10. package/dist/data-structures/binary-tree/segment-tree.d.ts +10 -26
  11. package/dist/data-structures/binary-tree/segment-tree.js +10 -58
  12. package/dist/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  13. package/dist/data-structures/binary-tree/tree-multiset.js +6 -6
  14. package/dist/data-structures/graph/abstract-graph.d.ts +5 -24
  15. package/dist/data-structures/graph/abstract-graph.js +4 -43
  16. package/dist/data-structures/graph/directed-graph.d.ts +4 -10
  17. package/dist/data-structures/graph/directed-graph.js +2 -20
  18. package/dist/data-structures/graph/map-graph.d.ts +4 -10
  19. package/dist/data-structures/graph/map-graph.js +2 -20
  20. package/dist/data-structures/graph/undirected-graph.d.ts +1 -8
  21. package/dist/data-structures/graph/undirected-graph.js +1 -14
  22. package/dist/data-structures/hash/coordinate-map.d.ts +0 -1
  23. package/dist/data-structures/hash/coordinate-map.js +0 -3
  24. package/dist/data-structures/hash/coordinate-set.d.ts +0 -1
  25. package/dist/data-structures/hash/coordinate-set.js +0 -3
  26. package/dist/data-structures/hash/hash-map.d.ts +8 -14
  27. package/dist/data-structures/hash/hash-map.js +4 -22
  28. package/dist/data-structures/hash/hash-table.d.ts +6 -9
  29. package/dist/data-structures/hash/hash-table.js +0 -9
  30. package/dist/data-structures/heap/heap.d.ts +12 -6
  31. package/dist/data-structures/heap/heap.js +40 -22
  32. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +6 -14
  33. package/dist/data-structures/linked-list/doubly-linked-list.js +18 -42
  34. package/dist/data-structures/linked-list/singly-linked-list.d.ts +5 -11
  35. package/dist/data-structures/linked-list/singly-linked-list.js +17 -35
  36. package/dist/data-structures/linked-list/skip-linked-list.d.ts +29 -10
  37. package/dist/data-structures/linked-list/skip-linked-list.js +62 -17
  38. package/dist/data-structures/matrix/matrix.d.ts +1 -1
  39. package/dist/data-structures/matrix/matrix2d.d.ts +1 -1
  40. package/dist/data-structures/matrix/navigator.d.ts +4 -4
  41. package/dist/data-structures/queue/deque.d.ts +8 -12
  42. package/dist/data-structures/queue/deque.js +31 -43
  43. package/dist/data-structures/queue/queue.d.ts +20 -5
  44. package/dist/data-structures/queue/queue.js +35 -18
  45. package/dist/data-structures/stack/stack.d.ts +2 -1
  46. package/dist/data-structures/stack/stack.js +10 -7
  47. package/dist/data-structures/tree/tree.d.ts +3 -9
  48. package/dist/data-structures/tree/tree.js +3 -21
  49. package/dist/data-structures/trie/trie.d.ts +6 -12
  50. package/dist/data-structures/trie/trie.js +6 -24
  51. package/dist/interfaces/binary-tree.d.ts +1 -1
  52. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  53. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -7
  54. package/dist/types/data-structures/binary-tree/rb-tree.js +11 -6
  55. package/package.json +2 -2
  56. package/src/data-structures/binary-tree/avl-tree.ts +2 -4
  57. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -15
  58. package/src/data-structures/binary-tree/binary-tree.ts +40 -43
  59. package/src/data-structures/binary-tree/bst.ts +9 -10
  60. package/src/data-structures/binary-tree/rb-tree.ts +415 -355
  61. package/src/data-structures/binary-tree/segment-tree.ts +16 -83
  62. package/src/data-structures/binary-tree/tree-multiset.ts +8 -9
  63. package/src/data-structures/graph/abstract-graph.ts +21 -67
  64. package/src/data-structures/graph/directed-graph.ts +13 -39
  65. package/src/data-structures/graph/map-graph.ts +7 -32
  66. package/src/data-structures/graph/undirected-graph.ts +9 -26
  67. package/src/data-structures/hash/coordinate-map.ts +0 -4
  68. package/src/data-structures/hash/coordinate-set.ts +0 -4
  69. package/src/data-structures/hash/hash-map.ts +13 -37
  70. package/src/data-structures/hash/hash-table.ts +6 -18
  71. package/src/data-structures/hash/tree-map.ts +2 -1
  72. package/src/data-structures/hash/tree-set.ts +2 -1
  73. package/src/data-structures/heap/heap.ts +58 -30
  74. package/src/data-structures/heap/max-heap.ts +1 -1
  75. package/src/data-structures/heap/min-heap.ts +1 -1
  76. package/src/data-structures/linked-list/doubly-linked-list.ts +26 -60
  77. package/src/data-structures/linked-list/singly-linked-list.ts +24 -49
  78. package/src/data-structures/linked-list/skip-linked-list.ts +73 -25
  79. package/src/data-structures/matrix/matrix.ts +2 -2
  80. package/src/data-structures/matrix/matrix2d.ts +1 -1
  81. package/src/data-structures/matrix/navigator.ts +4 -4
  82. package/src/data-structures/matrix/vector2d.ts +2 -1
  83. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  84. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  85. package/src/data-structures/priority-queue/priority-queue.ts +1 -1
  86. package/src/data-structures/queue/deque.ts +38 -53
  87. package/src/data-structures/queue/queue.ts +38 -20
  88. package/src/data-structures/stack/stack.ts +13 -9
  89. package/src/data-structures/tree/tree.ts +7 -33
  90. package/src/data-structures/trie/trie.ts +14 -40
  91. package/src/interfaces/binary-tree.ts +1 -1
  92. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  93. package/src/types/data-structures/binary-tree/rb-tree.ts +6 -6
  94. package/src/types/data-structures/matrix/navigator.ts +1 -1
  95. package/src/types/utils/utils.ts +1 -1
  96. package/src/types/utils/validate-type.ts +2 -2
@@ -9,70 +9,18 @@
9
9
  import type {SegmentTreeNodeVal} from '../../types';
10
10
 
11
11
  export class SegmentTreeNode {
12
- constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | null) {
13
- this._start = start;
14
- this._end = end;
15
- this._sum = sum;
16
- this._value = value || null;
17
- }
18
-
19
- private _start = 0;
20
- get start(): number {
21
- return this._start;
22
- }
23
-
24
- set start(v: number) {
25
- this._start = v;
26
- }
27
-
28
- private _end = 0;
29
-
30
- get end(): number {
31
- return this._end;
32
- }
33
-
34
- set end(v: number) {
35
- this._end = v;
36
- }
37
-
38
- private _value: SegmentTreeNodeVal | null = null;
39
-
40
- get value(): SegmentTreeNodeVal | null {
41
- return this._value;
42
- }
43
-
44
- set value(v: SegmentTreeNodeVal | null) {
45
- this._value = v;
46
- }
47
-
48
- private _sum = 0;
12
+ start = 0;
13
+ end = 0;
14
+ value: SegmentTreeNodeVal | null = null;
15
+ sum = 0;
16
+ left: SegmentTreeNode | null = null;
17
+ right: SegmentTreeNode | null = null;
49
18
 
50
- get sum(): number {
51
- return this._sum;
52
- }
53
-
54
- set sum(v: number) {
55
- this._sum = v;
56
- }
57
-
58
- private _left: SegmentTreeNode | null = null;
59
-
60
- get left(): SegmentTreeNode | null {
61
- return this._left;
62
- }
63
-
64
- set left(v: SegmentTreeNode | null) {
65
- this._left = v;
66
- }
67
-
68
- private _right: SegmentTreeNode | null = null;
69
-
70
- get right(): SegmentTreeNode | null {
71
- return this._right;
72
- }
73
-
74
- set right(v: SegmentTreeNode | null) {
75
- this._right = v;
19
+ constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | null) {
20
+ this.start = start;
21
+ this.end = end;
22
+ this.sum = sum;
23
+ this.value = value || null;
76
24
  }
77
25
  }
78
26
 
@@ -101,24 +49,25 @@ export class SegmentTree {
101
49
  }
102
50
  }
103
51
 
104
- private _values: number[] = [];
52
+ protected _values: number[] = [];
105
53
 
106
54
  get values(): number[] {
107
55
  return this._values;
108
56
  }
109
57
 
110
- private _start = 0;
58
+ protected _start = 0;
59
+
111
60
  get start(): number {
112
61
  return this._start;
113
62
  }
114
63
 
115
- private _end: number;
64
+ protected _end: number;
116
65
 
117
66
  get end(): number {
118
67
  return this._end;
119
68
  }
120
69
 
121
- private _root: SegmentTreeNode | null;
70
+ protected _root: SegmentTreeNode | null;
122
71
 
123
72
  get root(): SegmentTreeNode | null {
124
73
  return this._root;
@@ -238,20 +187,4 @@ export class SegmentTree {
238
187
  };
239
188
  return dfs(root, indexA, indexB);
240
189
  }
241
-
242
- protected _setValues(value: number[]) {
243
- this._values = value;
244
- }
245
-
246
- protected _setStart(value: number) {
247
- this._start = value;
248
- }
249
-
250
- protected _setEnd(value: number) {
251
- this._end = value;
252
- }
253
-
254
- protected _setRoot(v: SegmentTreeNode | null) {
255
- this._root = v;
256
- }
257
190
  }
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type {BTNKey, TreeMultisetNodeNested, TreeMultisetOptions} from '../../types';
9
- import {BinaryTreeDeletedResult, CP, FamilyPosition, IterationType, BTNCallback} from '../../types';
9
+ import {BinaryTreeDeletedResult, BTNCallback, CP, FamilyPosition, IterationType} from '../../types';
10
10
  import {IBinaryTree} from '../../interfaces';
11
11
  import {AVLTree, AVLTreeNode} from './avl-tree';
12
12
 
@@ -37,8 +37,7 @@ export class TreeMultisetNode<
37
37
  */
38
38
  export class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = TreeMultisetNode<V, TreeMultisetNodeNested<V>>>
39
39
  extends AVLTree<V, N>
40
- implements IBinaryTree<V, N>
41
- {
40
+ implements IBinaryTree<V, N> {
42
41
  /**
43
42
  * The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to
44
43
  * merge duplicated values.
@@ -93,7 +92,7 @@ export class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = TreeMultis
93
92
  }
94
93
  if (!this.root) {
95
94
  this._setRoot(newNode);
96
- this._setSize(this.size + 1);
95
+ this._size = this.size + 1;
97
96
  newNode && this._setCount(this.count + newNode.count);
98
97
  inserted = this.root;
99
98
  } else {
@@ -113,7 +112,7 @@ export class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = TreeMultis
113
112
  if (cur.left === undefined) {
114
113
  //Add to the left of the current node
115
114
  cur.left = newNode;
116
- this._setSize(this.size + 1);
115
+ this._size = this.size + 1;
117
116
  this._setCount(this.count + newNode.count);
118
117
 
119
118
  traversing = false;
@@ -127,7 +126,7 @@ export class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = TreeMultis
127
126
  if (cur.right === undefined) {
128
127
  //Add to the right of the current node
129
128
  cur.right = newNode;
130
- this._setSize(this.size + 1);
129
+ this._size = this.size + 1;
131
130
  this._setCount(this.count + newNode.count);
132
131
 
133
132
  traversing = false;
@@ -162,7 +161,7 @@ export class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = TreeMultis
162
161
  if (parent.left === undefined) {
163
162
  parent.left = newNode;
164
163
  if (newNode !== null) {
165
- this._setSize(this.size + 1);
164
+ this._size = this.size + 1;
166
165
  this._setCount(this.count + newNode.count);
167
166
  }
168
167
 
@@ -170,7 +169,7 @@ export class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = TreeMultis
170
169
  } else if (parent.right === undefined) {
171
170
  parent.right = newNode;
172
171
  if (newNode !== null) {
173
- this._setSize(this.size + 1);
172
+ this._size = (this.size + 1);
174
173
  this._setCount(this.count + newNode.count);
175
174
  }
176
175
  return parent.right;
@@ -321,7 +320,7 @@ export class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = TreeMultis
321
320
  }
322
321
  }
323
322
  }
324
- this._setSize(this.size - 1);
323
+ this._size = this.size - 1;
325
324
  // TODO How to handle when the count of target node is lesser than current node's count
326
325
  this._setCount(this.count - orgCurrent.count);
327
326
  }
@@ -12,6 +12,9 @@ import {IGraph} from '../../interfaces';
12
12
  import {Queue} from '../queue';
13
13
 
14
14
  export abstract class AbstractVertex<V = any> {
15
+ key: VertexKey;
16
+ value: V | undefined;
17
+
15
18
  /**
16
19
  * The function is a protected constructor that takes an key and an optional value as parameters.
17
20
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
@@ -20,32 +23,16 @@ export abstract class AbstractVertex<V = any> {
20
23
  * vertex. If no value is provided, it will be set to undefined.
21
24
  */
22
25
  protected constructor(key: VertexKey, value?: V) {
23
- this._key = key;
24
- this._value = value;
25
- }
26
-
27
- private _key: VertexKey;
28
-
29
- get key(): VertexKey {
30
- return this._key;
31
- }
32
-
33
- set key(v: VertexKey) {
34
- this._key = v;
35
- }
36
-
37
- private _value: V | undefined;
38
-
39
- get value(): V | undefined {
40
- return this._value;
26
+ this.key = key;
27
+ this.value = value;
41
28
  }
42
29
 
43
- set value(value: V | undefined) {
44
- this._value = value;
45
- }
46
30
  }
47
31
 
48
32
  export abstract class AbstractEdge<E = any> {
33
+ value: E | undefined;
34
+ weight: number;
35
+
49
36
  /**
50
37
  * The above function is a protected constructor that initializes the weight, value, and hash code properties of an
51
38
  * object.
@@ -56,31 +43,11 @@ export abstract class AbstractEdge<E = any> {
56
43
  * meaning it can be omitted when creating an instance of the class.
57
44
  */
58
45
  protected constructor(weight?: number, value?: E) {
59
- this._weight = weight !== undefined ? weight : 1;
60
- this._value = value;
46
+ this.weight = weight !== undefined ? weight : 1;
47
+ this.value = value;
61
48
  this._hashCode = uuidV4();
62
49
  }
63
50
 
64
- private _value: E | undefined;
65
-
66
- get value(): E | undefined {
67
- return this._value;
68
- }
69
-
70
- set value(value: E | undefined) {
71
- this._value = value;
72
- }
73
-
74
- private _weight: number;
75
-
76
- get weight(): number {
77
- return this._weight;
78
- }
79
-
80
- set weight(v: number) {
81
- this._weight = v;
82
- }
83
-
84
51
  protected _hashCode: string;
85
52
 
86
53
  get hashCode(): string {
@@ -91,15 +58,6 @@ export abstract class AbstractEdge<E = any> {
91
58
  * 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.
92
59
  * 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.
93
60
  */
94
-
95
- /**
96
- * The function sets the value of the _hashCode property to the provided string.
97
- * @param {string} v - The parameter "v" is of type string and represents the value that will be assigned to the
98
- * "_hashCode" property.
99
- */
100
- protected _setHashCode(v: string) {
101
- this._hashCode = v;
102
- }
103
61
  }
104
62
 
105
63
  export abstract class AbstractGraph<
@@ -107,9 +65,8 @@ export abstract class AbstractGraph<
107
65
  E = any,
108
66
  VO extends AbstractVertex<V> = AbstractVertex<V>,
109
67
  EO extends AbstractEdge<E> = AbstractEdge<E>
110
- > implements IGraph<V, E, VO, EO>
111
- {
112
- private _vertices: Map<VertexKey, VO> = new Map<VertexKey, VO>();
68
+ > implements IGraph<V, E, VO, EO> {
69
+ protected _vertices: Map<VertexKey, VO> = new Map<VertexKey, VO>();
113
70
 
114
71
  get vertices(): Map<VertexKey, VO> {
115
72
  return this._vertices;
@@ -556,14 +513,14 @@ export abstract class AbstractGraph<
556
513
  }
557
514
 
558
515
  getMinDist &&
559
- distMap.forEach((d, v) => {
560
- if (v !== srcVertex) {
561
- if (d < minDist) {
562
- minDist = d;
563
- if (genPaths) minDest = v;
564
- }
516
+ distMap.forEach((d, v) => {
517
+ if (v !== srcVertex) {
518
+ if (d < minDist) {
519
+ minDist = d;
520
+ if (genPaths) minDest = v;
565
521
  }
566
- });
522
+ }
523
+ });
567
524
 
568
525
  genPaths && getPaths(minDest);
569
526
 
@@ -625,7 +582,7 @@ export abstract class AbstractGraph<
625
582
  if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity);
626
583
  }
627
584
 
628
- const heap = new PriorityQueue<{key: number; value: VO}>({comparator: (a, b) => a.key - b.key});
585
+ const heap = new PriorityQueue<{ key: number; value: VO }>({comparator: (a, b) => a.key - b.key});
629
586
  heap.add({key: 0, value: srcVertex});
630
587
 
631
588
  distMap.set(srcVertex, 0);
@@ -854,7 +811,7 @@ export abstract class AbstractGraph<
854
811
  * `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest
855
812
  * path between vertices in the
856
813
  */
857
- floyd(): {costs: number[][]; predecessor: (VO | null)[][]} {
814
+ floyd(): { costs: number[][]; predecessor: (VO | null)[][] } {
858
815
  const idAndVertices = [...this._vertices];
859
816
  const n = idAndVertices.length;
860
817
 
@@ -1040,7 +997,4 @@ export abstract class AbstractGraph<
1040
997
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
1041
998
  }
1042
999
 
1043
- protected _setVertices(value: Map<VertexKey, VO>) {
1044
- this._vertices = value;
1045
- }
1046
1000
  }
@@ -24,6 +24,9 @@ export class DirectedVertex<V = any> extends AbstractVertex<V> {
24
24
  }
25
25
 
26
26
  export class DirectedEdge<E = any> extends AbstractEdge<E> {
27
+ src: VertexKey;
28
+ dest: VertexKey;
29
+
27
30
  /**
28
31
  * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
29
32
  * and value.
@@ -37,40 +40,19 @@ export class DirectedEdge<E = any> extends AbstractEdge<E> {
37
40
  */
38
41
  constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E) {
39
42
  super(weight, value);
40
- this._src = src;
41
- this._dest = dest;
42
- }
43
-
44
- private _src: VertexKey;
45
-
46
- get src(): VertexKey {
47
- return this._src;
48
- }
49
-
50
- set src(v: VertexKey) {
51
- this._src = v;
52
- }
53
-
54
- private _dest: VertexKey;
55
-
56
- get dest(): VertexKey {
57
- return this._dest;
58
- }
59
-
60
- set dest(v: VertexKey) {
61
- this._dest = v;
43
+ this.src = src;
44
+ this.dest = dest;
62
45
  }
63
46
  }
64
47
 
65
48
  export class DirectedGraph<
66
- V = any,
67
- E = any,
68
- VO extends DirectedVertex<V> = DirectedVertex<V>,
69
- EO extends DirectedEdge<E> = DirectedEdge<E>
70
- >
49
+ V = any,
50
+ E = any,
51
+ VO extends DirectedVertex<V> = DirectedVertex<V>,
52
+ EO extends DirectedEdge<E> = DirectedEdge<E>
53
+ >
71
54
  extends AbstractGraph<V, E, VO, EO>
72
- implements IGraph<V, E, VO, EO>
73
- {
55
+ implements IGraph<V, E, VO, EO> {
74
56
  /**
75
57
  * The constructor function initializes an instance of a class.
76
58
  */
@@ -78,13 +60,13 @@ export class DirectedGraph<
78
60
  super();
79
61
  }
80
62
 
81
- private _outEdgeMap: Map<VO, EO[]> = new Map<VO, EO[]>();
63
+ protected _outEdgeMap: Map<VO, EO[]> = new Map<VO, EO[]>();
82
64
 
83
65
  get outEdgeMap(): Map<VO, EO[]> {
84
66
  return this._outEdgeMap;
85
67
  }
86
68
 
87
- private _inEdgeMap: Map<VO, EO[]> = new Map<VO, EO[]>();
69
+ protected _inEdgeMap: Map<VO, EO[]> = new Map<VO, EO[]>();
88
70
 
89
71
  get inEdgeMap(): Map<VO, EO[]> {
90
72
  return this._inEdgeMap;
@@ -464,12 +446,4 @@ export class DirectedGraph<
464
446
  return false;
465
447
  }
466
448
  }
467
-
468
- protected _setOutEdgeMap(value: Map<VO, EO[]>) {
469
- this._outEdgeMap = value;
470
- }
471
-
472
- protected _setInEdgeMap(value: Map<VO, EO[]>) {
473
- this._inEdgeMap = value;
474
- }
475
449
  }
@@ -2,6 +2,9 @@ import {MapGraphCoordinate, VertexKey} from '../../types';
2
2
  import {DirectedEdge, DirectedGraph, DirectedVertex} from './directed-graph';
3
3
 
4
4
  export class MapVertex<V = any> extends DirectedVertex<V> {
5
+ lat: number;
6
+ long: number;
7
+
5
8
  /**
6
9
  * The constructor function initializes an object with an key, latitude, longitude, and an optional value.
7
10
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex.
@@ -16,28 +19,8 @@ export class MapVertex<V = any> extends DirectedVertex<V> {
16
19
  */
17
20
  constructor(key: VertexKey, value: V, lat: number, long: number) {
18
21
  super(key, value);
19
- this._lat = lat;
20
- this._long = long;
21
- }
22
-
23
- private _lat: number;
24
-
25
- get lat(): number {
26
- return this._lat;
27
- }
28
-
29
- set lat(value: number) {
30
- this._lat = value;
31
- }
32
-
33
- private _long: number;
34
-
35
- get long(): number {
36
- return this._long;
37
- }
38
-
39
- set long(value: number) {
40
- this._long = value;
22
+ this.lat = lat;
23
+ this.long = long;
41
24
  }
42
25
  }
43
26
 
@@ -78,26 +61,18 @@ export class MapGraph<
78
61
  this._bottomRight = bottomRight;
79
62
  }
80
63
 
81
- private _origin: MapGraphCoordinate = [0, 0];
64
+ protected _origin: MapGraphCoordinate = [0, 0];
82
65
 
83
66
  get origin(): MapGraphCoordinate {
84
67
  return this._origin;
85
68
  }
86
69
 
87
- set origin(value: MapGraphCoordinate) {
88
- this._origin = value;
89
- }
90
-
91
- private _bottomRight: MapGraphCoordinate | undefined;
70
+ protected _bottomRight: MapGraphCoordinate | undefined;
92
71
 
93
72
  get bottomRight(): MapGraphCoordinate | undefined {
94
73
  return this._bottomRight;
95
74
  }
96
75
 
97
- set bottomRight(value: MapGraphCoordinate | undefined) {
98
- this._bottomRight = value;
99
- }
100
-
101
76
  /**
102
77
  * The function creates a new vertex with the given key, value, latitude, and longitude.
103
78
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
@@ -24,6 +24,8 @@ export class UndirectedVertex<V = any> extends AbstractVertex<V> {
24
24
  }
25
25
 
26
26
  export class UndirectedEdge<E = number> extends AbstractEdge<E> {
27
+ vertices: [VertexKey, VertexKey];
28
+
27
29
  /**
28
30
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
29
31
  * value.
@@ -36,29 +38,18 @@ export class UndirectedEdge<E = number> extends AbstractEdge<E> {
36
38
  */
37
39
  constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E) {
38
40
  super(weight, value);
39
- this._vertices = [v1, v2];
40
- }
41
-
42
- private _vertices: [VertexKey, VertexKey];
43
-
44
- get vertices() {
45
- return this._vertices;
46
- }
47
-
48
- set vertices(v: [VertexKey, VertexKey]) {
49
- this._vertices = v;
41
+ this.vertices = [v1, v2];
50
42
  }
51
43
  }
52
44
 
53
45
  export class UndirectedGraph<
54
- V = any,
55
- E = any,
56
- VO extends UndirectedVertex<V> = UndirectedVertex<V>,
57
- EO extends UndirectedEdge<E> = UndirectedEdge<E>
58
- >
46
+ V = any,
47
+ E = any,
48
+ VO extends UndirectedVertex<V> = UndirectedVertex<V>,
49
+ EO extends UndirectedEdge<E> = UndirectedEdge<E>
50
+ >
59
51
  extends AbstractGraph<V, E, VO, EO>
60
- implements IGraph<V, E, VO, EO>
61
- {
52
+ implements IGraph<V, E, VO, EO> {
62
53
  /**
63
54
  * The constructor initializes a new Map object to store edges.
64
55
  */
@@ -265,12 +256,4 @@ export class UndirectedGraph<
265
256
  }
266
257
  return true;
267
258
  }
268
-
269
- /**
270
- * The function sets the edges of a graph.
271
- * @param v - A map where the keys are of type VO and the values are arrays of type EO.
272
- */
273
- protected _setEdges(v: Map<VO, EO[]>) {
274
- this._edges = v;
275
- }
276
259
  }
@@ -60,8 +60,4 @@ export class CoordinateMap<V> extends Map<any, V> {
60
60
  override delete(key: number[]) {
61
61
  return super.delete(key.join(this._joint));
62
62
  }
63
-
64
- protected _setJoint(v: string) {
65
- this._joint = v;
66
- }
67
63
  }
@@ -49,8 +49,4 @@ export class CoordinateSet extends Set<any> {
49
49
  override delete(value: number[]) {
50
50
  return super.delete(value.join(this._joint));
51
51
  }
52
-
53
- protected _setJoint(v: string) {
54
- this._joint = v;
55
- }
56
52
  }