Vertex value type.
Edge value type.
Concrete vertex class (extends AbstractVertex
Concrete edge class (extends AbstractEdge
Construct a directed graph with runtime defaults.
Optionaloptions: Partial<GraphOptions<V>>GraphOptions<V> (e.g. vertexValueInitializer, defaultEdgeWeight).
Protected_addInternal hook to attach a directed edge into adjacency maps.
Edge instance.
true if inserted; 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 a directed edge instance. Does not insert into the graph.
Source vertex key.
Destination vertex key.
Optionalweight: numberEdge weight; defaults to defaultEdgeWeight.
Optionalvalue: EEdge payload.
Concrete edge instance.
Degree (in + out) of a vertex.
Vertex or key.
Non-negative integer.
Delete an edge by instance or by (srcKey, destKey).
Edge instance or source vertex/key.
OptionaldestVertexKey: VertexKeyOptional destination vertex/key when deleting by pair.
Removed edge or undefined.
Delete a vertex and its incident edges.
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.
Topological sort if DAG; returns undefined if a cycle exists.
OptionalpropertyName: "key" | "vertex"'key' to map to keys; 'vertex' to keep instances.
Array of keys/vertices, or undefined when cycle is found.
StaticfromConstruct a directed graph from [key, value] entries.
Iterable of [key, value] pairs.
DirectedGraph with all vertices added.
StaticfromConstruct a directed graph from keys with value initializer v => v.
Iterable of vertex keys.
DirectedGraph with all keys added.
Directed graph implementation.
Remarks
Time O(1), Space O(1)
Example