Vertex value type.
Edge value type.
Concrete vertex class (extends AbstractVertex
Concrete edge class (extends AbstractEdge
Construct an undirected graph with runtime defaults.
Optionaloptions: Partial<GraphOptions<V>>GraphOptions<V> (e.g. vertexValueInitializer, defaultEdgeWeight).
Protected_addInternal hook to attach an undirected edge into adjacency maps.
Edge instance.
true if both endpoints exist; otherwise false.
Protected_addInsert a pre-built vertex into the graph.
Concrete vertex instance.
true if inserted; false if key already exists.
Protected_createProtected_createCreate a same-species graph populated with entries; preserves edges among kept vertices.
Optionaliter: Iterable<[VertexKey, undefined | V], any, any>Optional entries to seed the new graph.
Optionaloptions: Partial<Record<string, unknown>>Snapshot options.
A new graph of this type.
Protected_getProtected_getProtected_getResolve a vertex key from a key or vertex instance.
Vertex key or existing vertex.
The vertex key.
Protected_snapshotBellman-Ford single-source shortest paths with option to scan negative cycles.
Source vertex or key.
OptionalscanNegativeCycle: booleanIf true, also detect negative cycles.
OptionalgetMin: booleanIf true, compute global minimum distance.
OptionalgenPath: booleanIf true, generate path arrays via predecessor map.
Result bag including distances, predecessors, and optional cycle flag.
Create an undirected edge instance. Does not insert into the graph.
One endpoint key.
The other endpoint key.
Optionalweight: numberEdge weight; defaults to defaultEdgeWeight.
Optionalvalue: EO["value"]Edge payload.
Concrete edge instance.
Degree of a vertex (# of incident undirected edges).
Vertex or key.
Non-negative integer.
Delete an edge by instance or by a pair of keys.
Edge instance or one endpoint vertex/key.
OptionalotherSideVertexKey: VertexKeyRequired second endpoint when deleting by pair.
Removed edge or undefined.
Delete a vertex and remove it from all neighbor lists.
Vertex or key.
true if removed; otherwise false.
Test whether all entries satisfy the predicate.
(key, value, index, self) => boolean.
OptionalthisArg: anyOptional this for callback.
true if all pass; otherwise false.
Induced-subgraph filter: keep vertices where predicate(key, value) is true,
and only keep edges whose endpoints both survive.
(key, value, index, self) => boolean.
OptionalthisArg: anyOptional this for callback.
A new graph of the same concrete class (this type).
Find the first entry that matches a predicate.
(key, value, index, self) => boolean.
OptionalthisArg: anyOptional this for callback.
Matching [key, value] or undefined.
Visit each entry, left-to-right.
(key, value, index, self) => void.
OptionalthisArg: anyOptional this for callback.
Sum the weights along a vertex path.
Sequence of vertices.
Path weight sum (0 if empty or edge missing).
Whether there exists an entry with the given value.
Value to test.
true if found; otherwise false.
Whether a vertex exists.
Vertex or key.
true if present, otherwise false.
Delete multiple vertices.
Array of vertices or keys.
true if any vertex was removed.
Test whether any entry satisfies the predicate.
(key, value, index, self) => boolean.
OptionalthisArg: anyOptional this for callback.
true if any passes; otherwise false.
StaticfromConstruct an undirected graph from [key, value] entries.
Iterable of [key, value] pairs.
UndirectedGraph with all vertices added.
StaticfromConstruct an undirected graph from keys with value initializer v => v.
Iterable of vertex keys.
UndirectedGraph with all keys added.
Undirected graph implementation.
Remarks
Time O(1), Space O(1)
Example