priority-queue-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.
@@ -42,6 +42,41 @@ class SkipList {
42
42
  get probability() {
43
43
  return this._probability;
44
44
  }
45
+ /**
46
+ * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
47
+ * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
48
+ */
49
+ /**
50
+ * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
51
+ * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
52
+ *
53
+ * Get the value of the first element (the smallest element) in the Skip List.
54
+ * @returns The value of the first element, or undefined if the Skip List is empty.
55
+ */
56
+ get first() {
57
+ const firstNode = this.head.forward[0];
58
+ return firstNode ? firstNode.value : undefined;
59
+ }
60
+ /**
61
+ * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
62
+ * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
63
+ */
64
+ /**
65
+ * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
66
+ * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
67
+ *
68
+ * Get the value of the last element (the largest element) in the Skip List.
69
+ * @returns The value of the last element, or undefined if the Skip List is empty.
70
+ */
71
+ get last() {
72
+ let current = this.head;
73
+ for (let i = this.level - 1; i >= 0; i--) {
74
+ while (current.forward[i]) {
75
+ current = current.forward[i];
76
+ }
77
+ }
78
+ return current.value;
79
+ }
45
80
  /**
46
81
  * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
47
82
  * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
@@ -100,7 +135,7 @@ class SkipList {
100
135
  return undefined;
101
136
  }
102
137
  /**
103
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
138
+ * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
104
139
  * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
105
140
  */
106
141
  /**
@@ -147,41 +182,6 @@ class SkipList {
147
182
  }
148
183
  return false;
149
184
  }
150
- /**
151
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
152
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
153
- */
154
- /**
155
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
156
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
157
- *
158
- * Get the value of the first element (the smallest element) in the Skip List.
159
- * @returns The value of the first element, or undefined if the Skip List is empty.
160
- */
161
- get first() {
162
- const firstNode = this.head.forward[0];
163
- return firstNode ? firstNode.value : undefined;
164
- }
165
- /**
166
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
167
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
168
- */
169
- /**
170
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
171
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
172
- *
173
- * Get the value of the last element (the largest element) in the Skip List.
174
- * @returns The value of the last element, or undefined if the Skip List is empty.
175
- */
176
- get last() {
177
- let current = this.head;
178
- for (let i = this.level - 1; i >= 0; i--) {
179
- while (current.forward[i]) {
180
- current = current.forward[i];
181
- }
182
- }
183
- return current.value;
184
- }
185
185
  /**
186
186
  * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
187
187
  * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
@@ -32,6 +32,32 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
32
32
  * @returns {number} The size of the array, which is the difference between the length of the array and the offset.
33
33
  */
34
34
  get size(): number;
35
+ /**
36
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
37
+ * Space Complexity: O(1) - no additional space is used.
38
+ *
39
+ * The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
40
+ * @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
41
+ * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
42
+ */
43
+ get first(): E | undefined;
44
+ /**
45
+ * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
46
+ * Space Complexity: O(1) - no additional space is used.
47
+ */
48
+ /**
49
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
50
+ * Space Complexity: O(1) - no additional space is used.
51
+ *
52
+ * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
53
+ * @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
54
+ * array is empty, it returns `undefined`.
55
+ */
56
+ get last(): E | undefined;
57
+ /**
58
+ * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
59
+ * Space Complexity: O(1) - no additional space is used.
60
+ */
35
61
  /**
36
62
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
37
63
  * @public
@@ -42,7 +68,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
42
68
  */
43
69
  static fromArray<E>(elements: E[]): Queue<E>;
44
70
  /**
45
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
71
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
46
72
  * Space Complexity: O(1) - no additional space is used.
47
73
  */
48
74
  /**
@@ -55,7 +81,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
55
81
  */
56
82
  push(element: E): boolean;
57
83
  /**
58
- * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
84
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
59
85
  * Space Complexity: O(1) - no additional space is used.
60
86
  */
61
87
  /**
@@ -67,19 +93,6 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
67
93
  * @returns The function `shift()` returns either the first element in the queue or `undefined` if the queue is empty.
68
94
  */
69
95
  shift(): E | undefined;
70
- /**
71
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
72
- * Space Complexity: O(1) - no additional space is used.
73
- */
74
- /**
75
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
76
- * Space Complexity: O(1) - no additional space is used.
77
- *
78
- * The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
79
- * @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
80
- * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
81
- */
82
- get first(): E | undefined;
83
96
  /**
84
97
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
85
98
  * Space Complexity: O(1) - no additional space is used.
@@ -93,19 +106,6 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
93
106
  * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
94
107
  */
95
108
  peek(): E | undefined;
96
- /**
97
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
98
- * Space Complexity: O(1) - no additional space is used.
99
- */
100
- /**
101
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
102
- * Space Complexity: O(1) - no additional space is used.
103
- *
104
- * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
105
- * @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
106
- * array is empty, it returns `undefined`.
107
- */
108
- get last(): E | undefined;
109
109
  /**
110
110
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
111
111
  * Space Complexity: O(1) - no additional space is used.
@@ -247,6 +247,11 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
247
247
  * 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
248
248
  */
249
249
  export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
250
+ /**
251
+ * The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
252
+ * @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
253
+ */
254
+ get first(): E | undefined;
250
255
  /**
251
256
  * The enqueue function adds a value to the end of an array.
252
257
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
@@ -257,11 +262,6 @@ export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
257
262
  * @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
258
263
  */
259
264
  dequeue(): E | undefined;
260
- /**
261
- * The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
262
- * @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
263
- */
264
- get first(): E | undefined;
265
265
  /**
266
266
  * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
267
267
  * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
@@ -37,6 +37,36 @@ class Queue extends base_1.IterableElementBase {
37
37
  get size() {
38
38
  return this.nodes.length - this.offset;
39
39
  }
40
+ /**
41
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
42
+ * Space Complexity: O(1) - no additional space is used.
43
+ *
44
+ * The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
45
+ * @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
46
+ * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
47
+ */
48
+ get first() {
49
+ return this.size > 0 ? this.nodes[this.offset] : undefined;
50
+ }
51
+ /**
52
+ * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
53
+ * Space Complexity: O(1) - no additional space is used.
54
+ */
55
+ /**
56
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
57
+ * Space Complexity: O(1) - no additional space is used.
58
+ *
59
+ * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
60
+ * @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
61
+ * array is empty, it returns `undefined`.
62
+ */
63
+ get last() {
64
+ return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
65
+ }
66
+ /**
67
+ * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
68
+ * Space Complexity: O(1) - no additional space is used.
69
+ */
40
70
  /**
41
71
  * The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
42
72
  * @public
@@ -49,7 +79,7 @@ class Queue extends base_1.IterableElementBase {
49
79
  return new Queue(elements);
50
80
  }
51
81
  /**
52
- * Time Complexity: O(1) - constant time as it adds an element to the end of the array.
82
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
53
83
  * Space Complexity: O(1) - no additional space is used.
54
84
  */
55
85
  /**
@@ -65,7 +95,7 @@ class Queue extends base_1.IterableElementBase {
65
95
  return true;
66
96
  }
67
97
  /**
68
- * Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
98
+ * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
69
99
  * Space Complexity: O(1) - no additional space is used.
70
100
  */
71
101
  /**
@@ -89,21 +119,6 @@ class Queue extends base_1.IterableElementBase {
89
119
  this._offset = 0;
90
120
  return first;
91
121
  }
92
- /**
93
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
94
- * Space Complexity: O(1) - no additional space is used.
95
- */
96
- /**
97
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
98
- * Space Complexity: O(1) - no additional space is used.
99
- *
100
- * The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
101
- * @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
102
- * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
103
- */
104
- get first() {
105
- return this.size > 0 ? this.nodes[this.offset] : undefined;
106
- }
107
122
  /**
108
123
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
109
124
  * Space Complexity: O(1) - no additional space is used.
@@ -119,21 +134,6 @@ class Queue extends base_1.IterableElementBase {
119
134
  peek() {
120
135
  return this.first;
121
136
  }
122
- /**
123
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
124
- * Space Complexity: O(1) - no additional space is used.
125
- */
126
- /**
127
- * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
128
- * Space Complexity: O(1) - no additional space is used.
129
- *
130
- * The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
131
- * @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
132
- * array is empty, it returns `undefined`.
133
- */
134
- get last() {
135
- return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
136
- }
137
137
  /**
138
138
  * Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
139
139
  * Space Complexity: O(1) - no additional space is used.
@@ -315,6 +315,14 @@ exports.Queue = Queue;
315
315
  * 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
316
316
  */
317
317
  class LinkedListQueue extends linked_list_1.SinglyLinkedList {
318
+ /**
319
+ * The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
320
+ * @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
321
+ */
322
+ get first() {
323
+ var _a;
324
+ return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
325
+ }
318
326
  /**
319
327
  * The enqueue function adds a value to the end of an array.
320
328
  * @param {E} value - The value parameter represents the value that you want to add to the queue.
@@ -329,14 +337,6 @@ class LinkedListQueue extends linked_list_1.SinglyLinkedList {
329
337
  dequeue() {
330
338
  return this.shift();
331
339
  }
332
- /**
333
- * The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
334
- * @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
335
- */
336
- get first() {
337
- var _a;
338
- return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
339
- }
340
340
  /**
341
341
  * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
342
342
  * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "priority-queue-typed",
3
- "version": "1.49.2",
3
+ "version": "1.49.3",
4
4
  "description": "Priority Queue, Min Priority Queue, Max Priority Queue. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -120,6 +120,6 @@
120
120
  "typedoc": "^0.25.1"
121
121
  },
122
122
  "dependencies": {
123
- "data-structure-typed": "^1.49.1"
123
+ "data-structure-typed": "^1.49.3"
124
124
  }
125
125
  }
@@ -156,10 +156,10 @@ export abstract class AbstractGraph<
156
156
 
157
157
  addVertex(keyOrVertex: VertexKey | VO, value?: V): boolean {
158
158
  if (keyOrVertex instanceof AbstractVertex) {
159
- return this._addVertexOnly(keyOrVertex);
159
+ return this._addVertex(keyOrVertex);
160
160
  } else {
161
161
  const newVertex = this.createVertex(keyOrVertex, value);
162
- return this._addVertexOnly(newVertex);
162
+ return this._addVertex(newVertex);
163
163
  }
164
164
  }
165
165
 
@@ -242,14 +242,14 @@ export abstract class AbstractGraph<
242
242
 
243
243
  addEdge(srcOrEdge: VO | VertexKey | EO, dest?: VO | VertexKey, weight?: number, value?: E): boolean {
244
244
  if (srcOrEdge instanceof AbstractEdge) {
245
- return this._addEdgeOnly(srcOrEdge);
245
+ return this._addEdge(srcOrEdge);
246
246
  } else {
247
247
  if (dest instanceof AbstractVertex || typeof dest === 'string' || typeof dest === 'number') {
248
248
  if (!(this.hasVertex(srcOrEdge) && this.hasVertex(dest))) return false;
249
249
  if (srcOrEdge instanceof AbstractVertex) srcOrEdge = srcOrEdge.key;
250
250
  if (dest instanceof AbstractVertex) dest = dest.key;
251
251
  const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
252
- return this._addEdgeOnly(newEdge);
252
+ return this._addEdge(newEdge);
253
253
  } else {
254
254
  throw new Error('dest must be a Vertex or vertex key while srcOrEdge is an Edge');
255
255
  }
@@ -1147,14 +1147,6 @@ export abstract class AbstractGraph<
1147
1147
  return this.tarjan(false, false, false, false).lowMap;
1148
1148
  }
1149
1149
 
1150
- /**
1151
- * The function `getCycles` returns a map of cycles found using the Tarjan algorithm.
1152
- * @returns The function `getCycles()` is returning a `Map<number, VO[]>`.
1153
- */
1154
- getCycles(): Map<number, VO[]> {
1155
- return this.tarjan(false, false, false, true).cycles;
1156
- }
1157
-
1158
1150
  /**
1159
1151
  * The function "getCutVertexes" returns an array of cut vertexes using the Tarjan algorithm.
1160
1152
  * @returns an array of VO objects, specifically the cut vertexes.
@@ -1180,6 +1172,55 @@ export abstract class AbstractGraph<
1180
1172
  return this.tarjan(false, true, false, false).bridges;
1181
1173
  }
1182
1174
 
1175
+ /**
1176
+ * O(V+E+C)
1177
+ * O(V+C)
1178
+ */
1179
+ getCycles(isInclude2Cycle: boolean = false): VertexKey[][] {
1180
+ const cycles: VertexKey[][] = [];
1181
+ const visited: Set<VO> = new Set();
1182
+
1183
+ const dfs = (vertex: VO, currentPath: VertexKey[], visited: Set<VO>) => {
1184
+ if (visited.has(vertex)) {
1185
+ if ((!isInclude2Cycle && currentPath.length > 2 || isInclude2Cycle && currentPath.length >= 2) && currentPath[0] === vertex.key) {
1186
+ cycles.push([...currentPath]);
1187
+ }
1188
+ return;
1189
+ }
1190
+
1191
+ visited.add(vertex);
1192
+ currentPath.push(vertex.key);
1193
+
1194
+ for (const neighbor of this.getNeighbors(vertex)) {
1195
+ neighbor && dfs(neighbor, currentPath, visited);
1196
+ }
1197
+
1198
+ visited.delete(vertex);
1199
+ currentPath.pop();
1200
+ };
1201
+
1202
+ for (const vertex of this.vertexMap.values()) {
1203
+ dfs(vertex, [], visited);
1204
+ }
1205
+
1206
+ // Use a set to eliminate duplicate cycles
1207
+ const uniqueCycles = new Map<string, VertexKey[]>();
1208
+
1209
+ for (const cycle of cycles) {
1210
+ const sorted = [...cycle].sort().toString()
1211
+
1212
+ if (uniqueCycles.has(sorted)) continue
1213
+ else {
1214
+ uniqueCycles.set(sorted, cycle)
1215
+ }
1216
+ }
1217
+
1218
+ // Convert the unique cycles back to an array
1219
+ return [...uniqueCycles].map(cycleString =>
1220
+ cycleString[1]
1221
+ );
1222
+ }
1223
+
1183
1224
  /**
1184
1225
  * Time Complexity: O(n)
1185
1226
  * Space Complexity: O(n)
@@ -1247,9 +1288,9 @@ export abstract class AbstractGraph<
1247
1288
  }
1248
1289
  }
1249
1290
 
1250
- protected abstract _addEdgeOnly(edge: EO): boolean;
1291
+ protected abstract _addEdge(edge: EO): boolean;
1251
1292
 
1252
- protected _addVertexOnly(newVertex: VO): boolean {
1293
+ protected _addVertex(newVertex: VO): boolean {
1253
1294
  if (this.hasVertex(newVertex)) {
1254
1295
  return false;
1255
1296
  // throw (new Error('Duplicated vertex key is not allowed'));
@@ -596,6 +596,7 @@ export class DirectedGraph<
596
596
  }
597
597
  }
598
598
 
599
+
599
600
  /**
600
601
  * Time Complexity: O(1)
601
602
  * Space Complexity: O(1)
@@ -605,13 +606,13 @@ export class DirectedGraph<
605
606
  * Time Complexity: O(1)
606
607
  * Space Complexity: O(1)
607
608
  *
608
- * The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
609
+ * The function `_addEdge` adds an edge to a graph if the source and destination vertexMap exist.
609
610
  * @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that
610
611
  * needs to be added to the graph.
611
612
  * @returns a boolean value. It returns true if the edge was successfully added to the graph, and false if either the
612
613
  * source or destination vertex does not exist in the graph.
613
614
  */
614
- protected _addEdgeOnly(edge: EO): boolean {
615
+ protected _addEdge(edge: EO): boolean {
615
616
  if (!(this.hasVertex(edge.src) && this.hasVertex(edge.dest))) {
616
617
  return false;
617
618
  }
@@ -381,7 +381,7 @@ export class UndirectedGraph<
381
381
  * @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
382
382
  * @returns a boolean value.
383
383
  */
384
- protected _addEdgeOnly(edge: EO): boolean {
384
+ protected _addEdge(edge: EO): boolean {
385
385
  for (const end of edge.vertexMap) {
386
386
  const endVertex = this._getVertex(end);
387
387
  if (endVertex === undefined) return false;