The data source containing all vertices and edges, using a Map as adjacency list.
The default weight value to add to the edges.
Whether edges should be added in both direction.
The number of vertices.
The number of edges.
Adds an edge between two vertices with an optional weight. The order of
from
and to
parameters only matters if the graph is directed.
It fails if a vertex is not found or when trying to add an already
existing edge.
The origin vertex of the edge.
The destination vertex of the edge.
The edge weight.
true
or false
if insertion failed.
Adds a new vertex, referenced with a unique id, of given value. If the given id is already used, the insertion is aborted.
The vertex ID. Must be unique
The vertex value.
true
or false
if it failed to insert.
Adds new vertices from given tuples [id, value]
The tuples separated by a comma
The number of added vertices.
Internal helper providing recurrent checks on a specific edge before performing an operation.
The origin vertex of the edge.
The destination vertex of the edge.
{
srcVertex
: (Vertex) Vertex match for from
dstVertex
: (Vertex) Vertex match for to
isSafeAdd
: (boolean)
isSafeRem
: (boolean)
}
Returns an array of all edges.
An array of Edge
.
Retrieves the vertex corresponding to given id.
The vertex id.
Vertex
or undefined
if not found.Retrieves an edge connecting two vertices. The parameters order only matter in the case of a directed graph.
The origin vertex id.
The destination vertex id.
Edge
or undefined
if not found.Retrieves the edge between two vertices and returns its weight.
The order of from
and to
parameters only matters if the graph
is directed.
It fails if no edge is found (missing vertex or vertices not
connected).
The origin vertex of the edge.
The destination vertex of the edge.
The weight value of the edge or undefined
if it failed
to retrieve the edge.
Reduces all vertices to a single value using the ginven reduce
function.
The ReduceFunction
to apply on each vertex.
The starting value.
The value resulting of the result function.
Removes the edge between two vertices. The order of from
and to
parameters only matters if the graph is directed.
It fails if a vertex is not found or when trying to remove an inexistent
edge.
The origin vertex of the edge.
The destination vertex of the edge.
true
or false
if it failed to remove an edge.
Removes vertex qith given id and its related edges.
id of the vertex to be removed.
true
or false
if the vertex is not found.
Removes all related edges to a vertex. Its value persists.
id if the vertex to be removed.
true
or false
if the vertex is not found.
Sets the default weight on edge insertion to the given value.
The replacing weight value .
Retrieves the edge between two vertices and sets its weight.
The order of from
and to
parameters only matters if the graph
is directed.
It fails if no edge is found (missing vertex or vertices not
connected).
The origin vertex of the edge.
The destination vertex of the edge.
true
or false
if it failed to retrieve the edge.
Returns an array of Vertex<T>
representing the steps of
the shortest path from position from
to position to
.
It uses Dijktsra's algorithm.
The starting vertex id.
The destination vertex id.
An optional filter function applied on vertices to restrict or not their usage.
An array of Vertex<T>
Returns an array of all vertices.
An array of Vertex
.
Generated using TypeDoc
A Graph implementation based on an Adjacency list. In its current implementation, it is weighted (with a default value of
1
, allowing to not care about it if it is not needed), and can be optionnaly directed if specified in the constructor options.