Socket
Socket
Sign inDemoInstall

min-heap-typed

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

min-heap-typed - npm Package Compare versions

Comparing version 1.48.4 to 1.48.5

12

dist/data-structures/base/iterable-base.d.ts

@@ -1,3 +0,3 @@

import { ElementCallback, PairCallback, ReduceElementCallback, ReducePairCallback } from "../../types";
export declare abstract class IterablePairBase<K = any, V = any> {
import { ElementCallback, EntryCallback, ReduceElementCallback, ReduceEntryCallback } from "../../types";
export declare abstract class IterableEntryBase<K = any, V = any> {
/**

@@ -69,3 +69,3 @@ * Time Complexity: O(n)

*/
every(predicate: PairCallback<K, V, boolean>, thisArg?: any): boolean;
every(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean;
/**

@@ -90,3 +90,3 @@ * Time Complexity: O(n)

*/
some(predicate: PairCallback<K, V, boolean>, thisArg?: any): boolean;
some(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean;
/**

@@ -109,3 +109,3 @@ * Time Complexity: O(n)

*/
forEach(callbackfn: PairCallback<K, V, void>, thisArg?: any): void;
forEach(callbackfn: EntryCallback<K, V, void>, thisArg?: any): void;
/**

@@ -131,3 +131,3 @@ * Time Complexity: O(n)

*/
reduce<U>(callbackfn: ReducePairCallback<K, V, U>, initialValue: U): U;
reduce<U>(callbackfn: ReduceEntryCallback<K, V, U>, initialValue: U): U;
protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;

@@ -134,0 +134,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IterableElementBase = exports.IterablePairBase = void 0;
class IterablePairBase {
exports.IterableElementBase = exports.IterableEntryBase = void 0;
class IterableEntryBase {
/**

@@ -176,3 +176,3 @@ * Time Complexity: O(n)

}
exports.IterablePairBase = IterablePairBase;
exports.IterableEntryBase = IterableEntryBase;
class IterableElementBase {

@@ -179,0 +179,0 @@ /**

@@ -71,7 +71,9 @@ /**

* a new node.
* @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be either a key, a node, or an
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry.
* @returns The method is returning either the inserted node or `undefined`.
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary tree.
* @returns The method is returning either the inserted node or undefined.
*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -78,0 +80,0 @@ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.

@@ -84,10 +84,12 @@ "use strict";

* a new node.
* @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be either a key, a node, or an
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry.
* @returns The method is returning either the inserted node or `undefined`.
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary tree.
* @returns The method is returning either the inserted node or undefined.
*/
add(keyOrNodeOrEntry) {
add(keyOrNodeOrEntry, value) {
if (keyOrNodeOrEntry === null)
return undefined;
const inserted = super.add(keyOrNodeOrEntry);
const inserted = super.add(keyOrNodeOrEntry, value);
if (inserted)

@@ -94,0 +96,0 @@ this._balancePath(inserted);

@@ -9,5 +9,5 @@ /**

import type { BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, BTNodeEntry, BTNodeExemplar, BTNodeKeyOrNode } from '../../types';
import { BinaryTreeNested, BinaryTreePrintOptions, BiTreeDeleteResult, DFSOrderPattern, FamilyPosition, IterationType, NodeDisplayLayout, PairCallback } from '../../types';
import { BinaryTreeNested, BinaryTreePrintOptions, BiTreeDeleteResult, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeDisplayLayout } from '../../types';
import { IBinaryTree } from '../../interfaces';
import { IterablePairBase } from "../base";
import { IterableEntryBase } from "../base";
/**

@@ -46,3 +46,3 @@ * Represents a node in a binary tree.

*/
export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTree<K, V, N, BinaryTreeNested<K, V, N>>> extends IterablePairBase<K, V | undefined> implements IBinaryTree<K, V, N, TREE> {
export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTree<K, V, N, BinaryTreeNested<K, V, N>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, N, TREE> {
iterationType: IterationType;

@@ -87,9 +87,10 @@ /**

/**
* The function `exemplarToNode` converts an exemplar of a binary tree node into an actual node
* object.
* @param exemplar - BTNodeExemplar<K, V,N> - A generic type representing the exemplar parameter of the
* function. It can be any type.
* @returns a value of type `N` (which represents a node), or `null`, or `undefined`.
* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
* `exemplarToNode` function. It represents the value associated with the exemplar node. If no value
* is provided, it will be `undefined`.
* @returns a value of type N (node), or null, or undefined.
*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>): N | null | undefined;
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | null | undefined;
/**

@@ -110,7 +111,9 @@ * The function checks if a given value is an entry in a binary tree node.

*
* The `add` function adds a new node to a binary tree, either by key or by providing a node object.
* @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be one of the following:
* @returns The function `add` returns the inserted node (`N`), `null`, or `undefined`.
* The `add` function adds a new node to a binary tree, either by creating a new node or replacing an
* existing node with the same key.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @param {V} [value] - The value to be inserted into the binary tree.
* @returns The function `add` returns either a node (`N`), `null`, or `undefined`.
*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | null | undefined;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | null | undefined;
/**

@@ -502,3 +505,3 @@ * Time Complexity: O(k log n) - O(k * n)

*/
filter(predicate: PairCallback<K, V | undefined, boolean>, thisArg?: any): TREE;
filter(predicate: EntryCallback<K, V | undefined, boolean>, thisArg?: any): TREE;
/**

@@ -523,3 +526,3 @@ * Time Complexity: O(n)

*/
map(callback: PairCallback<K, V | undefined, V>, thisArg?: any): TREE;
map(callback: EntryCallback<K, V | undefined, V>, thisArg?: any): TREE;
/**

@@ -526,0 +529,0 @@ * The `print` function is used to display a binary tree structure in a visually appealing way.

@@ -83,8 +83,10 @@ /**

/**
* The function `exemplarToNode` takes an exemplar and returns a corresponding node if the exemplar
* is valid, otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @returns a variable `node` which is of type `N` or `undefined`.
* The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
* otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
* `exemplarToNode` function. It represents the value associated with the exemplar node.
* @returns a node of type N or undefined.
*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>): N | undefined;
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -98,9 +100,11 @@ * Time Complexity: O(log n) - Average case for a balanced tree. In the worst case (unbalanced tree), it can be O(n).

*
* The `add` function adds a new node to a binary search tree, either by key or by providing a node
* object.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @returns The method returns either the newly added node (`newNode`) or `undefined` if the input
* (`keyOrNodeOrEntry`) is null, undefined, or does not match any of the expected types.
* The `add` function adds a new node to a binary tree, updating the value if the key already exists
* or inserting a new node if the key is unique.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary tree.
* @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the
* node was not added.
*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -107,0 +111,0 @@ * Time Complexity: O(k log n) - Adding each element individually in a balanced tree.

@@ -115,8 +115,10 @@ "use strict";

/**
* The function `exemplarToNode` takes an exemplar and returns a corresponding node if the exemplar
* is valid, otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @returns a variable `node` which is of type `N` or `undefined`.
* The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
* otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
* `exemplarToNode` function. It represents the value associated with the exemplar node.
* @returns a node of type N or undefined.
*/
exemplarToNode(exemplar) {
exemplarToNode(exemplar, value) {
let node;

@@ -139,3 +141,3 @@ if (exemplar === null || exemplar === undefined) {

else if (this.isNotNodeInstance(exemplar)) {
node = this.createNode(exemplar);
node = this.createNode(exemplar, value);
}

@@ -155,10 +157,12 @@ else {

*
* The `add` function adds a new node to a binary search tree, either by key or by providing a node
* object.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @returns The method returns either the newly added node (`newNode`) or `undefined` if the input
* (`keyOrNodeOrEntry`) is null, undefined, or does not match any of the expected types.
* The `add` function adds a new node to a binary tree, updating the value if the key already exists
* or inserting a new node if the key is unique.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary tree.
* @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the
* node was not added.
*/
add(keyOrNodeOrEntry) {
const newNode = this.exemplarToNode(keyOrNodeOrEntry);
add(keyOrNodeOrEntry, value) {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
if (newNode === undefined)

@@ -165,0 +169,0 @@ return;

@@ -69,10 +69,10 @@ /**

/**
* The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
* otherwise it returns undefined.
* @param exemplar - BTNodeExemplar<K, V, N> - A generic type representing an exemplar of a binary tree
* node. It can be either a node itself, an entry (key-value pair), a node key, or any other value
* that is not a valid exemplar.
* @returns a variable `node` which is of type `N | undefined`.
* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
* `exemplarToNode` function. It represents the value associated with the exemplar node. If a value
* is provided, it will be used when creating the new node. If no value is provided, the new node
* @returns a node of type N or undefined.
*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>): N | undefined;
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -83,8 +83,14 @@ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)

/**
* The function adds a node to a Red-Black Tree data structure.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @returns The method `add` returns either an instance of `N` (the node that was added) or
* `undefined`.
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*
* The `add` function adds a new node to a binary search tree and performs necessary rotations and
* color changes to maintain the red-black tree properties.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry.
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary search tree.
* @returns The method `add` returns either the newly added node (`N`) or `undefined`.
*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined;
/**

@@ -91,0 +97,0 @@ * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)

@@ -89,10 +89,10 @@ "use strict";

/**
* The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
* otherwise it returns undefined.
* @param exemplar - BTNodeExemplar<K, V, N> - A generic type representing an exemplar of a binary tree
* node. It can be either a node itself, an entry (key-value pair), a node key, or any other value
* that is not a valid exemplar.
* @returns a variable `node` which is of type `N | undefined`.
* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
* `exemplarToNode` function. It represents the value associated with the exemplar node. If a value
* is provided, it will be used when creating the new node. If no value is provided, the new node
* @returns a node of type N or undefined.
*/
exemplarToNode(exemplar) {
exemplarToNode(exemplar, value) {
let node;

@@ -115,3 +115,3 @@ if (exemplar === null || exemplar === undefined) {

else if (this.isNotNodeInstance(exemplar)) {
node = this.createNode(exemplar, undefined, types_1.RBTNColor.RED);
node = this.createNode(exemplar, value, types_1.RBTNColor.RED);
}

@@ -128,9 +128,15 @@ else {

/**
* The function adds a node to a Red-Black Tree data structure.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @returns The method `add` returns either an instance of `N` (the node that was added) or
* `undefined`.
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*
* The `add` function adds a new node to a binary search tree and performs necessary rotations and
* color changes to maintain the red-black tree properties.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry.
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary search tree.
* @returns The method `add` returns either the newly added node (`N`) or `undefined`.
*/
add(keyOrNodeOrEntry) {
const newNode = this.exemplarToNode(keyOrNodeOrEntry);
add(keyOrNodeOrEntry, value) {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
if (newNode === undefined)

@@ -137,0 +143,0 @@ return;

@@ -53,9 +53,12 @@ /**

* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
* the value type and `N` represents the node type.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
* can be one of the following:
* @param {V} [value] - The `value` parameter is an optional argument that represents the value
* associated with the node. It is of type `V`, which can be any data type. If no value is provided,
* it defaults to `undefined`.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the node should be created. If not provided, it defaults to 1.
* @returns a value of type `N` (the generic type parameter) or `undefined`.
* times the value should be added to the node. If not provided, it defaults to 1.
* @returns a node of type `N` or `undefined`.
*/
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, count?: number): N | undefined;
exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | undefined;
/**

@@ -69,11 +72,15 @@ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.

*
* The `add` function overrides the base class `add` function to add a new node to the tree multimap
* and update the count.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key or node or entry should be added to the multimap. If not provided, the default value
* is 1.
* @returns either a node (`N`) or `undefined`.
* The function overrides the add method of a binary tree node and adds a new node to the tree.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry. It represents the key, node, or entry that you want to add to the binary tree.
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
* binary tree node. It is an optional parameter, meaning it can be omitted when calling the `add`
* method.
* @param [count=1] - The `count` parameter represents the number of times the key-value pair should
* be added to the binary tree. By default, it is set to 1, meaning that the key-value pair will be
* added once. However, you can specify a different value for `count` if you want to add
* @returns The method is returning either the newly inserted node or `undefined` if the insertion
* was not successful.
*/
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count?: number): N | undefined;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | undefined;
/**

@@ -80,0 +87,0 @@ * Time Complexity: O(k log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.

@@ -65,9 +65,12 @@ "use strict";

* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
* the value type and `N` represents the node type.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
* can be one of the following:
* @param {V} [value] - The `value` parameter is an optional argument that represents the value
* associated with the node. It is of type `V`, which can be any data type. If no value is provided,
* it defaults to `undefined`.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the node should be created. If not provided, it defaults to 1.
* @returns a value of type `N` (the generic type parameter) or `undefined`.
* times the value should be added to the node. If not provided, it defaults to 1.
* @returns a node of type `N` or `undefined`.
*/
exemplarToNode(exemplar, count = 1) {
exemplarToNode(exemplar, value, count = 1) {
let node;

@@ -90,3 +93,3 @@ if (exemplar === undefined || exemplar === null) {

else if (this.isNotNodeInstance(exemplar)) {
node = this.createNode(exemplar, undefined, count);
node = this.createNode(exemplar, value, count);
}

@@ -106,12 +109,16 @@ else {

*
* The `add` function overrides the base class `add` function to add a new node to the tree multimap
* and update the count.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key or node or entry should be added to the multimap. If not provided, the default value
* is 1.
* @returns either a node (`N`) or `undefined`.
* The function overrides the add method of a binary tree node and adds a new node to the tree.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry. It represents the key, node, or entry that you want to add to the binary tree.
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
* binary tree node. It is an optional parameter, meaning it can be omitted when calling the `add`
* method.
* @param [count=1] - The `count` parameter represents the number of times the key-value pair should
* be added to the binary tree. By default, it is set to 1, meaning that the key-value pair will be
* added once. However, you can specify a different value for `count` if you want to add
* @returns The method is returning either the newly inserted node or `undefined` if the insertion
* was not successful.
*/
add(keyOrNodeOrEntry, count = 1) {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, count);
add(keyOrNodeOrEntry, value, count = 1) {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);
if (newNode === undefined)

@@ -169,3 +176,3 @@ return;

const midNode = sorted[m];
this.add([midNode.key, midNode.value], midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
buildBalanceBST(l, m - 1);

@@ -186,3 +193,3 @@ buildBalanceBST(m + 1, r);

const midNode = sorted[m];
this.add([midNode.key, midNode.value], midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
stack.push([m + 1, r]);

@@ -301,3 +308,3 @@ stack.push([l, m - 1]);

const cloned = this.createTree();
this.bfs(node => cloned.add([node.key, node.value], node.count));
this.bfs(node => cloned.add(node.key, node.value, node.count));
return cloned;

@@ -304,0 +311,0 @@ }

import type { DijkstraResult, VertexKey } from '../../types';
import { PairCallback } from "../../types";
import { EntryCallback } from "../../types";
import { IGraph } from '../../interfaces';
import { IterablePairBase } from "../base";
import { IterableEntryBase } from "../base";
export declare abstract class AbstractVertex<V = any> {

@@ -33,6 +33,6 @@ key: VertexKey;

}
export declare abstract class AbstractGraph<V = any, E = any, VO extends AbstractVertex<V> = AbstractVertex<V>, EO extends AbstractEdge<E> = AbstractEdge<E>> extends IterablePairBase<VertexKey, V | undefined> implements IGraph<V, E, VO, EO> {
export declare abstract class AbstractGraph<V = any, E = any, VO extends AbstractVertex<V> = AbstractVertex<V>, EO extends AbstractEdge<E> = AbstractEdge<E>> extends IterableEntryBase<VertexKey, V | undefined> implements IGraph<V, E, VO, EO> {
constructor();
protected _vertices: Map<VertexKey, VO>;
get vertices(): Map<VertexKey, VO>;
protected _vertexMap: Map<VertexKey, VO>;
get vertexMap(): Map<VertexKey, VO>;
/**

@@ -71,4 +71,4 @@ * 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.

* @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
* the `_vertices` map.
* @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
* the `_vertexMap` map.
* @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertexMap`
* map. If the vertex does not exist, it returns `undefined`.

@@ -109,16 +109,16 @@ */

/**
* Time Complexity: O(K), where K is the number of vertices to be removed.
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
*/
/**
* Time Complexity: O(K), where K is the number of vertices to be removed.
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
*
* The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
* @param {VO[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`VO[]`) or an array
* The function removes all vertexMap from a graph and returns a boolean indicating if any vertexMap were removed.
* @param {VO[] | VertexKey[]} vertexMap - The `vertexMap` parameter can be either an array of vertexMap (`VO[]`) or an array
* of vertex IDs (`VertexKey[]`).
* @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
* @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertexMap
* were removed.
*/
removeManyVertices(vertices: VO[] | VertexKey[]): boolean;
removeManyVertices(vertexMap: VO[] | VertexKey[]): boolean;
/**

@@ -132,3 +132,3 @@ * Time Complexity: O(1) - Depends on the implementation in the concrete class.

*
* The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
* The function checks if there is an edge between two vertexMap and returns a boolean value indicating the result.
* @param {VertexKey | VO} v1 - The parameter v1 can be either a VertexKey or a VO. A VertexKey represents the unique

@@ -151,3 +151,3 @@ * identifier of a vertex in a graph, while VO represents the type of the vertex object itself.

*
* The function sets the weight of an edge between two vertices in a graph.
* The function sets the weight of an edge between two vertexMap in a graph.
* @param {VertexKey | VO} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `VO` object. It represents

@@ -159,3 +159,3 @@ * the source vertex of the edge.

* and the destination vertex (destOrKey).
* @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
* @returns a boolean value. If the edge exists between the source and destination vertexMap, the function will update
* the weight of the edge and return true. If the edge does not exist, the function will return false.

@@ -172,3 +172,3 @@ */

*
* The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
* The function `getAllPathsBetween` finds all paths between two vertexMap in a graph using depth-first search.
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).

@@ -178,3 +178,3 @@ * It is the starting vertex for finding paths.

* @param limit - The count of limitation of result array.
* @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`VO[][]`).
* @returns The function `getAllPathsBetween` returns an array of arrays of vertexMap (`VO[][]`).
*/

@@ -191,4 +191,4 @@ getAllPathsBetween(v1: VO | VertexKey, v2: VO | VertexKey, limit?: number): VO[][];

* The function calculates the sum of weights along a given path.
* @param {VO[]} path - An array of vertices (VO) representing a path in a graph.
* @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
* @param {VO[]} path - An array of vertexMap (VO) representing a path in a graph.
* @returns The function `getPathSumWeight` returns the sum of the weights of the edgeMap in the given path.
*/

@@ -204,3 +204,3 @@ getPathSumWeight(path: VO[]): number;

*
* The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
* The function `getMinCostBetween` calculates the minimum cost between two vertexMap in a graph, either based on edge
* weights or using a breadth-first search algorithm.

@@ -210,8 +210,8 @@ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.

* you want to find the minimum cost or weight from the source vertex `v1`.
* @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
* @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edgeMap have weights.
* If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
* the edges. If isWeight is set to false or not provided, the function will calculate the
* @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`v1`
* the edgeMap. If isWeight is set to false or not provided, the function will calculate the
* @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertexMap (`v1`
* and `v2`). If the `isWeight` parameter is `true`, it calculates the minimum weight among all paths between the
* vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
* vertexMap. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
* minimum number of

@@ -228,3 +228,3 @@ */

*
* The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
* The function `getMinPathBetween` returns the minimum path between two vertexMap in a graph, either based on weight or
* using a breadth-first search algorithm.

@@ -235,3 +235,3 @@ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex

* path.
* @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
* @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edgeMap in finding the
* minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set

@@ -242,4 +242,4 @@ * to false, the function will use breadth-first search (BFS) to find the minimum path.

* so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
* @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
* two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
* @returns The function `getMinPathBetween` returns an array of vertexMap (`VO[]`) representing the minimum path between
* two vertexMap (`v1` and `v2`). If there is no path between the vertexMap, it returns `undefined`.
*/

@@ -259,3 +259,3 @@ getMinPathBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean, isDFS?: boolean): VO[] | undefined;

*
* The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
* The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertexMap in
* a graph without using a heap data structure.

@@ -272,3 +272,3 @@ * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a

* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
* shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
* @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.

@@ -281,3 +281,3 @@ */

* Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
* Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
* Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
* The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.

@@ -302,3 +302,3 @@ *

* vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
* will calculate the shortest paths to all other vertices from the source vertex.
* will calculate the shortest paths to all other vertexMap from the source vertex.
* @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum

@@ -309,3 +309,3 @@ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If

* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
* shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
* @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.

@@ -325,5 +325,5 @@ */

* one to rest pairs
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
* The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
* all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
* all other vertexMap in a graph, and optionally detects negative cycles and generates the minimum path.
* @param {VO | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will

@@ -333,5 +333,5 @@ * start calculating the shortest paths. It can be either a vertex object or a vertex ID.

* @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
* calculate the minimum distance from the source vertex to all other vertices in the graph. If `getMin` is set to
* calculate the minimum distance from the source vertex to all other vertexMap in the graph. If `getMin` is set to
* `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum
* @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertices from the source
* @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertexMap from the source
* vertex.

@@ -359,3 +359,3 @@ * @returns The function `bellmanFord` returns an object with the following properties:

* one to rest pairs
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
* The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to

@@ -368,3 +368,3 @@ */

* all pairs
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
* /

@@ -378,9 +378,9 @@

* all pairs
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
* The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
* The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertexMap in a
* graph.
* @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
* property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
* `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
* path between vertices in the
* property is a 2D array of numbers representing the shortest path costs between vertexMap in a graph. The
* `predecessor` property is a 2D array of vertexMap (or `undefined`) representing the predecessor vertexMap in the shortest
* path between vertexMap in the
*/

@@ -396,3 +396,3 @@ floydWarshall(): {

* Tarjan can find cycles in directed or undirected graph
* Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
* Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
* Tarjan solve the bi-connected components of undirected graphs;

@@ -408,3 +408,3 @@ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.

* Tarjan can find cycles in directed or undirected graph
* Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
* Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
* Tarjan solve the bi-connected components of undirected graphs;

@@ -415,6 +415,6 @@ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.

* @param {boolean} [needCutVertexes] - A boolean value indicating whether or not to calculate and return the
* articulation points in the graph. Articulation points are the vertices in a graph whose removal would increase the
* articulation points in the graph. Articulation points are the vertexMap in a graph whose removal would increase the
* number of connected components in the graph.
* @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
* (edges whose removal would increase the number of connected components in the graph).
* (edgeMap whose removal would increase the number of connected components in the graph).
* @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the

@@ -425,3 +425,3 @@ * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the

* set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
* are arrays of vertices that form cycles within the SCCs.
* are arrays of vertexMap that form cycles within the SCCs.
* @returns The function `tarjan` returns an object with the following properties:

@@ -498,3 +498,3 @@ */

*/
filter(predicate: PairCallback<VertexKey, V | undefined, boolean>, thisArg?: any): [VertexKey, V | undefined][];
filter(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: any): [VertexKey, V | undefined][];
/**

@@ -517,3 +517,3 @@ * Time Complexity: O(n)

*/
map<T>(callback: PairCallback<VertexKey, V | undefined, T>, thisArg?: any): T[];
map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?: any): T[];
protected _getIterator(): IterableIterator<[VertexKey, V | undefined]>;

@@ -520,0 +520,0 @@ protected abstract _addEdgeOnly(edge: EO): boolean;

@@ -49,9 +49,9 @@ "use strict";

exports.AbstractEdge = AbstractEdge;
class AbstractGraph extends base_1.IterablePairBase {
class AbstractGraph extends base_1.IterableEntryBase {
constructor() {
super();
this._vertices = new Map();
this._vertexMap = new Map();
}
get vertices() {
return this._vertices;
get vertexMap() {
return this._vertexMap;
}

@@ -68,8 +68,8 @@ /**

* @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
* the `_vertices` map.
* @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
* the `_vertexMap` map.
* @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertexMap`
* map. If the vertex does not exist, it returns `undefined`.
*/
getVertex(vertexKey) {
return this._vertices.get(vertexKey) || undefined;
return this._vertexMap.get(vertexKey) || undefined;
}

@@ -90,3 +90,3 @@ /**

hasVertex(vertexOrKey) {
return this._vertices.has(this._getVertexKey(vertexOrKey));
return this._vertexMap.has(this._getVertexKey(vertexOrKey));
}

@@ -125,21 +125,21 @@ /**

const vertexKey = this._getVertexKey(vertexOrKey);
return this._vertices.delete(vertexKey);
return this._vertexMap.delete(vertexKey);
}
/**
* Time Complexity: O(K), where K is the number of vertices to be removed.
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
*/
/**
* Time Complexity: O(K), where K is the number of vertices to be removed.
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
*
* The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
* @param {VO[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`VO[]`) or an array
* The function removes all vertexMap from a graph and returns a boolean indicating if any vertexMap were removed.
* @param {VO[] | VertexKey[]} vertexMap - The `vertexMap` parameter can be either an array of vertexMap (`VO[]`) or an array
* of vertex IDs (`VertexKey[]`).
* @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
* @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertexMap
* were removed.
*/
removeManyVertices(vertices) {
removeManyVertices(vertexMap) {
const removed = [];
for (const v of vertices) {
for (const v of vertexMap) {
removed.push(this.deleteVertex(v));

@@ -157,3 +157,3 @@ }

*
* The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
* The function checks if there is an edge between two vertexMap and returns a boolean value indicating the result.
* @param {VertexKey | VO} v1 - The parameter v1 can be either a VertexKey or a VO. A VertexKey represents the unique

@@ -201,3 +201,3 @@ * identifier of a vertex in a graph, while VO represents the type of the vertex object itself.

*
* The function sets the weight of an edge between two vertices in a graph.
* The function sets the weight of an edge between two vertexMap in a graph.
* @param {VertexKey | VO} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `VO` object. It represents

@@ -209,3 +209,3 @@ * the source vertex of the edge.

* and the destination vertex (destOrKey).
* @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
* @returns a boolean value. If the edge exists between the source and destination vertexMap, the function will update
* the weight of the edge and return true. If the edge does not exist, the function will return false.

@@ -231,3 +231,3 @@ */

*
* The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
* The function `getAllPathsBetween` finds all paths between two vertexMap in a graph using depth-first search.
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).

@@ -237,3 +237,3 @@ * It is the starting vertex for finding paths.

* @param limit - The count of limitation of result array.
* @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`VO[][]`).
* @returns The function `getAllPathsBetween` returns an array of arrays of vertexMap (`VO[][]`).
*/

@@ -275,4 +275,4 @@ getAllPathsBetween(v1, v2, limit = 1000) {

* The function calculates the sum of weights along a given path.
* @param {VO[]} path - An array of vertices (VO) representing a path in a graph.
* @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
* @param {VO[]} path - An array of vertexMap (VO) representing a path in a graph.
* @returns The function `getPathSumWeight` returns the sum of the weights of the edgeMap in the given path.
*/

@@ -295,3 +295,3 @@ getPathSumWeight(path) {

*
* The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
* The function `getMinCostBetween` calculates the minimum cost between two vertexMap in a graph, either based on edge
* weights or using a breadth-first search algorithm.

@@ -301,8 +301,8 @@ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.

* you want to find the minimum cost or weight from the source vertex `v1`.
* @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
* @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edgeMap have weights.
* If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
* the edges. If isWeight is set to false or not provided, the function will calculate the
* @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`v1`
* the edgeMap. If isWeight is set to false or not provided, the function will calculate the
* @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertexMap (`v1`
* and `v2`). If the `isWeight` parameter is `true`, it calculates the minimum weight among all paths between the
* vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
* vertexMap. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
* minimum number of

@@ -362,3 +362,3 @@ */

*
* The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
* The function `getMinPathBetween` returns the minimum path between two vertexMap in a graph, either based on weight or
* using a breadth-first search algorithm.

@@ -369,3 +369,3 @@ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex

* path.
* @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
* @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edgeMap in finding the
* minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set

@@ -376,4 +376,4 @@ * to false, the function will use breadth-first search (BFS) to find the minimum path.

* so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
* @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
* two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
* @returns The function `getMinPathBetween` returns an array of vertexMap (`VO[]`) representing the minimum path between
* two vertexMap (`v1` and `v2`). If there is no path between the vertexMap, it returns `undefined`.
*/

@@ -443,3 +443,3 @@ getMinPathBetween(v1, v2, isWeight, isDFS = false) {

*
* The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
* The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertexMap in
* a graph without using a heap data structure.

@@ -456,3 +456,3 @@ * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a

* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
* shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
* @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.

@@ -471,3 +471,3 @@ */

const paths = [];
const vertices = this._vertices;
const vertexMap = this._vertexMap;
const distMap = new Map();

@@ -481,3 +481,3 @@ const seen = new Set();

}
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -503,3 +503,3 @@ if (vertexOrKey instanceof AbstractVertex)

const getPaths = (minV) => {
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -520,3 +520,3 @@ if (vertexOrKey instanceof AbstractVertex) {

};
for (let i = 1; i < vertices.size; i++) {
for (let i = 1; i < vertexMap.size; i++) {
const cur = getMinOfNoSeen();

@@ -570,3 +570,3 @@ if (cur) {

* Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
* Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
* Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
* The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.

@@ -591,3 +591,3 @@ *

* vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
* will calculate the shortest paths to all other vertices from the source vertex.
* will calculate the shortest paths to all other vertexMap from the source vertex.
* @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum

@@ -598,3 +598,3 @@ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If

* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
* shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
* @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.

@@ -614,3 +614,3 @@ */

const paths = [];
const vertices = this._vertices;
const vertexMap = this._vertexMap;
const distMap = new Map();

@@ -623,3 +623,3 @@ const seen = new Set();

return undefined;
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -634,3 +634,3 @@ if (vertexOrKey instanceof AbstractVertex)

/**
* The function `getPaths` retrieves all paths from vertices to a specified minimum vertex.
* The function `getPaths` retrieves all paths from vertexMap to a specified minimum vertex.
* @param {VO | undefined} minV - The parameter `minV` is of type `VO | undefined`. It represents the minimum vertex value or

@@ -640,3 +640,3 @@ * undefined.

const getPaths = (minV) => {
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -719,5 +719,5 @@ if (vertexOrKey instanceof AbstractVertex) {

* one to rest pairs
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
* The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
* all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
* all other vertexMap in a graph, and optionally detects negative cycles and generates the minimum path.
* @param {VO | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will

@@ -727,5 +727,5 @@ * start calculating the shortest paths. It can be either a vertex object or a vertex ID.

* @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
* calculate the minimum distance from the source vertex to all other vertices in the graph. If `getMin` is set to
* calculate the minimum distance from the source vertex to all other vertexMap in the graph. If `getMin` is set to
* `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum
* @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertices from the source
* @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertexMap from the source
* vertex.

@@ -751,7 +751,7 @@ * @returns The function `bellmanFord` returns an object with the following properties:

return { hasNegativeCycle, distMap, preMap, paths, min, minPath };
const vertices = this._vertices;
const numOfVertices = vertices.size;
const edges = this.edgeSet();
const numOfEdges = edges.length;
this._vertices.forEach(vertex => {
const vertexMap = this._vertexMap;
const numOfVertices = vertexMap.size;
const edgeMap = this.edgeSet();
const numOfEdges = edgeMap.length;
this._vertexMap.forEach(vertex => {
distMap.set(vertex, Infinity);

@@ -762,6 +762,6 @@ });

for (let j = 0; j < numOfEdges; ++j) {
const ends = this.getEndsOfEdge(edges[j]);
const ends = this.getEndsOfEdge(edgeMap[j]);
if (ends) {
const [s, d] = ends;
const weight = edges[j].weight;
const weight = edgeMap[j].weight;
const sWeight = distMap.get(s);

@@ -791,3 +791,3 @@ const dWeight = distMap.get(d);

if (genPath) {
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -809,6 +809,6 @@ if (vertexOrKey instanceof AbstractVertex) {

for (let j = 0; j < numOfEdges; ++j) {
const ends = this.getEndsOfEdge(edges[j]);
const ends = this.getEndsOfEdge(edgeMap[j]);
if (ends) {
const [s] = ends;
const weight = edges[j].weight;
const weight = edgeMap[j].weight;
const sWeight = distMap.get(s);

@@ -834,3 +834,3 @@ if (sWeight) {

* one to rest pairs
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
* The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to

@@ -843,3 +843,3 @@ */

* all pairs
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
* /

@@ -853,13 +853,13 @@

* all pairs
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
* The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
* The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertexMap in a
* graph.
* @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
* property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
* `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
* path between vertices in the
* property is a 2D array of numbers representing the shortest path costs between vertexMap in a graph. The
* `predecessor` property is a 2D array of vertexMap (or `undefined`) representing the predecessor vertexMap in the shortest
* path between vertexMap in the
*/
floydWarshall() {
var _a;
const idAndVertices = [...this._vertices];
const idAndVertices = [...this._vertexMap];
const n = idAndVertices.length;

@@ -898,3 +898,3 @@ const costs = [];

* Tarjan can find cycles in directed or undirected graph
* Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
* Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
* Tarjan solve the bi-connected components of undirected graphs;

@@ -910,3 +910,3 @@ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.

* Tarjan can find cycles in directed or undirected graph
* Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
* Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
* Tarjan solve the bi-connected components of undirected graphs;

@@ -917,6 +917,6 @@ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.

* @param {boolean} [needCutVertexes] - A boolean value indicating whether or not to calculate and return the
* articulation points in the graph. Articulation points are the vertices in a graph whose removal would increase the
* articulation points in the graph. Articulation points are the vertexMap in a graph whose removal would increase the
* number of connected components in the graph.
* @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
* (edges whose removal would increase the number of connected components in the graph).
* (edgeMap whose removal would increase the number of connected components in the graph).
* @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the

@@ -927,3 +927,3 @@ * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the

* set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
* are arrays of vertices that form cycles within the SCCs.
* are arrays of vertexMap that form cycles within the SCCs.
* @returns The function `tarjan` returns an object with the following properties:

@@ -946,8 +946,8 @@ */

const lowMap = new Map();
const vertices = this._vertices;
vertices.forEach(v => {
const vertexMap = this._vertexMap;
vertexMap.forEach(v => {
dfnMap.set(v, -1);
lowMap.set(v, Infinity);
});
const [root] = vertices.values();
const [root] = vertexMap.values();
const cutVertexes = [];

@@ -1137,3 +1137,3 @@ const bridges = [];

*_getIterator() {
for (const vertex of this._vertices.values()) {
for (const vertex of this._vertexMap.values()) {
yield [vertex.key, vertex.value];

@@ -1147,3 +1147,3 @@ }

}
this._vertices.set(newVertex.key, newVertex);
this._vertexMap.set(newVertex.key, newVertex);
return true;

@@ -1153,3 +1153,3 @@ }

const vertexKey = this._getVertexKey(vertexOrKey);
return this._vertices.get(vertexKey) || undefined;
return this._vertexMap.get(vertexKey) || undefined;
}

@@ -1156,0 +1156,0 @@ _getVertexKey(vertexOrKey) {

@@ -18,3 +18,3 @@ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';

/**
* The constructor function initializes the source and destination vertices of an edge, along with an optional weight
* The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
* and value.

@@ -47,3 +47,3 @@ * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in

* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
* could be a number or a string depending on how you want to identify your vertices.
* could be a number or a string depending on how you want to identify your vertexMap.
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,

@@ -60,3 +60,3 @@ * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be

/**
* The function creates a directed edge between two vertices with an optional weight and value.
* The function creates a directed edge between two vertexMap with an optional weight and value.
* @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.

@@ -72,10 +72,10 @@ * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.

/**
* Time Complexity: O(|V|) where |V| is the number of vertices
* Time Complexity: O(|V|) where |V| is the number of vertexMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|V|) where |V| is the number of vertices
* Time Complexity: O(|V|) where |V| is the number of vertexMap
* Space Complexity: O(1)
*
* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
* The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
* @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.

@@ -85,14 +85,14 @@ * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the

* destination is not specified.
* @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
* @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
*/
getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined;
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function removes an edge between two vertices in a graph and returns the removed edge.
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
* @param {VO | VertexKey} srcOrKey - The source vertex or its ID.

@@ -104,7 +104,7 @@ * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.

/**
* Time Complexity: O(E) where E is the number of edges
* Time Complexity: O(E) where E is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(E) where E is the number of edges
* Time Complexity: O(E) where E is the number of edgeMap
* Space Complexity: O(1)

@@ -137,10 +137,10 @@ *

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function removes edges between two vertices and returns the removed edges.
* The function removes edgeMap between two vertexMap and returns the removed edgeMap.
* @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the

@@ -150,3 +150,3 @@ * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.

* the second vertex in the edge that needs to be removed.
* @returns an array of removed edges (EO[]).
* @returns an array of removed edgeMap (EO[]).
*/

@@ -162,6 +162,6 @@ deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[];

*
* The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
* The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
* @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
*/

@@ -177,6 +177,6 @@ incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[];

*
* The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
* The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
* @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
*/

@@ -205,5 +205,5 @@ outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[];

*
* The function "inDegreeOf" returns the number of incoming edges for a given vertex.
* The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The number of incoming edges of the specified vertex or vertex ID.
* @returns The number of incoming edgeMap of the specified vertex or vertex ID.
*/

@@ -219,5 +219,5 @@ inDegreeOf(vertexOrKey: VertexKey | VO): number;

*
* The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
* The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The number of outgoing edges from the specified vertex or vertex ID.
* @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
*/

@@ -233,5 +233,5 @@ outDegreeOf(vertexOrKey: VertexKey | VO): number;

*
* The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
* The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The function `edgesOf` returns an array of edges.
* @returns The function `edgesOf` returns an array of edgeMap.
*/

@@ -266,55 +266,55 @@ edgesOf(vertexOrKey: VertexKey | VO): EO[];

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function `getDestinations` returns an array of destination vertices connected to a given vertex.
* The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
* @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/
getDestinations(vertex: VO | VertexKey | undefined): VO[];
/**
* Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
* Space Complexity: O(|V|)
*/
/**
* Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
* Space Complexity: O(|V|)
*
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
* in the sorted order, or undefined if the graph contains a cycle.
* @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
* property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
* specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
* @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
* property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
* specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
* @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
*/
topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined;
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(|E|)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(|E|)
*
* The `edgeSet` function returns an array of all the edges in the graph.
* @returns The `edgeSet()` method returns an array of edges (`EO[]`).
* The `edgeSet` function returns an array of all the edgeMap in the graph.
* @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
*/
edgeSet(): EO[];
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
* The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -330,6 +330,6 @@ getNeighbors(vertexOrKey: VO | VertexKey): VO[];

*
* The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
* The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
* otherwise it returns undefined.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
* graph. If the edge does not exist, it returns `undefined`.

@@ -346,3 +346,3 @@ */

*
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that

@@ -349,0 +349,0 @@ * needs to be added to the graph.

@@ -28,3 +28,3 @@ "use strict";

/**
* The constructor function initializes the source and destination vertices of an edge, along with an optional weight
* The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
* and value.

@@ -68,3 +68,3 @@ * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in

* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
* could be a number or a string depending on how you want to identify your vertices.
* could be a number or a string depending on how you want to identify your vertexMap.
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,

@@ -83,3 +83,3 @@ * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be

/**
* The function creates a directed edge between two vertices with an optional weight and value.
* The function creates a directed edge between two vertexMap with an optional weight and value.
* @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.

@@ -97,10 +97,10 @@ * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.

/**
* Time Complexity: O(|V|) where |V| is the number of vertices
* Time Complexity: O(|V|) where |V| is the number of vertexMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|V|) where |V| is the number of vertices
* Time Complexity: O(|V|) where |V| is the number of vertexMap
* Space Complexity: O(1)
*
* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
* The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
* @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.

@@ -110,6 +110,6 @@ * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the

* destination is not specified.
* @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
* @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
*/
getEdge(srcOrKey, destOrKey) {
let edges = [];
let edgeMap = [];
if (srcOrKey !== undefined && destOrKey !== undefined) {

@@ -121,17 +121,17 @@ const src = this._getVertex(srcOrKey);

if (srcOutEdges) {
edges = srcOutEdges.filter(edge => edge.dest === dest.key);
edgeMap = srcOutEdges.filter(edge => edge.dest === dest.key);
}
}
}
return edges[0] || undefined;
return edgeMap[0] || undefined;
}
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function removes an edge between two vertices in a graph and returns the removed edge.
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
* @param {VO | VertexKey} srcOrKey - The source vertex or its ID.

@@ -159,7 +159,7 @@ * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.

/**
* Time Complexity: O(E) where E is the number of edges
* Time Complexity: O(E) where E is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(E) where E is the number of edges
* Time Complexity: O(E) where E is the number of edgeMap
* Space Complexity: O(1)

@@ -232,13 +232,13 @@ *

}
return this._vertices.delete(vertexKey);
return this._vertexMap.delete(vertexKey);
}
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function removes edges between two vertices and returns the removed edges.
* The function removes edgeMap between two vertexMap and returns the removed edgeMap.
* @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the

@@ -248,3 +248,3 @@ * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.

* the second vertex in the edge that needs to be removed.
* @returns an array of removed edges (EO[]).
* @returns an array of removed edgeMap (EO[]).
*/

@@ -269,6 +269,6 @@ deleteEdgesBetween(v1, v2) {

*
* The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
* The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
* @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
*/

@@ -290,6 +290,6 @@ incomingEdgesOf(vertexOrKey) {

*
* The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
* The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
* @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
*/

@@ -326,5 +326,5 @@ outgoingEdgesOf(vertexOrKey) {

*
* The function "inDegreeOf" returns the number of incoming edges for a given vertex.
* The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The number of incoming edges of the specified vertex or vertex ID.
* @returns The number of incoming edgeMap of the specified vertex or vertex ID.
*/

@@ -342,5 +342,5 @@ inDegreeOf(vertexOrKey) {

*
* The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
* The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The number of outgoing edges from the specified vertex or vertex ID.
* @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
*/

@@ -358,5 +358,5 @@ outDegreeOf(vertexOrKey) {

*
* The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
* The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The function `edgesOf` returns an array of edges.
* @returns The function `edgesOf` returns an array of edgeMap.
*/

@@ -397,13 +397,13 @@ edgesOf(vertexOrKey) {

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function `getDestinations` returns an array of destination vertices connected to a given vertex.
* The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
* @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -425,15 +425,15 @@ getDestinations(vertex) {

/**
* Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
* Space Complexity: O(|V|)
*/
/**
* Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
* Space Complexity: O(|V|)
*
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
* in the sorted order, or undefined if the graph contains a cycle.
* @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
* property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
* specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
* @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
* property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
* specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
* @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
*/

@@ -445,3 +445,3 @@ topologicalSort(propertyName) {

const statusMap = new Map();
for (const entry of this.vertices) {
for (const entry of this.vertexMap) {
statusMap.set(entry[1], 0);

@@ -466,3 +466,3 @@ }

};
for (const entry of this.vertices) {
for (const entry of this.vertexMap) {
if (statusMap.get(entry[1]) === 0) {

@@ -479,31 +479,31 @@ dfs(entry[1]);

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(|E|)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(|E|)
*
* The `edgeSet` function returns an array of all the edges in the graph.
* @returns The `edgeSet()` method returns an array of edges (`EO[]`).
* The `edgeSet` function returns an array of all the edgeMap in the graph.
* @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
*/
edgeSet() {
let edges = [];
let edgeMap = [];
this._outEdgeMap.forEach(outEdges => {
edges = [...edges, ...outEdges];
edgeMap = [...edgeMap, ...outEdges];
});
return edges;
return edgeMap;
}
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
* The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -533,6 +533,6 @@ getNeighbors(vertexOrKey) {

*
* The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
* The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
* otherwise it returns undefined.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
* graph. If the edge does not exist, it returns `undefined`.

@@ -561,3 +561,3 @@ */

*
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that

@@ -564,0 +564,0 @@ * needs to be added to the graph.

@@ -35,4 +35,4 @@ import { MapGraphCoordinate, VertexKey } from '../../types';

/**
* The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
* @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
* The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
* @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
* starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map

@@ -44,5 +44,5 @@ * graph.

*/
constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
protected _origin: MapGraphCoordinate;
get origin(): MapGraphCoordinate;
constructor(originCoord: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
protected _originCoord: MapGraphCoordinate;
get originCoord(): MapGraphCoordinate;
protected _bottomRight: MapGraphCoordinate | undefined;

@@ -49,0 +49,0 @@ get bottomRight(): MapGraphCoordinate | undefined;

@@ -43,4 +43,4 @@ "use strict";

/**
* The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
* @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
* The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
* @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
* starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map

@@ -52,10 +52,10 @@ * graph.

*/
constructor(origin, bottomRight) {
constructor(originCoord, bottomRight) {
super();
this._origin = [0, 0];
this._origin = origin;
this._originCoord = [0, 0];
this._originCoord = originCoord;
this._bottomRight = bottomRight;
}
get origin() {
return this._origin;
get originCoord() {
return this._originCoord;
}

@@ -76,3 +76,3 @@ get bottomRight() {

*/
createVertex(key, value, lat = this.origin[0], long = this.origin[1]) {
createVertex(key, value, lat = this.originCoord[0], long = this.originCoord[1]) {
return new MapVertex(key, value, lat, long);

@@ -79,0 +79,0 @@ }

@@ -15,3 +15,3 @@ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';

export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
vertices: [VertexKey, VertexKey];
vertexMap: [VertexKey, VertexKey];
/**

@@ -31,7 +31,7 @@ * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional

/**
* The constructor initializes a new Map object to store edges.
* The constructor initializes a new Map object to store edgeMap.
*/
constructor();
protected _edges: Map<VO, EO[]>;
get edges(): Map<VO, EO[]>;
protected _edgeMap: Map<VO, EO[]>;
get edgeMap(): Map<VO, EO[]>;
/**

@@ -48,3 +48,3 @@ * The function creates a new vertex with an optional value and returns it.

/**
* The function creates an undirected edge between two vertices with an optional weight and value.
* The function creates an undirected edge between two vertexMap with an optional weight and value.
* @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.

@@ -60,10 +60,10 @@ * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.

/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function `getEdge` returns the first edge that connects two vertices, or undefined if no such edge exists.
* The function `getEdge` returns the first edge that connects two vertexMap, or undefined if no such edge exists.
* @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex

@@ -77,25 +77,25 @@ * object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).

/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function removes an edge between two vertices in a graph and returns the removed edge.
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
* @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
* (VertexKey). It represents the second vertex of the edge that needs to be removed.
* @returns the removed edge (EO) if it exists, or undefined if either of the vertices (VO) does not exist.
* @returns the removed edge (EO) if it exists, or undefined if either of the vertexMap (VO) does not exist.
*/
deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | undefined;
/**
* Time Complexity: O(E), where E is the number of edges incident to the given vertex.
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(E), where E is the number of edges incident to the given vertex.
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function `deleteEdge` deletes an edge between two vertices in a graph.
* The function `deleteEdge` deletes an edge between two vertexMap in a graph.
* @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be

@@ -132,7 +132,7 @@ * either an edge object or a vertex key.

*
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edgeMap connected to that
* vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
* edges connected to that vertex.
* edgeMap connected to that vertex.
*/

@@ -148,17 +148,17 @@ degreeOf(vertexOrKey: VertexKey | VO): number;

*
* The function returns the edges of a given vertex or vertex ID.
* The function returns the edgeMap of a given vertex or vertex ID.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
* unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
* @returns an array of edges.
* @returns an array of edgeMap.
*/
edgesOf(vertexOrKey: VertexKey | VO): EO[];
/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*/
/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*
* The function "edgeSet" returns an array of unique edges from a set of edges.
* The function "edgeSet" returns an array of unique edgeMap from a set of edgeMap.
* @returns The method `edgeSet()` returns an array of type `EO[]`.

@@ -168,13 +168,13 @@ */

/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*/
/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*
* The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
* The function "getNeighbors" returns an array of neighboring vertexMap for a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -190,6 +190,6 @@ getNeighbors(vertexOrKey: VO | VertexKey): VO[];

*
* The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
* The function "getEndsOfEdge" returns the vertexMap at the ends of an edge if the edge exists in the graph, otherwise
* it returns undefined.
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
* graph. If the edge does not exist, it returns `undefined`.

@@ -206,3 +206,3 @@ */

*
* The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
* The function adds an edge to the graph by updating the adjacency list with the vertexMap of the edge.
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.

@@ -209,0 +209,0 @@ * @returns a boolean value.

@@ -39,3 +39,3 @@ "use strict";

super(weight, value);
this.vertices = [v1, v2];
this.vertexMap = [v1, v2];
}

@@ -46,10 +46,10 @@ }

/**
* The constructor initializes a new Map object to store edges.
* The constructor initializes a new Map object to store edgeMap.
*/
constructor() {
super();
this._edges = new Map();
this._edgeMap = new Map();
}
get edges() {
return this._edges;
get edgeMap() {
return this._edgeMap;
}

@@ -69,3 +69,3 @@ /**

/**
* The function creates an undirected edge between two vertices with an optional weight and value.
* The function creates an undirected edge between two vertexMap with an optional weight and value.
* @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.

@@ -83,10 +83,10 @@ * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.

/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function `getEdge` returns the first edge that connects two vertices, or undefined if no such edge exists.
* The function `getEdge` returns the first edge that connects two vertexMap, or undefined if no such edge exists.
* @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex

@@ -100,3 +100,3 @@ * object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).

var _a;
let edges = [];
let edgeMap = [];
if (v1 !== undefined && v2 !== undefined) {

@@ -106,20 +106,20 @@ const vertex1 = this._getVertex(v1);

if (vertex1 && vertex2) {
edges = (_a = this._edges.get(vertex1)) === null || _a === void 0 ? void 0 : _a.filter(e => e.vertices.includes(vertex2.key));
edgeMap = (_a = this._edgeMap.get(vertex1)) === null || _a === void 0 ? void 0 : _a.filter(e => e.vertexMap.includes(vertex2.key));
}
}
return edges ? edges[0] || undefined : undefined;
return edgeMap ? edgeMap[0] || undefined : undefined;
}
/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function removes an edge between two vertices in a graph and returns the removed edge.
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
* @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
* (VertexKey). It represents the second vertex of the edge that needs to be removed.
* @returns the removed edge (EO) if it exists, or undefined if either of the vertices (VO) does not exist.
* @returns the removed edge (EO) if it exists, or undefined if either of the vertexMap (VO) does not exist.
*/

@@ -132,10 +132,10 @@ deleteEdgeBetween(v1, v2) {

}
const v1Edges = this._edges.get(vertex1);
const v1Edges = this._edgeMap.get(vertex1);
let removed = undefined;
if (v1Edges) {
removed = (0, utils_1.arrayRemove)(v1Edges, (e) => e.vertices.includes(vertex2.key))[0] || undefined;
removed = (0, utils_1.arrayRemove)(v1Edges, (e) => e.vertexMap.includes(vertex2.key))[0] || undefined;
}
const v2Edges = this._edges.get(vertex2);
const v2Edges = this._edgeMap.get(vertex2);
if (v2Edges) {
(0, utils_1.arrayRemove)(v2Edges, (e) => e.vertices.includes(vertex1.key));
(0, utils_1.arrayRemove)(v2Edges, (e) => e.vertexMap.includes(vertex1.key));
}

@@ -145,10 +145,10 @@ return removed;

/**
* Time Complexity: O(E), where E is the number of edges incident to the given vertex.
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(E), where E is the number of edges incident to the given vertex.
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function `deleteEdge` deletes an edge between two vertices in a graph.
* The function `deleteEdge` deletes an edge between two vertexMap in a graph.
* @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be

@@ -174,4 +174,4 @@ * either an edge object or a vertex key.

else {
oneSide = this._getVertex(edgeOrOneSideVertexKey.vertices[0]);
otherSide = this._getVertex(edgeOrOneSideVertexKey.vertices[1]);
oneSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[0]);
otherSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[1]);
}

@@ -212,13 +212,13 @@ if (oneSide && otherSide) {

neighbors.forEach(neighbor => {
const neighborEdges = this._edges.get(neighbor);
const neighborEdges = this._edgeMap.get(neighbor);
if (neighborEdges) {
const restEdges = neighborEdges.filter(edge => {
return !edge.vertices.includes(vertexKey);
return !edge.vertexMap.includes(vertexKey);
});
this._edges.set(neighbor, restEdges);
this._edgeMap.set(neighbor, restEdges);
}
});
this._edges.delete(vertex);
this._edgeMap.delete(vertex);
}
return this._vertices.delete(vertexKey);
return this._vertexMap.delete(vertexKey);
}

@@ -233,7 +233,7 @@ /**

*
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edgeMap connected to that
* vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
* edges connected to that vertex.
* edgeMap connected to that vertex.
*/

@@ -244,3 +244,3 @@ degreeOf(vertexOrKey) {

if (vertex) {
return ((_a = this._edges.get(vertex)) === null || _a === void 0 ? void 0 : _a.length) || 0;
return ((_a = this._edgeMap.get(vertex)) === null || _a === void 0 ? void 0 : _a.length) || 0;
}

@@ -259,6 +259,6 @@ else {

*
* The function returns the edges of a given vertex or vertex ID.
* The function returns the edgeMap of a given vertex or vertex ID.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
* unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
* @returns an array of edges.
* @returns an array of edgeMap.
*/

@@ -268,3 +268,3 @@ edgesOf(vertexOrKey) {

if (vertex) {
return this._edges.get(vertex) || [];
return this._edgeMap.get(vertex) || [];
}

@@ -276,10 +276,10 @@ else {

/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*/
/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*
* The function "edgeSet" returns an array of unique edges from a set of edges.
* The function "edgeSet" returns an array of unique edgeMap from a set of edgeMap.
* @returns The method `edgeSet()` returns an array of type `EO[]`.

@@ -289,4 +289,4 @@ */

const edgeSet = new Set();
this._edges.forEach(edges => {
edges.forEach(edge => {
this._edgeMap.forEach(edgeMap => {
edgeMap.forEach(edge => {
edgeSet.add(edge);

@@ -298,13 +298,13 @@ });

/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*/
/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*
* The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
* The function "getNeighbors" returns an array of neighboring vertexMap for a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -317,3 +317,3 @@ getNeighbors(vertexOrKey) {

for (const edge of neighborEdges) {
const neighbor = this._getVertex(edge.vertices.filter(e => e !== vertex.key)[0]);
const neighbor = this._getVertex(edge.vertexMap.filter(e => e !== vertex.key)[0]);
if (neighbor) {

@@ -334,14 +334,14 @@ neighbors.push(neighbor);

*
* The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
* The function "getEndsOfEdge" returns the vertexMap at the ends of an edge if the edge exists in the graph, otherwise
* it returns undefined.
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
* graph. If the edge does not exist, it returns `undefined`.
*/
getEndsOfEdge(edge) {
if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
if (!this.hasEdge(edge.vertexMap[0], edge.vertexMap[1])) {
return undefined;
}
const v1 = this._getVertex(edge.vertices[0]);
const v2 = this._getVertex(edge.vertices[1]);
const v1 = this._getVertex(edge.vertexMap[0]);
const v2 = this._getVertex(edge.vertexMap[1]);
if (v1 && v2) {

@@ -362,3 +362,3 @@ return [v1, v2];

*
* The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
* The function adds an edge to the graph by updating the adjacency list with the vertexMap of the edge.
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.

@@ -368,3 +368,3 @@ * @returns a boolean value.

_addEdgeOnly(edge) {
for (const end of edge.vertices) {
for (const end of edge.vertexMap) {
const endVertex = this._getVertex(end);

@@ -374,8 +374,8 @@ if (endVertex === undefined)

if (endVertex) {
const edges = this._edges.get(endVertex);
if (edges) {
edges.push(edge);
const edgeMap = this._edgeMap.get(endVertex);
if (edgeMap) {
edgeMap.push(edge);
}
else {
this._edges.set(endVertex, [edge]);
this._edgeMap.set(endVertex, [edge]);
}

@@ -382,0 +382,0 @@ }

@@ -8,5 +8,5 @@ /**

*/
import { HashMapLinkedNode, HashMapOptions, HashMapStoreItem, PairCallback } from '../../types';
import { IterablePairBase } from "../base";
export declare class HashMap<K = any, V = any> extends IterablePairBase<K, V> {
import { EntryCallback, HashMapLinkedNode, HashMapOptions, HashMapStoreItem } from '../../types';
import { IterableEntryBase } from "../base";
export declare class HashMap<K = any, V = any> extends IterableEntryBase<K, V> {
protected _store: {

@@ -89,3 +89,3 @@ [key: string]: HashMapStoreItem<K, V>;

*/
map<U>(callbackfn: PairCallback<K, V, U>, thisArg?: any): HashMap<K, U>;
map<U>(callbackfn: EntryCallback<K, V, U>, thisArg?: any): HashMap<K, U>;
/**

@@ -111,3 +111,3 @@ * Time Complexity: O(n)

*/
filter(predicate: PairCallback<K, V, boolean>, thisArg?: any): HashMap<K, V>;
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): HashMap<K, V>;
print(): void;

@@ -123,3 +123,3 @@ /**

}
export declare class LinkedHashMap<K = any, V = any> extends IterablePairBase<K, V> {
export declare class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K, V> {
protected _noObjMap: Record<string, HashMapLinkedNode<K, V | undefined>>;

@@ -260,3 +260,3 @@ protected _objMap: WeakMap<object, HashMapLinkedNode<K, V | undefined>>;

*/
filter(predicate: PairCallback<K, V, boolean>, thisArg?: any): LinkedHashMap<K, V>;
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): LinkedHashMap<K, V>;
/**

@@ -283,3 +283,3 @@ * Time Complexity: O(n)

*/
map<NV>(callback: PairCallback<K, V, NV>, thisArg?: any): LinkedHashMap<K, NV>;
map<NV>(callback: EntryCallback<K, V, NV>, thisArg?: any): LinkedHashMap<K, NV>;
print(): void;

@@ -286,0 +286,0 @@ /**

@@ -13,3 +13,3 @@ "use strict";

const base_1 = require("../base");
class HashMap extends base_1.IterablePairBase {
class HashMap extends base_1.IterableEntryBase {
/**

@@ -234,3 +234,3 @@ * The constructor function initializes a new instance of a class with optional elements and options.

exports.HashMap = HashMap;
class LinkedHashMap extends base_1.IterablePairBase {
class LinkedHashMap extends base_1.IterableEntryBase {
constructor(elements, options = {

@@ -237,0 +237,0 @@ hashFn: (key) => String(key),

@@ -6,5 +6,5 @@ import { BinaryTree, BinaryTreeNode } from '../data-structures';

createTree(options?: Partial<BinaryTreeOptions<K>>): TREE;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count?: number): N | null | undefined;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | null | undefined;
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
}

@@ -1,5 +0,5 @@

import { IterableElementBase, IterablePairBase } from "../../../data-structures";
export type PairCallback<K, V, R> = (value: V, key: K, index: number, container: IterablePairBase<K, V>) => R;
import { IterableElementBase, IterableEntryBase } from "../../../data-structures";
export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
export type ElementCallback<V, R> = (element: V, index: number, container: IterableElementBase<V>) => R;
export type ReducePairCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterablePairBase<K, V>) => R;
export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
export type ReduceElementCallback<V, R> = (accumulator: R, element: V, index: number, container: IterableElementBase<V>) => R;
{
"name": "min-heap-typed",
"version": "1.48.4",
"version": "1.48.5",
"description": "Min Heap. Javascript & Typescript Data Structure.",

@@ -135,4 +135,4 @@ "main": "dist/index.js",

"dependencies": {
"data-structure-typed": "^1.48.4"
"data-structure-typed": "^1.48.5"
}
}

@@ -1,4 +0,4 @@

import { ElementCallback, PairCallback, ReduceElementCallback, ReducePairCallback } from "../../types";
import { ElementCallback, EntryCallback, ReduceElementCallback, ReduceEntryCallback } from "../../types";
export abstract class IterablePairBase<K = any, V = any> {
export abstract class IterableEntryBase<K = any, V = any> {

@@ -90,3 +90,3 @@ /**

*/
every(predicate: PairCallback<K, V, boolean>, thisArg?: any): boolean {
every(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
let index = 0;

@@ -120,3 +120,3 @@ for (const item of this) {

*/
some(predicate: PairCallback<K, V, boolean>, thisArg?: any): boolean {
some(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
let index = 0;

@@ -148,3 +148,3 @@ for (const item of this) {

*/
forEach(callbackfn: PairCallback<K, V, void>, thisArg?: any): void {
forEach(callbackfn: EntryCallback<K, V, void>, thisArg?: any): void {
let index = 0;

@@ -177,3 +177,3 @@ for (const item of this) {

*/
reduce<U>(callbackfn: ReducePairCallback<K, V, U>, initialValue: U): U {
reduce<U>(callbackfn: ReduceEntryCallback<K, V, U>, initialValue: U): U {
let accumulator = initialValue;

@@ -180,0 +180,0 @@ let index = 0;

@@ -98,15 +98,18 @@ /**

/**
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
*
*
* The function overrides the add method of a binary tree node and balances the tree after inserting
* a new node.
* @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be either a key, a node, or an
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry.
* @returns The method is returning either the inserted node or `undefined`.
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary tree.
* @returns The method is returning either the inserted node or undefined.
*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined {
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
if (keyOrNodeOrEntry === null) return undefined;
const inserted = super.add(keyOrNodeOrEntry);
const inserted = super.add(keyOrNodeOrEntry, value);
if (inserted) this._balancePath(inserted);

@@ -113,0 +116,0 @@ return inserted;

@@ -157,9 +157,12 @@ /**

/**
* The function `exemplarToNode` takes an exemplar and returns a corresponding node if the exemplar
* is valid, otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
* @returns a variable `node` which is of type `N` or `undefined`.
* The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
* otherwise it returns undefined.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
* `exemplarToNode` function. It represents the value associated with the exemplar node.
* @returns a node of type N or undefined.
*/
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>): N | undefined {
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
let node: N | undefined;

@@ -178,3 +181,3 @@ if (exemplar === null || exemplar === undefined) {

} else if (this.isNotNodeInstance(exemplar)) {
node = this.createNode(exemplar);
node = this.createNode(exemplar, value);
} else {

@@ -194,11 +197,13 @@ return;

* Space Complexity: O(1) - Constant space is used.
*
* The `add` function adds a new node to a binary search tree, either by key or by providing a node
* object.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @returns The method returns either the newly added node (`newNode`) or `undefined` if the input
* (`keyOrNodeOrEntry`) is null, undefined, or does not match any of the expected types.
*
* The `add` function adds a new node to a binary tree, updating the value if the key already exists
* or inserting a new node if the key is unique.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary tree.
* @returns The method `add` returns either the newly added node (`newNode`) or `undefined` if the
* node was not added.
*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry);
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
if (newNode === undefined) return;

@@ -205,0 +210,0 @@

@@ -119,10 +119,10 @@ /**

/**
* The function `exemplarToNode` takes an exemplar and returns a node if the exemplar is valid,
* otherwise it returns undefined.
* @param exemplar - BTNodeExemplar<K, V, N> - A generic type representing an exemplar of a binary tree
* node. It can be either a node itself, an entry (key-value pair), a node key, or any other value
* that is not a valid exemplar.
* @returns a variable `node` which is of type `N | undefined`.
* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
* `exemplarToNode` function. It represents the value associated with the exemplar node. If a value
* is provided, it will be used when creating the new node. If no value is provided, the new node
* @returns a node of type N or undefined.
*/
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>): N | undefined {
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
let node: N | undefined;

@@ -142,3 +142,3 @@

} else if (this.isNotNodeInstance(exemplar)) {
node = this.createNode(exemplar, undefined, RBTNColor.RED);
node = this.createNode(exemplar, value, RBTNColor.RED);
} else {

@@ -156,9 +156,15 @@ return;

/**
* The function adds a node to a Red-Black Tree data structure.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @returns The method `add` returns either an instance of `N` (the node that was added) or
* `undefined`.
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*
* The `add` function adds a new node to a binary search tree and performs necessary rotations and
* color changes to maintain the red-black tree properties.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry.
* @param {V} [value] - The `value` parameter represents the value associated with the key that is
* being added to the binary search tree.
* @returns The method `add` returns either the newly added node (`N`) or `undefined`.
*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry);
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
if (newNode === undefined) return;

@@ -165,0 +171,0 @@

@@ -88,11 +88,15 @@ /**

/**
* The function `exemplarToNode` converts an exemplar object into a node object.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where `V` represents
* the value type and `N` represents the node type.
* @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it
* can be one of the following:
* @param {V} [value] - The `value` parameter is an optional argument that represents the value
* associated with the node. It is of type `V`, which can be any data type. If no value is provided,
* it defaults to `undefined`.
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the node should be created. If not provided, it defaults to 1.
* @returns a value of type `N` (the generic type parameter) or `undefined`.
* times the value should be added to the node. If not provided, it defaults to 1.
* @returns a node of type `N` or `undefined`.
*/
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, count = 1): N | undefined {
override exemplarToNode(exemplar: BTNodeExemplar<K, V, N>, value?: V, count = 1): N | undefined {
let node: N | undefined;

@@ -111,3 +115,3 @@ if (exemplar === undefined || exemplar === null) {

} else if (this.isNotNodeInstance(exemplar)) {
node = this.createNode(exemplar, undefined, count);
node = this.createNode(exemplar, value, count);
} else {

@@ -127,13 +131,17 @@ return;

* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
*
* The `add` function overrides the base class `add` function to add a new node to the tree multimap
* and update the count.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be one of the following:
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
* times the key or node or entry should be added to the multimap. If not provided, the default value
* is 1.
* @returns either a node (`N`) or `undefined`.
*
* The function overrides the add method of a binary tree node and adds a new node to the tree.
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
* entry. It represents the key, node, or entry that you want to add to the binary tree.
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
* binary tree node. It is an optional parameter, meaning it can be omitted when calling the `add`
* method.
* @param [count=1] - The `count` parameter represents the number of times the key-value pair should
* be added to the binary tree. By default, it is set to 1, meaning that the key-value pair will be
* added once. However, you can specify a different value for `count` if you want to add
* @returns The method is returning either the newly inserted node or `undefined` if the insertion
* was not successful.
*/
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count = 1): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, count);
override add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count = 1): N | undefined {
const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);
if (newNode === undefined) return;

@@ -196,3 +204,3 @@

const midNode = sorted[m];
this.add([midNode.key, midNode.value], midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
buildBalanceBST(l, m - 1);

@@ -213,3 +221,3 @@ buildBalanceBST(m + 1, r);

const midNode = sorted[m];
this.add([midNode.key, midNode.value], midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
stack.push([m + 1, r]);

@@ -335,3 +343,3 @@ stack.push([l, m - 1]);

const cloned = this.createTree();
this.bfs(node => cloned.add([node.key, node.value], node.count));
this.bfs(node => cloned.add(node.key, node.value, node.count));
return cloned;

@@ -338,0 +346,0 @@ }

@@ -11,6 +11,6 @@ /**

import type { DijkstraResult, VertexKey } from '../../types';
import { PairCallback } from "../../types";
import { EntryCallback } from "../../types";
import { IGraph } from '../../interfaces';
import { Queue } from '../queue';
import { IterablePairBase } from "../base";
import { IterableEntryBase } from "../base";

@@ -70,3 +70,3 @@ export abstract class AbstractVertex<V = any> {

EO extends AbstractEdge<E> = AbstractEdge<E>
> extends IterablePairBase<VertexKey, V | undefined> implements IGraph<V, E, VO, EO> {
> extends IterableEntryBase<VertexKey, V | undefined> implements IGraph<V, E, VO, EO> {
constructor() {

@@ -76,6 +76,6 @@ super();

protected _vertices: Map<VertexKey, VO> = new Map<VertexKey, VO>();
protected _vertexMap: Map<VertexKey, VO> = new Map<VertexKey, VO>();
get vertices(): Map<VertexKey, VO> {
return this._vertices;
get vertexMap(): Map<VertexKey, VO> {
return this._vertexMap;
}

@@ -126,8 +126,8 @@

* @param {VertexKey} vertexKey - The `vertexKey` parameter is the identifier of the vertex that you want to retrieve from
* the `_vertices` map.
* @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertices`
* the `_vertexMap` map.
* @returns The method `getVertex` returns the vertex with the specified `vertexKey` if it exists in the `_vertexMap`
* map. If the vertex does not exist, it returns `undefined`.
*/
getVertex(vertexKey: VertexKey): VO | undefined {
return this._vertices.get(vertexKey) || undefined;
return this._vertexMap.get(vertexKey) || undefined;
}

@@ -150,3 +150,3 @@

hasVertex(vertexOrKey: VO | VertexKey): boolean {
return this._vertices.has(this._getVertexKey(vertexOrKey));
return this._vertexMap.has(this._getVertexKey(vertexOrKey));
}

@@ -193,7 +193,7 @@

const vertexKey = this._getVertexKey(vertexOrKey);
return this._vertices.delete(vertexKey);
return this._vertexMap.delete(vertexKey);
}
/**
* Time Complexity: O(K), where K is the number of vertices to be removed.
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
* Space Complexity: O(1) - Constant space, as it creates only a few variables.

@@ -203,14 +203,14 @@ */

/**
* Time Complexity: O(K), where K is the number of vertices to be removed.
* Time Complexity: O(K), where K is the number of vertexMap to be removed.
* Space Complexity: O(1) - Constant space, as it creates only a few variables.
*
* The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.
* @param {VO[] | VertexKey[]} vertices - The `vertices` parameter can be either an array of vertices (`VO[]`) or an array
* The function removes all vertexMap from a graph and returns a boolean indicating if any vertexMap were removed.
* @param {VO[] | VertexKey[]} vertexMap - The `vertexMap` parameter can be either an array of vertexMap (`VO[]`) or an array
* of vertex IDs (`VertexKey[]`).
* @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices
* @returns a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertexMap
* were removed.
*/
removeManyVertices(vertices: VO[] | VertexKey[]): boolean {
removeManyVertices(vertexMap: VO[] | VertexKey[]): boolean {
const removed: boolean[] = [];
for (const v of vertices) {
for (const v of vertexMap) {
removed.push(this.deleteVertex(v));

@@ -230,3 +230,3 @@ }

*
* The function checks if there is an edge between two vertices and returns a boolean value indicating the result.
* The function checks if there is an edge between two vertexMap and returns a boolean value indicating the result.
* @param {VertexKey | VO} v1 - The parameter v1 can be either a VertexKey or a VO. A VertexKey represents the unique

@@ -277,3 +277,3 @@ * identifier of a vertex in a graph, while VO represents the type of the vertex object itself.

*
* The function sets the weight of an edge between two vertices in a graph.
* The function sets the weight of an edge between two vertexMap in a graph.
* @param {VertexKey | VO} srcOrKey - The `srcOrKey` parameter can be either a `VertexKey` or a `VO` object. It represents

@@ -285,3 +285,3 @@ * the source vertex of the edge.

* and the destination vertex (destOrKey).
* @returns a boolean value. If the edge exists between the source and destination vertices, the function will update
* @returns a boolean value. If the edge exists between the source and destination vertexMap, the function will update
* the weight of the edge and return true. If the edge does not exist, the function will return false.

@@ -308,3 +308,3 @@ */

*
* The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.
* The function `getAllPathsBetween` finds all paths between two vertexMap in a graph using depth-first search.
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).

@@ -314,3 +314,3 @@ * It is the starting vertex for finding paths.

* @param limit - The count of limitation of result array.
* @returns The function `getAllPathsBetween` returns an array of arrays of vertices (`VO[][]`).
* @returns The function `getAllPathsBetween` returns an array of arrays of vertexMap (`VO[][]`).
*/

@@ -358,4 +358,4 @@ getAllPathsBetween(v1: VO | VertexKey, v2: VO | VertexKey, limit = 1000): VO[][] {

* The function calculates the sum of weights along a given path.
* @param {VO[]} path - An array of vertices (VO) representing a path in a graph.
* @returns The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.
* @param {VO[]} path - An array of vertexMap (VO) representing a path in a graph.
* @returns The function `getPathSumWeight` returns the sum of the weights of the edgeMap in the given path.
*/

@@ -379,3 +379,3 @@ getPathSumWeight(path: VO[]): number {

*
* The function `getMinCostBetween` calculates the minimum cost between two vertices in a graph, either based on edge
* The function `getMinCostBetween` calculates the minimum cost between two vertexMap in a graph, either based on edge
* weights or using a breadth-first search algorithm.

@@ -385,8 +385,8 @@ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex or its ID.

* you want to find the minimum cost or weight from the source vertex `v1`.
* @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edges have weights.
* @param {boolean} [isWeight] - isWeight is an optional parameter that indicates whether the graph edgeMap have weights.
* If isWeight is set to true, the function will calculate the minimum cost between v1 and v2 based on the weights of
* the edges. If isWeight is set to false or not provided, the function will calculate the
* @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`v1`
* the edgeMap. If isWeight is set to false or not provided, the function will calculate the
* @returns The function `getMinCostBetween` returns a number representing the minimum cost between two vertexMap (`v1`
* and `v2`). If the `isWeight` parameter is `true`, it calculates the minimum weight among all paths between the
* vertices. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
* vertexMap. If `isWeight` is `false` or not provided, it uses a breadth-first search (BFS) algorithm to calculate the
* minimum number of

@@ -448,3 +448,3 @@ */

*
* The function `getMinPathBetween` returns the minimum path between two vertices in a graph, either based on weight or
* The function `getMinPathBetween` returns the minimum path between two vertexMap in a graph, either based on weight or
* using a breadth-first search algorithm.

@@ -455,3 +455,3 @@ * @param {VO | VertexKey} v1 - The parameter `v1` represents the starting vertex of the path. It can be either a vertex

* path.
* @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edges in finding the
* @param {boolean} [isWeight] - A boolean flag indicating whether to consider the weight of edgeMap in finding the
* minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set

@@ -462,4 +462,4 @@ * to false, the function will use breadth-first search (BFS) to find the minimum path.

* so the default method is to use the Dijkstra algorithm to obtain the shortest weighted path.
* @returns The function `getMinPathBetween` returns an array of vertices (`VO[]`) representing the minimum path between
* two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `undefined`.
* @returns The function `getMinPathBetween` returns an array of vertexMap (`VO[]`) representing the minimum path between
* two vertexMap (`v1` and `v2`). If there is no path between the vertexMap, it returns `undefined`.
*/

@@ -531,3 +531,3 @@ getMinPathBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean, isDFS = false): VO[] | undefined {

*
* The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
* The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertexMap in
* a graph without using a heap data structure.

@@ -544,3 +544,3 @@ * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a

* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
* shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
* @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.

@@ -563,3 +563,3 @@ */

const vertices = this._vertices;
const vertexMap = this._vertexMap;
const distMap: Map<VO, number> = new Map();

@@ -576,3 +576,3 @@ const seen: Set<VO> = new Set();

for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -599,3 +599,3 @@ if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity);

const getPaths = (minV: VO | undefined) => {
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -617,3 +617,3 @@

for (let i = 1; i < vertices.size; i++) {
for (let i = 1; i < vertexMap.size; i++) {
const cur = getMinOfNoSeen();

@@ -670,3 +670,3 @@ if (cur) {

* Dijkstra's algorithm only solves the single-source shortest path problem, while the Bellman-Ford algorithm and Floyd-Warshall algorithm can address shortest paths between all pairs of nodes.
* Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edges.
* Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
* The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.

@@ -692,3 +692,3 @@ *

* vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
* will calculate the shortest paths to all other vertices from the source vertex.
* will calculate the shortest paths to all other vertexMap from the source vertex.
* @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum

@@ -699,3 +699,3 @@ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If

* paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
* shortest paths from the source vertex to all other vertices in the graph. If `genPaths
* shortest paths from the source vertex to all other vertexMap in the graph. If `genPaths
* @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.

@@ -717,3 +717,3 @@ */

const paths: VO[][] = [];
const vertices = this._vertices;
const vertexMap = this._vertexMap;
const distMap: Map<VO, number> = new Map();

@@ -728,3 +728,3 @@ const seen: Set<VO> = new Set();

for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -741,3 +741,3 @@ if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity);

/**
* The function `getPaths` retrieves all paths from vertices to a specified minimum vertex.
* The function `getPaths` retrieves all paths from vertexMap to a specified minimum vertex.
* @param {VO | undefined} minV - The parameter `minV` is of type `VO | undefined`. It represents the minimum vertex value or

@@ -747,3 +747,3 @@ * undefined.

const getPaths = (minV: VO | undefined) => {
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -829,5 +829,5 @@ if (vertexOrKey instanceof AbstractVertex) {

* one to rest pairs
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
* The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to
* all other vertices in a graph, and optionally detects negative cycles and generates the minimum path.
* all other vertexMap in a graph, and optionally detects negative cycles and generates the minimum path.
* @param {VO | VertexKey} src - The `src` parameter is the source vertex from which the Bellman-Ford algorithm will

@@ -837,5 +837,5 @@ * start calculating the shortest paths. It can be either a vertex object or a vertex ID.

* @param {boolean} [getMin] - The `getMin` parameter is a boolean flag that determines whether the algorithm should
* calculate the minimum distance from the source vertex to all other vertices in the graph. If `getMin` is set to
* calculate the minimum distance from the source vertex to all other vertexMap in the graph. If `getMin` is set to
* `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum
* @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertices from the source
* @param {boolean} [genPath] - A boolean flag indicating whether to generate paths for all vertexMap from the source
* vertex.

@@ -859,8 +859,8 @@ * @returns The function `bellmanFord` returns an object with the following properties:

const vertices = this._vertices;
const numOfVertices = vertices.size;
const edges = this.edgeSet();
const numOfEdges = edges.length;
const vertexMap = this._vertexMap;
const numOfVertices = vertexMap.size;
const edgeMap = this.edgeSet();
const numOfEdges = edgeMap.length;
this._vertices.forEach(vertex => {
this._vertexMap.forEach(vertex => {
distMap.set(vertex, Infinity);

@@ -873,6 +873,6 @@ });

for (let j = 0; j < numOfEdges; ++j) {
const ends = this.getEndsOfEdge(edges[j]);
const ends = this.getEndsOfEdge(edgeMap[j]);
if (ends) {
const [s, d] = ends;
const weight = edges[j].weight;
const weight = edgeMap[j].weight;
const sWeight = distMap.get(s);

@@ -903,3 +903,3 @@ const dWeight = distMap.get(d);

if (genPath) {
for (const vertex of vertices) {
for (const vertex of vertexMap) {
const vertexOrKey = vertex[1];

@@ -921,6 +921,6 @@ if (vertexOrKey instanceof AbstractVertex) {

for (let j = 0; j < numOfEdges; ++j) {
const ends = this.getEndsOfEdge(edges[j]);
const ends = this.getEndsOfEdge(edgeMap[j]);
if (ends) {
const [s] = ends;
const weight = edges[j].weight;
const weight = edgeMap[j].weight;
const sWeight = distMap.get(s);

@@ -948,3 +948,3 @@ if (sWeight) {

* one to rest pairs
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edges for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edges, the Bellman-Ford algorithm is more flexible in some scenarios.
* The Bellman-Ford algorithm is also used to find the shortest paths from a source node to all other nodes in a graph. Unlike Dijkstra's algorithm, it can handle edge weights that are negative. Its basic idea involves iterative relaxation of all edgeMap for several rounds to gradually approximate the shortest paths. Due to its ability to handle negative-weight edgeMap, the Bellman-Ford algorithm is more flexible in some scenarios.
* The `bellmanFord` function implements the Bellman-Ford algorithm to find the shortest path from a source vertex to

@@ -958,3 +958,3 @@ */

* all pairs
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
* /

@@ -968,12 +968,12 @@

* all pairs
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edges, and it can simultaneously compute shortest paths between any two nodes.
* The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertices in a
* The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
* The function implements the Floyd-Warshall algorithm to find the shortest path between all pairs of vertexMap in a
* graph.
* @returns The function `floydWarshall()` returns an object with two properties: `costs` and `predecessor`. The `costs`
* property is a 2D array of numbers representing the shortest path costs between vertices in a graph. The
* `predecessor` property is a 2D array of vertices (or `undefined`) representing the predecessor vertices in the shortest
* path between vertices in the
* property is a 2D array of numbers representing the shortest path costs between vertexMap in a graph. The
* `predecessor` property is a 2D array of vertexMap (or `undefined`) representing the predecessor vertexMap in the shortest
* path between vertexMap in the
*/
floydWarshall(): { costs: number[][]; predecessor: (VO | undefined)[][] } {
const idAndVertices = [...this._vertices];
const idAndVertices = [...this._vertexMap];
const n = idAndVertices.length;

@@ -1017,3 +1017,3 @@

* Tarjan can find cycles in directed or undirected graph
* Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
* Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
* Tarjan solve the bi-connected components of undirected graphs;

@@ -1029,3 +1029,3 @@ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.

* Tarjan can find cycles in directed or undirected graph
* Tarjan can find the articulation points and bridges(critical edges) of undirected graphs in linear time,
* Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time,
* Tarjan solve the bi-connected components of undirected graphs;

@@ -1036,6 +1036,6 @@ * Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs.

* @param {boolean} [needCutVertexes] - A boolean value indicating whether or not to calculate and return the
* articulation points in the graph. Articulation points are the vertices in a graph whose removal would increase the
* articulation points in the graph. Articulation points are the vertexMap in a graph whose removal would increase the
* number of connected components in the graph.
* @param {boolean} [needBridges] - A boolean flag indicating whether the algorithm should find and return the bridges
* (edges whose removal would increase the number of connected components in the graph).
* (edgeMap whose removal would increase the number of connected components in the graph).
* @param {boolean} [needSCCs] - A boolean value indicating whether the Strongly Connected Components (SCCs) of the

@@ -1046,3 +1046,3 @@ * graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the

* set to true, the algorithm will return a map of cycles, where the keys are the low values of the SCCs and the values
* are arrays of vertices that form cycles within the SCCs.
* are arrays of vertexMap that form cycles within the SCCs.
* @returns The function `tarjan` returns an object with the following properties:

@@ -1068,4 +1068,4 @@ */

const lowMap: Map<VO, number> = new Map();
const vertices = this._vertices;
vertices.forEach(v => {
const vertexMap = this._vertexMap;
vertexMap.forEach(v => {
dfnMap.set(v, -1);

@@ -1075,3 +1075,3 @@ lowMap.set(v, Infinity);

const [root] = vertices.values();
const [root] = vertexMap.values();

@@ -1240,3 +1240,3 @@ const cutVertexes: VO[] = [];

*/
filter(predicate: PairCallback<VertexKey, V | undefined, boolean>, thisArg?: any): [VertexKey, V | undefined][] {
filter(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: any): [VertexKey, V | undefined][] {
const filtered: [VertexKey, V | undefined][] = [];

@@ -1271,3 +1271,3 @@ let index = 0;

*/
map<T>(callback: PairCallback<VertexKey, V | undefined, T>, thisArg?: any): T[] {
map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?: any): T[] {
const mapped: T[] = [];

@@ -1283,3 +1283,3 @@ let index = 0;

protected* _getIterator(): IterableIterator<[VertexKey, V | undefined]> {
for (const vertex of this._vertices.values()) {
for (const vertex of this._vertexMap.values()) {
yield [vertex.key, vertex.value];

@@ -1296,3 +1296,3 @@ }

}
this._vertices.set(newVertex.key, newVertex);
this._vertexMap.set(newVertex.key, newVertex);
return true;

@@ -1303,3 +1303,3 @@ }

const vertexKey = this._getVertexKey(vertexOrKey);
return this._vertices.get(vertexKey) || undefined;
return this._vertexMap.get(vertexKey) || undefined;
}

@@ -1306,0 +1306,0 @@

@@ -31,3 +31,3 @@ /**

/**
* The constructor function initializes the source and destination vertices of an edge, along with an optional weight
* The constructor function initializes the source and destination vertexMap of an edge, along with an optional weight
* and value.

@@ -84,3 +84,3 @@ * @param {VertexKey} src - The `src` parameter is the source vertex ID. It represents the starting point of an edge in

* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is of type `VertexKey`, which
* could be a number or a string depending on how you want to identify your vertices.
* could be a number or a string depending on how you want to identify your vertexMap.
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,

@@ -101,3 +101,3 @@ * it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be

/**
* The function creates a directed edge between two vertices with an optional weight and value.
* The function creates a directed edge between two vertexMap with an optional weight and value.
* @param {VertexKey} src - The source vertex ID of the edge. It represents the starting point of the edge.

@@ -116,3 +116,3 @@ * @param {VertexKey} dest - The `dest` parameter is the identifier of the destination vertex for the edge.

/**
* Time Complexity: O(|V|) where |V| is the number of vertices
* Time Complexity: O(|V|) where |V| is the number of vertexMap
* Space Complexity: O(1)

@@ -122,6 +122,6 @@ */

/**
* Time Complexity: O(|V|) where |V| is the number of vertices
* Time Complexity: O(|V|) where |V| is the number of vertexMap
* Space Complexity: O(1)
*
* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
* The `getEdge` function retrieves an edge between two vertexMap based on their source and destination IDs.
* @param {VO | VertexKey | undefined} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.

@@ -131,6 +131,6 @@ * @param {VO | VertexKey | undefined} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the

* destination is not specified.
* @returns the first edge found between the source and destination vertices, or undefined if no such edge is found.
* @returns the first edge found between the source and destination vertexMap, or undefined if no such edge is found.
*/
getEdge(srcOrKey: VO | VertexKey | undefined, destOrKey: VO | VertexKey | undefined): EO | undefined {
let edges: EO[] = [];
let edgeMap: EO[] = [];

@@ -144,3 +144,3 @@ if (srcOrKey !== undefined && destOrKey !== undefined) {

if (srcOutEdges) {
edges = srcOutEdges.filter(edge => edge.dest === dest.key);
edgeMap = srcOutEdges.filter(edge => edge.dest === dest.key);
}

@@ -150,7 +150,7 @@ }

return edges[0] || undefined;
return edgeMap[0] || undefined;
}
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)

@@ -160,6 +160,6 @@ */

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function removes an edge between two vertices in a graph and returns the removed edge.
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
* @param {VO | VertexKey} srcOrKey - The source vertex or its ID.

@@ -190,3 +190,3 @@ * @param {VO | VertexKey} destOrKey - The `destOrKey` parameter represents the destination vertex or its ID.

/**
* Time Complexity: O(E) where E is the number of edges
* Time Complexity: O(E) where E is the number of edgeMap
* Space Complexity: O(1)

@@ -197,3 +197,3 @@ */

/**
* Time Complexity: O(E) where E is the number of edges
* Time Complexity: O(E) where E is the number of edgeMap
* Space Complexity: O(1)

@@ -270,7 +270,7 @@ *

return this._vertices.delete(vertexKey);
return this._vertexMap.delete(vertexKey);
}
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)

@@ -280,6 +280,6 @@ */

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function removes edges between two vertices and returns the removed edges.
* The function removes edgeMap between two vertexMap and returns the removed edgeMap.
* @param {VertexKey | VO} v1 - The parameter `v1` can be either a `VertexKey` or a `VO`. A `VertexKey` represents the

@@ -289,3 +289,3 @@ * unique identifier of a vertex in a graph, while `VO` represents the actual vertex object.

* the second vertex in the edge that needs to be removed.
* @returns an array of removed edges (EO[]).
* @returns an array of removed edgeMap (EO[]).
*/

@@ -315,6 +315,6 @@ deleteEdgesBetween(v1: VertexKey | VO, v2: VertexKey | VO): EO[] {

*
* The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.
* The function `incomingEdgesOf` returns an array of incoming edgeMap for a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns The method `incomingEdgesOf` returns an array of edges (`EO[]`).
* @returns The method `incomingEdgesOf` returns an array of edgeMap (`EO[]`).
*/

@@ -338,6 +338,6 @@ incomingEdgesOf(vertexOrKey: VO | VertexKey): EO[] {

*
* The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.
* The function `outgoingEdgesOf` returns an array of outgoing edgeMap from a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can accept either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns The method `outgoingEdgesOf` returns an array of edges (`EO[]`).
* @returns The method `outgoingEdgesOf` returns an array of edgeMap (`EO[]`).
*/

@@ -378,5 +378,5 @@ outgoingEdgesOf(vertexOrKey: VO | VertexKey): EO[] {

*
* The function "inDegreeOf" returns the number of incoming edges for a given vertex.
* The function "inDegreeOf" returns the number of incoming edgeMap for a given vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The number of incoming edges of the specified vertex or vertex ID.
* @returns The number of incoming edgeMap of the specified vertex or vertex ID.
*/

@@ -396,5 +396,5 @@ inDegreeOf(vertexOrKey: VertexKey | VO): number {

*
* The function `outDegreeOf` returns the number of outgoing edges from a given vertex.
* The function `outDegreeOf` returns the number of outgoing edgeMap from a given vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The number of outgoing edges from the specified vertex or vertex ID.
* @returns The number of outgoing edgeMap from the specified vertex or vertex ID.
*/

@@ -414,5 +414,5 @@ outDegreeOf(vertexOrKey: VertexKey | VO): number {

*
* The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.
* The function "edgesOf" returns an array of both outgoing and incoming edgeMap of a given vertex or vertex ID.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The function `edgesOf` returns an array of edges.
* @returns The function `edgesOf` returns an array of edgeMap.
*/

@@ -458,3 +458,3 @@ edgesOf(vertexOrKey: VertexKey | VO): EO[] {

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)

@@ -464,9 +464,9 @@ */

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function `getDestinations` returns an array of destination vertices connected to a given vertex.
* The function `getDestinations` returns an array of destination vertexMap connected to a given vertex.
* @param {VO | VertexKey | undefined} vertex - The `vertex` parameter represents the starting vertex from which we want to
* find the destinations. It can be either a `VO` object, a `VertexKey` value, or `undefined`.
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -489,3 +489,3 @@ getDestinations(vertex: VO | VertexKey | undefined): VO[] {

/**
* Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
* Space Complexity: O(|V|)

@@ -495,11 +495,11 @@ */

/**
* Time Complexity: O(|V| + |E|) where |V| is the number of vertices and |E| is the number of edges
* Time Complexity: O(|V| + |E|) where |V| is the number of vertexMap and |E| is the number of edgeMap
* Space Complexity: O(|V|)
*
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs
* The `topologicalSort` function performs a topological sort on a graph and returns an array of vertexMap or vertex IDs
* in the sorted order, or undefined if the graph contains a cycle.
* @param {'vertex' | 'key'} [propertyName] - The `propertyName` parameter is an optional parameter that specifies the
* property to use for sorting the vertices. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
* specified, the vertices themselves will be used for sorting. If 'key' is specified, the ids of
* @returns an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
* property to use for sorting the vertexMap. It can have two possible values: 'vertex' or 'key'. If 'vertex' is
* specified, the vertexMap themselves will be used for sorting. If 'key' is specified, the ids of
* @returns an array of vertexMap or vertex IDs in topological order. If there is a cycle in the graph, it returns undefined.
*/

@@ -511,3 +511,3 @@ topologicalSort(propertyName?: 'vertex' | 'key'): Array<VO | VertexKey> | undefined {

const statusMap: Map<VO | VertexKey, TopologicalStatus> = new Map<VO | VertexKey, TopologicalStatus>();
for (const entry of this.vertices) {
for (const entry of this.vertexMap) {
statusMap.set(entry[1], 0);

@@ -533,3 +533,3 @@ }

for (const entry of this.vertices) {
for (const entry of this.vertexMap) {
if (statusMap.get(entry[1]) === 0) {

@@ -547,3 +547,3 @@ dfs(entry[1]);

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(|E|)

@@ -553,18 +553,18 @@ */

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(|E|)
*
* The `edgeSet` function returns an array of all the edges in the graph.
* @returns The `edgeSet()` method returns an array of edges (`EO[]`).
* The `edgeSet` function returns an array of all the edgeMap in the graph.
* @returns The `edgeSet()` method returns an array of edgeMap (`EO[]`).
*/
edgeSet(): EO[] {
let edges: EO[] = [];
let edgeMap: EO[] = [];
this._outEdgeMap.forEach(outEdges => {
edges = [...edges, ...outEdges];
edgeMap = [...edgeMap, ...outEdges];
});
return edges;
return edgeMap;
}
/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)

@@ -574,9 +574,9 @@ */

/**
* Time Complexity: O(|E|) where |E| is the number of edges
* Time Complexity: O(|E|) where |E| is the number of edgeMap
* Space Complexity: O(1)
*
* The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.
* The function `getNeighbors` returns an array of neighboring vertexMap of a given vertex or vertex ID in a graph.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -608,6 +608,6 @@ getNeighbors(vertexOrKey: VO | VertexKey): VO[] {

*
* The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph,
* The function "getEndsOfEdge" returns the source and destination vertexMap of an edge if it exists in the graph,
* otherwise it returns undefined.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph.
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
* graph. If the edge does not exist, it returns `undefined`.

@@ -637,3 +637,3 @@ */

*
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that

@@ -640,0 +640,0 @@ * needs to be added to the graph.

@@ -50,4 +50,4 @@ import { MapGraphCoordinate, VertexKey } from '../../types';

/**
* The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.
* @param {MapGraphCoordinate} origin - The `origin` parameter is a `MapGraphCoordinate` object that represents the
* The constructor function initializes the originCoord and bottomRight properties of a MapGraphCoordinate object.
* @param {MapGraphCoordinate} originCoord - The `originCoord` parameter is a `MapGraphCoordinate` object that represents the
* starting point or reference point of the map graph. It defines the coordinates of the top-left corner of the map

@@ -59,12 +59,12 @@ * graph.

*/
constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate) {
constructor(originCoord: MapGraphCoordinate, bottomRight?: MapGraphCoordinate) {
super();
this._origin = origin;
this._originCoord = originCoord;
this._bottomRight = bottomRight;
}
protected _origin: MapGraphCoordinate = [0, 0];
protected _originCoord: MapGraphCoordinate = [0, 0];
get origin(): MapGraphCoordinate {
return this._origin;
get originCoord(): MapGraphCoordinate {
return this._originCoord;
}

@@ -89,3 +89,3 @@

*/
override createVertex(key: VertexKey, value?: V, lat: number = this.origin[0], long: number = this.origin[1]): VO {
override createVertex(key: VertexKey, value?: V, lat: number = this.originCoord[0], long: number = this.originCoord[1]): VO {
return new MapVertex(key, value, lat, long) as VO;

@@ -92,0 +92,0 @@ }

@@ -27,3 +27,3 @@ /**

export class UndirectedEdge<E = number> extends AbstractEdge<E> {
vertices: [VertexKey, VertexKey];
vertexMap: [VertexKey, VertexKey];

@@ -42,3 +42,3 @@ /**

super(weight, value);
this.vertices = [v1, v2];
this.vertexMap = [v1, v2];
}

@@ -56,13 +56,13 @@ }

/**
* The constructor initializes a new Map object to store edges.
* The constructor initializes a new Map object to store edgeMap.
*/
constructor() {
super();
this._edges = new Map<VO, EO[]>();
this._edgeMap = new Map<VO, EO[]>();
}
protected _edges: Map<VO, EO[]>;
protected _edgeMap: Map<VO, EO[]>;
get edges(): Map<VO, EO[]> {
return this._edges;
get edgeMap(): Map<VO, EO[]> {
return this._edgeMap;
}

@@ -84,3 +84,3 @@

/**
* The function creates an undirected edge between two vertices with an optional weight and value.
* The function creates an undirected edge between two vertexMap with an optional weight and value.
* @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.

@@ -99,3 +99,3 @@ * @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.

/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)

@@ -105,6 +105,6 @@ */

/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function `getEdge` returns the first edge that connects two vertices, or undefined if no such edge exists.
* The function `getEdge` returns the first edge that connects two vertexMap, or undefined if no such edge exists.
* @param {VO | VertexKey | undefined} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex

@@ -117,3 +117,3 @@ * object), `undefined`, or `VertexKey` (a string or number representing the ID of a vertex).

getEdge(v1: VO | VertexKey | undefined, v2: VO | VertexKey | undefined): EO | undefined {
let edges: EO[] | undefined = [];
let edgeMap: EO[] | undefined = [];

@@ -125,11 +125,11 @@ if (v1 !== undefined && v2 !== undefined) {

if (vertex1 && vertex2) {
edges = this._edges.get(vertex1)?.filter(e => e.vertices.includes(vertex2.key));
edgeMap = this._edgeMap.get(vertex1)?.filter(e => e.vertexMap.includes(vertex2.key));
}
}
return edges ? edges[0] || undefined : undefined;
return edgeMap ? edgeMap[0] || undefined : undefined;
}
/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)

@@ -139,10 +139,10 @@ */

/**
* Time Complexity: O(|E|), where |E| is the number of edges incident to the given vertex.
* Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function removes an edge between two vertices in a graph and returns the removed edge.
* The function removes an edge between two vertexMap in a graph and returns the removed edge.
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
* @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
* (VertexKey). It represents the second vertex of the edge that needs to be removed.
* @returns the removed edge (EO) if it exists, or undefined if either of the vertices (VO) does not exist.
* @returns the removed edge (EO) if it exists, or undefined if either of the vertexMap (VO) does not exist.
*/

@@ -157,10 +157,10 @@ deleteEdgeBetween(v1: VO | VertexKey, v2: VO | VertexKey): EO | undefined {

const v1Edges = this._edges.get(vertex1);
const v1Edges = this._edgeMap.get(vertex1);
let removed: EO | undefined = undefined;
if (v1Edges) {
removed = arrayRemove<EO>(v1Edges, (e: EO) => e.vertices.includes(vertex2.key))[0] || undefined;
removed = arrayRemove<EO>(v1Edges, (e: EO) => e.vertexMap.includes(vertex2.key))[0] || undefined;
}
const v2Edges = this._edges.get(vertex2);
const v2Edges = this._edgeMap.get(vertex2);
if (v2Edges) {
arrayRemove<EO>(v2Edges, (e: EO) => e.vertices.includes(vertex1.key));
arrayRemove<EO>(v2Edges, (e: EO) => e.vertexMap.includes(vertex1.key));
}

@@ -171,3 +171,3 @@ return removed;

/**
* Time Complexity: O(E), where E is the number of edges incident to the given vertex.
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)

@@ -178,6 +178,6 @@ */

/**
* Time Complexity: O(E), where E is the number of edges incident to the given vertex.
* Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
* Space Complexity: O(1)
*
* The function `deleteEdge` deletes an edge between two vertices in a graph.
* The function `deleteEdge` deletes an edge between two vertexMap in a graph.
* @param {EO | VertexKey} edgeOrOneSideVertexKey - The parameter `edgeOrOneSideVertexKey` can be

@@ -201,4 +201,4 @@ * either an edge object or a vertex key.

} else {
oneSide = this._getVertex(edgeOrOneSideVertexKey.vertices[0]);
otherSide = this._getVertex(edgeOrOneSideVertexKey.vertices[1]);
oneSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[0]);
otherSide = this._getVertex(edgeOrOneSideVertexKey.vertexMap[1]);
}

@@ -243,15 +243,15 @@

neighbors.forEach(neighbor => {
const neighborEdges = this._edges.get(neighbor);
const neighborEdges = this._edgeMap.get(neighbor);
if (neighborEdges) {
const restEdges = neighborEdges.filter(edge => {
return !edge.vertices.includes(vertexKey);
return !edge.vertexMap.includes(vertexKey);
});
this._edges.set(neighbor, restEdges);
this._edgeMap.set(neighbor, restEdges);
}
})
this._edges.delete(vertex);
this._edgeMap.delete(vertex);
}
return this._vertices.delete(vertexKey);
return this._vertexMap.delete(vertexKey);
}

@@ -268,7 +268,7 @@

*
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edgeMap connected to that
* vertex.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
* @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
* edges connected to that vertex.
* edgeMap connected to that vertex.
*/

@@ -278,3 +278,3 @@ degreeOf(vertexOrKey: VertexKey | VO): number {

if (vertex) {
return this._edges.get(vertex)?.length || 0;
return this._edgeMap.get(vertex)?.length || 0;
} else {

@@ -294,6 +294,6 @@ return 0;

*
* The function returns the edges of a given vertex or vertex ID.
* The function returns the edgeMap of a given vertex or vertex ID.
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
* unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
* @returns an array of edges.
* @returns an array of edgeMap.
*/

@@ -303,3 +303,3 @@ edgesOf(vertexOrKey: VertexKey | VO): EO[] {

if (vertex) {
return this._edges.get(vertex) || [];
return this._edgeMap.get(vertex) || [];
} else {

@@ -311,3 +311,3 @@ return [];

/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)

@@ -317,6 +317,6 @@ */

/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*
* The function "edgeSet" returns an array of unique edges from a set of edges.
* The function "edgeSet" returns an array of unique edgeMap from a set of edgeMap.
* @returns The method `edgeSet()` returns an array of type `EO[]`.

@@ -326,4 +326,4 @@ */

const edgeSet: Set<EO> = new Set();
this._edges.forEach(edges => {
edges.forEach(edge => {
this._edgeMap.forEach(edgeMap => {
edgeMap.forEach(edge => {
edgeSet.add(edge);

@@ -336,3 +336,3 @@ });

/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)

@@ -342,9 +342,9 @@ */

/**
* Time Complexity: O(|V| + |E|), where |V| is the number of vertices and |E| is the number of edges.
* Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
* Space Complexity: O(|E|)
*
* The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
* The function "getNeighbors" returns an array of neighboring vertexMap for a given vertex or vertex ID.
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
* (`VertexKey`).
* @returns an array of vertices (VO[]).
* @returns an array of vertexMap (VO[]).
*/

@@ -357,3 +357,3 @@ getNeighbors(vertexOrKey: VO | VertexKey): VO[] {

for (const edge of neighborEdges) {
const neighbor = this._getVertex(edge.vertices.filter(e => e !== vertex.key)[0]);
const neighbor = this._getVertex(edge.vertexMap.filter(e => e !== vertex.key)[0]);
if (neighbor) {

@@ -376,14 +376,14 @@ neighbors.push(neighbor);

*
* The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
* The function "getEndsOfEdge" returns the vertexMap at the ends of an edge if the edge exists in the graph, otherwise
* it returns undefined.
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
* @returns The function `getEndsOfEdge` returns an array containing two vertexMap `[VO, VO]` if the edge exists in the
* graph. If the edge does not exist, it returns `undefined`.
*/
getEndsOfEdge(edge: EO): [VO, VO] | undefined {
if (!this.hasEdge(edge.vertices[0], edge.vertices[1])) {
if (!this.hasEdge(edge.vertexMap[0], edge.vertexMap[1])) {
return undefined;
}
const v1 = this._getVertex(edge.vertices[0]);
const v2 = this._getVertex(edge.vertices[1]);
const v1 = this._getVertex(edge.vertexMap[0]);
const v2 = this._getVertex(edge.vertexMap[1]);
if (v1 && v2) {

@@ -405,3 +405,3 @@ return [v1, v2];

*
* The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
* The function adds an edge to the graph by updating the adjacency list with the vertexMap of the edge.
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.

@@ -411,11 +411,11 @@ * @returns a boolean value.

protected _addEdgeOnly(edge: EO): boolean {
for (const end of edge.vertices) {
for (const end of edge.vertexMap) {
const endVertex = this._getVertex(end);
if (endVertex === undefined) return false;
if (endVertex) {
const edges = this._edges.get(endVertex);
if (edges) {
edges.push(edge);
const edgeMap = this._edgeMap.get(endVertex);
if (edgeMap) {
edgeMap.push(edge);
} else {
this._edges.set(endVertex, [edge]);
this._edgeMap.set(endVertex, [edge]);
}

@@ -422,0 +422,0 @@ }

@@ -10,6 +10,6 @@ /**

import { isWeakKey, rangeCheck } from '../../utils';
import { HashMapLinkedNode, HashMapOptions, HashMapStoreItem, PairCallback } from '../../types';
import { IterablePairBase } from "../base";
import { EntryCallback, HashMapLinkedNode, HashMapOptions, HashMapStoreItem } from '../../types';
import { IterableEntryBase } from "../base";
export class HashMap<K = any, V = any> extends IterablePairBase<K, V> {
export class HashMap<K = any, V = any> extends IterableEntryBase<K, V> {
protected _store: { [key: string]: HashMapStoreItem<K, V> } = {};

@@ -169,3 +169,3 @@ protected _objMap: Map<object, V> = new Map();

*/
map<U>(callbackfn: PairCallback<K, V, U>, thisArg?: any): HashMap<K, U> {
map<U>(callbackfn: EntryCallback<K, V, U>, thisArg?: any): HashMap<K, U> {
const resultMap = new HashMap<K, U>();

@@ -200,3 +200,3 @@ let index = 0;

*/
filter(predicate: PairCallback<K, V, boolean>, thisArg?: any): HashMap<K, V> {
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): HashMap<K, V> {
const filteredMap = new HashMap<K, V>();

@@ -254,3 +254,3 @@ let index = 0;

export class LinkedHashMap<K = any, V = any> extends IterablePairBase<K, V> {
export class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K, V> {

@@ -574,3 +574,3 @@ protected _noObjMap: Record<string, HashMapLinkedNode<K, V | undefined>> = {};

*/
filter(predicate: PairCallback<K, V, boolean>, thisArg?: any): LinkedHashMap<K, V> {
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): LinkedHashMap<K, V> {
const filteredMap = new LinkedHashMap<K, V>();

@@ -609,3 +609,3 @@ let index = 0;

*/
map<NV>(callback: PairCallback<K, V, NV>, thisArg?: any): LinkedHashMap<K, NV> {
map<NV>(callback: EntryCallback<K, V, NV>, thisArg?: any): LinkedHashMap<K, NV> {
const mappedMap = new LinkedHashMap<K, NV>();

@@ -612,0 +612,0 @@ let index = 0;

@@ -16,3 +16,3 @@ import { BinaryTree, BinaryTreeNode } from '../data-structures';

add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, count?: number): N | null | undefined;
add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | null | undefined;

@@ -19,0 +19,0 @@ addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];

@@ -1,6 +0,6 @@

import { IterableElementBase, IterablePairBase } from "../../../data-structures";
import { IterableElementBase, IterableEntryBase } from "../../../data-structures";
export type PairCallback<K, V, R> = (value: V, key: K, index: number, container: IterablePairBase<K, V>) => R;
export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
export type ElementCallback<V, R> = (element: V, index: number, container: IterableElementBase<V>) => R;
export type ReducePairCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterablePairBase<K, V>) => R;
export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
export type ReduceElementCallback<V, R> = (accumulator: R, element: V, index: number, container: IterableElementBase<V>) => R;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc