# Class MapGraph<V, E>

#### Type Parameters

- #### V extends MapVertex<V["val"]> = MapVertex

- #### E extends MapEdge = MapEdge

#### Hierarchy

- DirectedGraph<V, E>
  - MapGraph

- Defined in src/data-structures/graph/map-graph.ts:60

#####
Index

### Constructors

constructor

### Properties

_bottomRight
_origin

### Accessors

bottomRight
inEdgeMap
origin
outEdgeMap
vertices

### Methods

_addEdgeOnly
_addVertexOnly
_getVertex
_getVertexId
_setInEdgeMap
_setOutEdgeMap
_setVertices
addEdge
addVertex
bellmanFord
createEdge
createVertex
degreeOf
dijkstra
dijkstraWithoutHeap
edgeSet
edgesOf
floyd
getAllPathsBetween
getDestinations
getEdge
getEdgeDest
getEdgeSrc
getEndsOfEdge
getMinCostBetween
getMinPathBetween
getNeighbors
getPathSumWeight
getVertex
hasEdge
hasVertex
inDegreeOf
incomingEdgesOf
outDegreeOf
outgoingEdgesOf
removeAllVertices
removeEdge
removeEdgeSrcToDest
removeEdgesBetween
removeVertex
setEdgeWeight
tarjan
topologicalSort

## Constructors

### constructor

- new MapGraph<V, E>(origin, bottomRight?): MapGraph<V, E>

- The constructor function initializes the origin and bottomRight properties of a MapGraphCoordinate object.

  #### Type Parameters

  - #### V extends MapVertex<V["val"], V> = MapVertex<any>

  - #### E extends MapEdge<any, E> = MapEdge<any>

  #### Parameters

  - ##### origin: MapGraphCoordinate

    The `origin` 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 graph.

  - ##### `Optional` bottomRight: MapGraphCoordinate

    The `bottomRight` parameter is an optional parameter of type `MapGraphCoordinate`. It represents the bottom right coordinate of a map graph. If this parameter is not provided, it will default to `undefined`.

  #### Returns MapGraph<V, E>

  Overrides DirectedGraph.constructor

  - Defined in src/data-structures/graph/map-graph.ts:73

## Properties

### `Private` _bottomRight

_bottomRight: undefined | MapGraphCoordinate

- Defined in src/data-structures/graph/map-graph.ts:89

### `Private` _origin

_origin: MapGraphCoordinate = ...

- Defined in src/data-structures/graph/map-graph.ts:79

## Accessors

### bottomRight

- get bottomRight(): undefined | MapGraphCoordinate

- #### Returns undefined | MapGraphCoordinate

  - Defined in src/data-structures/graph/map-graph.ts:91
- set bottomRight(value): void

- #### Parameters

  - ##### value: undefined | MapGraphCoordinate

  #### Returns void

  - Defined in src/data-structures/graph/map-graph.ts:95

### inEdgeMap

- get inEdgeMap(): Map<V, E[]>

- #### Returns Map<V, E[]>

  Inherited from DirectedGraph.inEdgeMap

  - Defined in src/data-structures/graph/directed-graph.ts:84

### origin

- get origin(): MapGraphCoordinate

- #### Returns MapGraphCoordinate

  - Defined in src/data-structures/graph/map-graph.ts:81
- set origin(value): void

- #### Parameters

  - ##### value: MapGraphCoordinate

  #### Returns void

  - Defined in src/data-structures/graph/map-graph.ts:85

### outEdgeMap

- get outEdgeMap(): Map<V, E[]>

- #### Returns Map<V, E[]>

  Inherited from DirectedGraph.outEdgeMap

  - Defined in src/data-structures/graph/directed-graph.ts:78

### vertices

- get vertices(): Map<VertexId, V>

- #### Returns Map<VertexId, V>

  Inherited from DirectedGraph.vertices

  - Defined in src/data-structures/graph/abstract-graph.ts:111

## Methods

### `Protected` _addEdgeOnly

- _addEdgeOnly(edge): boolean

- The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertices exist.

  #### Parameters

  - ##### edge: E

    The parameter `edge` is of type `E`, which represents an edge in a graph. It is the edge that needs to be added to the graph.

  #### Returns boolean

  a boolean value. It returns true if the edge was successfully added to the graph, and false if either the source or destination vertex does not exist in the graph.

  Inherited from DirectedGraph._addEdgeOnly

  - Defined in src/data-structures/graph/directed-graph.ts:434

### `Protected` _addVertexOnly

- _addVertexOnly(newVertex): boolean

- #### Parameters

  - ##### newVertex: V

  #### Returns boolean

  Inherited from DirectedGraph._addVertexOnly

  - Defined in src/data-structures/graph/abstract-graph.ts:1019

### `Protected` _getVertex

- _getVertex(vertexOrId): null | V

- #### Parameters

  - ##### vertexOrId: VertexId | V

  #### Returns null | V

  Inherited from DirectedGraph._getVertex

  - Defined in src/data-structures/graph/abstract-graph.ts:1028

### `Protected` _getVertexId

- _getVertexId(vertexOrId): VertexId

- #### Parameters

  - ##### vertexOrId: VertexId | V

  #### Returns VertexId

  Inherited from DirectedGraph._getVertexId

  - Defined in src/data-structures/graph/abstract-graph.ts:1033

### `Protected` _setInEdgeMap

- _setInEdgeMap(value): void

- #### Parameters

  - ##### value: Map<V, E[]>

  #### Returns void

  Inherited from DirectedGraph._setInEdgeMap

  - Defined in src/data-structures/graph/directed-graph.ts:467

### `Protected` _setOutEdgeMap

- _setOutEdgeMap(value): void

- #### Parameters

  - ##### value: Map<V, E[]>

  #### Returns void

  Inherited from DirectedGraph._setOutEdgeMap

  - Defined in src/data-structures/graph/directed-graph.ts:463

### `Protected` _setVertices

- _setVertices(value): void

- #### Parameters

  - ##### value: Map<VertexId, V>

  #### Returns void

  Inherited from DirectedGraph._setVertices

  - Defined in src/data-structures/graph/abstract-graph.ts:1037

### addEdge

- addEdge(edge): boolean

- #### Parameters

  - ##### edge: E

  #### Returns boolean

  Inherited from DirectedGraph.addEdge

  - Defined in src/data-structures/graph/abstract-graph.ts:220
- addEdge(src, dest, weight?, val?): boolean

- #### Parameters

  - ##### src: VertexId | V

  - ##### dest: VertexId | V

  - ##### `Optional` weight: number

  - ##### `Optional` val: E["val"]

  #### Returns boolean

  Inherited from DirectedGraph.addEdge

  - Defined in src/data-structures/graph/abstract-graph.ts:222

### addVertex

- addVertex(vertex): boolean

- #### Parameters

  - ##### vertex: V

  #### Returns boolean

  Inherited from DirectedGraph.addVertex

  - Defined in src/data-structures/graph/abstract-graph.ts:168
- addVertex(id, val?): boolean

- #### Parameters

  - ##### id: VertexId

  - ##### `Optional` val: V["val"]

  #### Returns boolean

  Inherited from DirectedGraph.addVertex

  - Defined in src/data-structures/graph/abstract-graph.ts:170

### bellmanFord

- bellmanFord(src, scanNegativeCycle?, getMin?, genPath?): {
  distMap: Map<V, number>;
  hasNegativeCycle: undefined | boolean;
  min: number;
  minPath: V[];
  paths: V[][];
  preMap: Map<V, V>;
  }

- BellmanFord time:O(VE) space:O(V) one to rest pairs /

  /** BellmanFord time:O(VE) space:O(V) 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 `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.

  #### Parameters

  - ##### src: VertexId | V

    The `src` parameter is the source vertex from which the Bellman-Ford algorithm will start calculating the shortest paths. It can be either a vertex object or a vertex ID.

  - ##### `Optional` scanNegativeCycle: boolean

    A boolean flag indicating whether to scan for negative cycles in the graph.

  - ##### `Optional` getMin: boolean

    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 `true`, the algorithm will find the minimum distance and update the `min` variable with the minimum

  - ##### `Optional` genPath: boolean

    A boolean flag indicating whether to generate paths for all vertices from the source vertex.

  #### Returns {
  distMap: Map<V, number>;
  hasNegativeCycle: undefined | boolean;
  min: number;
  minPath: V[];
  paths: V[][];
  preMap: Map<V, V>;
  }

  The function `bellmanFord` returns an object with the following properties:

  - ##### distMap: Map<V, number>

  - ##### hasNegativeCycle: undefined | boolean

  - ##### min: number

  - ##### minPath: V[]

  - ##### paths: V[][]

  - ##### preMap: Map<V, V>

  Inherited from DirectedGraph.bellmanFord

  - Defined in src/data-structures/graph/abstract-graph.ts:725

### createEdge

- createEdge(src, dest, weight?, val?): E

- The function creates a new instance of a MapEdge with the given source, destination, weight, and value.

  #### Parameters

  - ##### src: VertexId

    The source vertex ID of the edge. It represents the starting point of the edge.

  - ##### dest: VertexId

    The `dest` parameter is the identifier of the destination vertex for the edge being created.

  - ##### `Optional` weight: number

    The `weight` parameter is an optional number that represents the weight of the edge. It is used to assign a numerical value to the edge, which can be used in algorithms such as shortest path algorithms. If the weight is not provided, it can be set to a default value or left undefined.

  - ##### `Optional` val: E["val"]

    The `val` parameter is an optional value that can be assigned to the edge. It can be of any type, depending on the specific implementation of the `MapEdge` class.

  #### Returns E

  a new instance of the `MapEdge` class, casted as type `E`.

  Overrides DirectedGraph.createEdge

  - Defined in src/data-structures/graph/map-graph.ts:126

### createVertex

- createVertex(id, val?, lat?, long?): V

- The function creates a new vertex with the given id, value, latitude, and longitude.

  #### Parameters

  - ##### id: VertexId

    The id parameter is the unique identifier for the vertex. It is of type VertexId, which could be a string or a number depending on how you define it in your code.

  - ##### `Optional` val: V["val"]

    The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It is of type `V['val']`, which means it should be of the same type as the `val` property of the vertex class `V`.

  - ##### lat: number = ...

    The `lat` parameter represents the latitude of the vertex. It is a number that specifies the position of the vertex on the Earth's surface in the north-south direction.

  - ##### long: number = ...

    The `long` parameter represents the longitude coordinate of the vertex.

  #### Returns V

  The method is returning a new instance of the `MapVertex` class, casted as type `V`.

  Overrides DirectedGraph.createVertex

  - Defined in src/data-structures/graph/map-graph.ts:110

### degreeOf

- degreeOf(vertexOrId): number

- The function "degreeOf" returns the total degree of a vertex, which is the sum of its out-degree and in-degree.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a `VertexId` or a `V`.

  #### Returns number

  The sum of the out-degree and in-degree of the specified vertex or vertex ID.

  Inherited from DirectedGraph.degreeOf

  - Defined in src/data-structures/graph/directed-graph.ts:257

### dijkstra

- dijkstra(src, dest?, getMinDist?, genPaths?): DijkstraResult<V>

- Dijkstra algorithm time: O(logVE) space: O(V + E)

  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. 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(V^3), where V is the number of nodes. For dense graphs, Floyd-Warshall might become slower.

  /

  /** Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative. The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an optional destination vertex, and optionally returns the minimum distance, the paths, and other information.

  #### Parameters

  - ##### src: VertexId | V

    The `src` parameter represents the source vertex from which the Dijkstra algorithm will start. It can be either a vertex object or a vertex ID.

  - ##### `Optional` dest: null | VertexId | V

    The `dest` parameter is the destination vertex or vertex ID. It specifies the 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.

  - ##### `Optional` getMinDist: boolean

    The `getMinDist` parameter is a boolean flag that determines whether the minimum distance from the source vertex to the destination vertex should be calculated and returned in the result. If `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance

  - ##### `Optional` genPaths: boolean

    The `genPaths` parameter is a boolean flag that determines whether or not to generate 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 @returns The function` dijkstra`returns an object of type`DijkstraResult`.

  #### Returns DijkstraResult<V>

  Inherited from DirectedGraph.dijkstra

  - Defined in src/data-structures/graph/abstract-graph.ts:596

### dijkstraWithoutHeap

- dijkstraWithoutHeap(src, dest?, getMinDist?, genPaths?): DijkstraResult<V>

- Dijkstra algorithm time: O(VE) space: O(V + E) /

  /** Dijkstra algorithm time: O(VE) space: O(V + E) The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in a graph without using a heap data structure.

  #### Parameters

  - ##### src: VertexId | V

    The source vertex from which to start the Dijkstra's algorithm. It can be either a vertex object or a vertex ID.

  - ##### `Optional` dest: null | VertexId | V

    The `dest` parameter in the `dijkstraWithoutHeap` function is an optional parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its identifier. If no destination is provided, the value is set to `null`.

  - ##### `Optional` getMinDist: boolean

    The `getMinDist` parameter is a boolean flag that determines whether the minimum distance from the source vertex to the destination vertex should be calculated and returned in the result. If `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance

  - ##### `Optional` genPaths: boolean

    The `genPaths` parameter is a boolean flag that determines whether or not to generate 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 @returns The function` dijkstraWithoutHeap`returns an object of type`DijkstraResult`.

  #### Returns DijkstraResult<V>

  Inherited from DirectedGraph.dijkstraWithoutHeap

  - Defined in src/data-structures/graph/abstract-graph.ts:456

### edgeSet

- edgeSet(): E[]

- The `edgeSet` function returns an array of all the edges in the graph.

  #### Returns E[]

  The `edgeSet()` method returns an array of edges (`E[]`).

  Inherited from DirectedGraph.edgeSet

  - Defined in src/data-structures/graph/directed-graph.ts:377

### edgesOf

- edgesOf(vertexOrId): E[]

- The function "edgesOf" returns an array of both outgoing and incoming edges of a given vertex or vertex ID.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a `VertexId` or a `V`.

  #### Returns E[]

  The function `edgesOf` returns an array of edges.

  Inherited from DirectedGraph.edgesOf

  - Defined in src/data-structures/graph/directed-graph.ts:284

### floyd

- floyd(): {
  costs: number[][];
  predecessor: (null | V)[][];
  }

- Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle all pairs /

  /** Floyd algorithm time: O(V^3) space: O(V^2), not support graph with negative weight cycle 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 graph.

  #### Returns {
  costs: number[][];
  predecessor: (null | V)[][];
  }

  The function `floyd()` 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 `null`) representing the predecessor vertices in the shortest path between vertices in the

  - ##### costs: number[][]

  - ##### predecessor: (null | V)[][]

  Inherited from DirectedGraph.floyd

  - Defined in src/data-structures/graph/abstract-graph.ts:851

### getAllPathsBetween

- getAllPathsBetween(v1, v2): V[][]

- The function `getAllPathsBetween` finds all paths between two vertices in a graph using depth-first search.

  #### Parameters

  - ##### v1: VertexId | V

    The parameter `v1` represents either a vertex object (`V`) or a vertex ID (`VertexId`). It is the starting vertex for finding paths.

  - ##### v2: VertexId | V

    The parameter `v2` represents either a vertex object (`V`) or a vertex ID (`VertexId`).

  #### Returns V[][]

  The function `getAllPathsBetween` returns an array of arrays of vertices (`V[][]`).

  Inherited from DirectedGraph.getAllPathsBetween

  - Defined in src/data-structures/graph/abstract-graph.ts:268

### getDestinations

- getDestinations(vertex): V[]

- The function `getDestinations` returns an array of destination vertices connected to a given vertex.

  #### Parameters

  - ##### vertex: null | VertexId | V

    The `vertex` parameter represents the starting vertex from which we want to find the destinations. It can be either a `V` object, a `VertexId` value, or `null`.

  #### Returns V[]

  an array of vertices (V[]).

  Inherited from DirectedGraph.getDestinations

  - Defined in src/data-structures/graph/directed-graph.ts:312

### getEdge

- getEdge(srcOrId, destOrId): null | E

- The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.

  #### Parameters

  - ##### srcOrId: null | VertexId | V

    The source vertex or its ID. It can be either a vertex object or a vertex ID.

  - ##### destOrId: null | VertexId | V

    The `destOrId` parameter in the `getEdge` function represents the destination vertex of the edge. It can be either a vertex object (`V`), a vertex ID (`VertexId`), or `null` if the destination is not specified.

  #### Returns null | E

  the first edge found between the source and destination vertices, or null if no such edge is found.

  Inherited from DirectedGraph.getEdge

  - Defined in src/data-structures/graph/directed-graph.ts:133

### getEdgeDest

- getEdgeDest(e): null | V

- The function "getEdgeDest" returns the destination vertex of an edge.

  #### Parameters

  - ##### e: E

    The parameter "e" is of type "E", which represents an edge in a graph.

  #### Returns null | V

  either a vertex object of type V or null.

  Inherited from DirectedGraph.getEdgeDest

  - Defined in src/data-structures/graph/directed-graph.ts:302

### getEdgeSrc

- getEdgeSrc(e): null | V

- The function "getEdgeSrc" returns the source vertex of an edge, or null if the edge does not exist.

  #### Parameters

  - ##### e: E

    The parameter "e" is of type E, which represents an edge in a graph.

  #### Returns null | V

  either a vertex object (V) or null.

  Inherited from DirectedGraph.getEdgeSrc

  - Defined in src/data-structures/graph/directed-graph.ts:293

### getEndsOfEdge

- getEndsOfEdge(edge): null | [V, V]

- The function "getEndsOfEdge" returns the source and destination vertices of an edge if it exists in the graph, otherwise it returns null.

  #### Parameters

  - ##### edge: E

    The parameter `edge` is of type `E`, which represents an edge in a graph.

  #### Returns null | [V, V]

  The function `getEndsOfEdge` returns an array containing two vertices `[V, V]` if the edge exists in the graph. If the edge does not exist, it returns `null`.

  Inherited from DirectedGraph.getEndsOfEdge

  - Defined in src/data-structures/graph/directed-graph.ts:414

### getMinCostBetween

- getMinCostBetween(v1, v2, isWeight?): null | number

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

  #### Parameters

  - ##### v1: VertexId | V

    The parameter `v1` represents the starting vertex or its ID.

  - ##### v2: VertexId | V

    The parameter `v2` represents the destination vertex or its ID. It is the vertex to which you want to find the minimum cost or weight from the source vertex `v1`.

  - ##### `Optional` isWeight: boolean

    isWeight is an optional parameter that indicates whether the graph edges 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 null | number

  The function `getMinCostBetween` returns a number representing the minimum cost between two vertices (`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 minimum number of

  Inherited from DirectedGraph.getMinCostBetween

  - Defined in src/data-structures/graph/abstract-graph.ts:326

### getMinPathBetween

- getMinPathBetween(v1, v2, isWeight?): null | V[]

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

  #### Parameters

  - ##### v1: VertexId | V

    The parameter `v1` represents the starting vertex of the path. It can be either a vertex object (`V`) or a vertex ID (`VertexId`).

  - ##### v2: VertexId | V

    V | VertexId - The second vertex or vertex ID between which we want to find the minimum path.

  - ##### `Optional` isWeight: boolean

    A boolean flag indicating whether to consider the weight of edges in finding the minimum path. If set to true, the function will use Dijkstra's algorithm to find the minimum weighted path. If set to false, the function will use breadth-first search (BFS) to find the minimum path.

  #### Returns null | V[]

  The function `getMinPathBetween` returns an array of vertices (`V[]`) representing the minimum path between two vertices (`v1` and `v2`). If there is no path between the vertices, it returns `null`.

  Inherited from DirectedGraph.getMinPathBetween

  - Defined in src/data-structures/graph/abstract-graph.ts:384

### getNeighbors

- getNeighbors(vertexOrId): V[]

- The function `getNeighbors` returns an array of neighboring vertices of a given vertex or vertex ID in a graph.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID (`VertexId`).

  #### Returns V[]

  an array of vertices (V[]).

  Inherited from DirectedGraph.getNeighbors

  - Defined in src/data-structures/graph/directed-graph.ts:391

### getPathSumWeight

- getPathSumWeight(path): number

- The function calculates the sum of weights along a given path.

  #### Parameters

  - ##### path: V[]

    An array of vertices (V) representing a path in a graph.

  #### Returns number

  The function `getPathSumWeight` returns the sum of the weights of the edges in the given path.

  Inherited from DirectedGraph.getPathSumWeight

  - Defined in src/data-structures/graph/abstract-graph.ts:304

### getVertex

- getVertex(vertexId): null | V

- The function "getVertex" returns the vertex with the specified ID or null if it doesn't exist.

  #### Parameters

  - ##### vertexId: VertexId

    The `vertexId` parameter is the identifier of the vertex that you want to retrieve from the `_vertices` map.

  #### Returns null | V

  The method `getVertex` returns the vertex with the specified `vertexId` if it exists in the `_vertices` map. If the vertex does not exist, it returns `null`.

  Inherited from DirectedGraph.getVertex

  - Defined in src/data-structures/graph/abstract-graph.ts:154

### hasEdge

- hasEdge(v1, v2): boolean

- The function checks if there is an edge between two vertices and returns a boolean value indicating the result.

  #### Parameters

  - ##### v1: VertexId | V

    The parameter v1 can be either a VertexId or a V. A VertexId represents the unique identifier of a vertex in a graph, while V represents the type of the vertex object itself.

  - ##### v2: VertexId | V

    The parameter `v2` represents the second vertex in the edge. It can be either a `VertexId` or a `V` type, which represents the type of the vertex.

  #### Returns boolean

  A boolean value is being returned.

  Inherited from DirectedGraph.hasEdge

  - Defined in src/data-structures/graph/abstract-graph.ts:215

### hasVertex

- hasVertex(vertexOrId): boolean

- The function checks if a vertex exists in a graph.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID (`VertexId`).

  #### Returns boolean

  a boolean value.

  Inherited from DirectedGraph.hasVertex

  - Defined in src/data-structures/graph/abstract-graph.ts:164

### inDegreeOf

- inDegreeOf(vertexOrId): number

- The function "inDegreeOf" returns the number of incoming edges for a given vertex.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a `VertexId` or a `V`.

  #### Returns number

  The number of incoming edges of the specified vertex or vertex ID.

  Inherited from DirectedGraph.inDegreeOf

  - Defined in src/data-structures/graph/directed-graph.ts:266

### incomingEdgesOf

- incomingEdgesOf(vertexOrId): E[]

- The function `incomingEdgesOf` returns an array of incoming edges for a given vertex or vertex ID.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID (`VertexId`).

  #### Returns E[]

  The method `incomingEdgesOf` returns an array of edges (`E[]`).

  Inherited from DirectedGraph.incomingEdgesOf

  - Defined in src/data-structures/graph/directed-graph.ts:230

### outDegreeOf

- outDegreeOf(vertexOrId): number

- The function `outDegreeOf` returns the number of outgoing edges from a given vertex.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a `VertexId` or a `V`.

  #### Returns number

  The number of outgoing edges from the specified vertex or vertex ID.

  Inherited from DirectedGraph.outDegreeOf

  - Defined in src/data-structures/graph/directed-graph.ts:275

### outgoingEdgesOf

- outgoingEdgesOf(vertexOrId): E[]

- The function `outgoingEdgesOf` returns an array of outgoing edges from a given vertex or vertex ID.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can accept either a vertex object (`V`) or a vertex ID (`VertexId`).

  #### Returns E[]

  The method `outgoingEdgesOf` returns an array of edges (`E[]`).

  Inherited from DirectedGraph.outgoingEdgesOf

  - Defined in src/data-structures/graph/directed-graph.ts:244

### removeAllVertices

- removeAllVertices(vertices): boolean

- The function removes all vertices from a graph and returns a boolean indicating if any vertices were removed.

  #### Parameters

  - ##### vertices: VertexId[] | V[]

    The `vertices` parameter can be either an array of vertices (`V[]`) or an array of vertex IDs (`VertexId[]`).

  #### Returns boolean

  a boolean value. It returns true if at least one vertex was successfully removed, and false if no vertices were removed.

  Inherited from DirectedGraph.removeAllVertices

  - Defined in src/data-structures/graph/abstract-graph.ts:199

### removeEdge

- removeEdge(edge): null | E

- The function removes an edge from a graph and returns the removed edge, or null if the edge was not found.

  #### Parameters

  - ##### edge: E

    The `edge` parameter is an object that represents an edge in a graph. It has two properties: `src` and `dest`, which represent the source and destination vertices of the edge, respectively.

  #### Returns null | E

  The method `removeEdge` returns the removed edge (`E`) if it exists, or `null` if the edge does not exist.

  Inherited from DirectedGraph.removeEdge

  - Defined in src/data-structures/graph/directed-graph.ts:183

### removeEdgeSrcToDest

- removeEdgeSrcToDest(srcOrId, destOrId): null | E

- The function removes an edge between two vertices in a graph and returns the removed edge.

  #### Parameters

  - ##### srcOrId: VertexId | V

    The source vertex or its ID.

  - ##### destOrId: VertexId | V

    The `destOrId` parameter represents the destination vertex or its ID.

  #### Returns null | E

  the removed edge (E) if it exists, or null if either the source or destination vertex does not exist.

  Inherited from DirectedGraph.removeEdgeSrcToDest

  - Defined in src/data-structures/graph/directed-graph.ts:157

### removeEdgesBetween

- removeEdgesBetween(v1, v2): E[]

- The function removes edges between two vertices and returns the removed edges.

  #### Parameters

  - ##### v1: VertexId | V

    The parameter `v1` can be either a `VertexId` or a `V`. A `VertexId` represents the unique identifier of a vertex in a graph, while `V` represents the actual vertex object.

  - ##### v2: VertexId | V

    The parameter `v2` represents either a `VertexId` or a `V` object. It is used to specify the second vertex in the edge that needs to be removed.

  #### Returns E[]

  an array of removed edges (E[]).

  Inherited from DirectedGraph.removeEdgesBetween

  - Defined in src/data-structures/graph/directed-graph.ts:210

### removeVertex

- removeVertex(vertexOrId): boolean

- The `removeVertex` function removes a vertex from a graph by its ID or by the vertex object itself.

  #### Parameters

  - ##### vertexOrId: VertexId | V

    The parameter `vertexOrId` can be either a vertex object (`V`) or a vertex ID (`VertexId`).

  #### Returns boolean

  The method is returning a boolean value.

  Inherited from DirectedGraph.removeVertex

  - Defined in src/data-structures/graph/abstract-graph.ts:187

### setEdgeWeight

- setEdgeWeight(srcOrId, destOrId, weight): boolean

- The function sets the weight of an edge between two vertices in a graph.

  #### Parameters

  - ##### srcOrId: VertexId | V

    The `srcOrId` parameter can be either a `VertexId` or a `V` object. It represents the source vertex of the edge.

  - ##### destOrId: VertexId | V

    The `destOrId` parameter represents the destination vertex of the edge. It can be either a `VertexId` or a vertex object `V`.

  - ##### weight: number

    The weight parameter represents the weight of the edge between the source vertex (srcOrId) and the destination vertex (destOrId).

  #### Returns boolean

  a boolean value. If the edge exists between the source and destination vertices, the function will update the weight of the edge and return true. If the edge does not exist, the function will return false.

  Inherited from DirectedGraph.setEdgeWeight

  - Defined in src/data-structures/graph/abstract-graph.ts:251

### tarjan

- tarjan(needArticulationPoints?, needBridges?, needSCCs?, needCycles?): {
  SCCs: Map<number, V[]>;
  articulationPoints: V[];
  bridges: E[];
  cycles: Map<number, V[]>;
  dfnMap: Map<V, number>;
  lowMap: Map<V, number>;
  }

- Tarjan is an algorithm based on DFS,which is used to solve the connectivity problem of 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 solve the bi-connected components of undirected graphs; Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs. /

  /** Tarjan is an algorithm based on DFS,which is used to solve the connectivity problem of 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 solve the bi-connected components of undirected graphs; Tarjan can find the SSC(strongly connected components), articulation points, and bridges of directed graphs. The `tarjan` function is used to perform various graph analysis tasks such as finding articulation points, bridges, strongly connected components (SCCs), and cycles in a graph.

  #### Parameters

  - ##### `Optional` needArticulationPoints: boolean

    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 number of connected components in the graph.

  - ##### `Optional` needBridges: boolean

    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).

  - ##### `Optional` needSCCs: boolean

    A boolean value indicating whether the Strongly Connected Components (SCCs) of the graph are needed. If set to true, the function will calculate and return the SCCs of the graph. If set to false, the SCCs will not be calculated or returned.

  - ##### `Optional` needCycles: boolean

    A boolean flag indicating whether the algorithm should find cycles in the graph. If 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.

  #### Returns {
  SCCs: Map<number, V[]>;
  articulationPoints: V[];
  bridges: E[];
  cycles: Map<number, V[]>;
  dfnMap: Map<V, number>;
  lowMap: Map<V, number>;
  }

  The function `tarjan` returns an object with the following properties:

  - ##### SCCs: Map<number, V[]>

  - ##### articulationPoints: V[]

  - ##### bridges: E[]

  - ##### cycles: Map<number, V[]>

  - ##### dfnMap: Map<V, number>

  - ##### lowMap: Map<V, number>

  Inherited from DirectedGraph.tarjan

  - Defined in src/data-structures/graph/abstract-graph.ts:915

### topologicalSort

- topologicalSort(propertyName?): null | (VertexId | V)[]

- The `topologicalSort` function performs a topological sort on a graph and returns an array of vertices or vertex IDs in the sorted order, or null if the graph contains a cycle.

  #### Parameters

  - ##### `Optional` propertyName: "id" | "vertex"

    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 'id'. If 'vertex' is specified, the vertices themselves will be used for sorting. If 'id' is specified, the ids of

  #### Returns null | (VertexId | V)[]

  an array of vertices or vertex IDs in topological order. If there is a cycle in the graph, it returns null.

  Inherited from DirectedGraph.topologicalSort

  - Defined in src/data-structures/graph/directed-graph.ts:335

Generated using TypeDoc