Graph82
Constructors
Models
AllPairsResultinterfaceResult of an all-pairs shortest path computation.AstarConfiginterfaceConfiguration for finding a shortest path with the A algorithm.BellmanFordConfiginterfaceConfiguration for finding a shortest path with the Bellman-Ford algorithm.DijkstraConfiginterfaceConfiguration for finding a shortest path with Dijkstra's algorithm.DirectedGraphtypeImmutable graph type for source-to-target relationships.DirectiontypeDirection for graph traversal, indicating which edges to follow.EdgeclassRepresents edge data containing source, target, and user data.EdgeIndextypeEdge index for edge identification using plain numbers.EdgeWalkertypeType alias for edge iteration using Walker.ExternalsConfiginterfaceConfiguration for selecting external nodes.GraphinterfaceImmutable graph interface.KindtypeGraph type for distinguishing directed and undirected graphs.MermaidDiagramTypetypeMermaid diagram types for different visualization formats.MermaidDirectiontypeMermaid diagram direction types for controlling layout orientation.MermaidNodeShapetypeMermaid node shape types for diagram visualization.MutableDirectedGraphtypeMutable directed graph type alias.MutableGraphinterfaceMutable graph interface.MutableUndirectedGraphtypeMutable undirected graph type alias.NodeIndextypeNode index for node identification using plain numbers.NodeWalkertypeType alias for node iteration using Walker.PathResultinterfaceResult of a shortest path computation.ProtointerfaceCommon structural interface shared by immutable and mutable graphs.SearchConfiginterfaceConfiguration for DFS, BFS, and postorder graph traversals.TopoConfiginterfaceConfiguration for the topological sort iterator.UndirectedGraphtypeImmutable graph type for relationships without source-to-target direction.WalkerclassRepresents an iterable wrapper used by graph traversal and listing APIs.Guards
Getters
edgeCountconstReturns the number of edges in the graph.findEdgeconstFinds the first edge that matches the given predicate.findEdgesconstFinds all edges that match the given predicate.findNodeconstFinds the first node that matches the given predicate.findNodesconstFinds all nodes that match the given predicate.getEdgeconstGets the edge data associated with an edge index safely, if it exists.getNodeconstGets the data associated with a node index safely, if it exists.hasEdgeconstChecks whether an edge exists between two nodes in the graph.hasNodeconstChecks whether a node with the given index exists in the graph.neighborsconstReturns the neighboring node indices for a node.nodeCountconstReturns the number of nodes in the graph.Mutations
addEdgeconstAdds a new edge to a mutable graph and returns its index.addNodeconstAdds a new node to a mutable graph and returns its index.beginMutationconstCreates a mutable scope for safe graph mutations by copying the data structure.endMutationconstConverts a mutable graph back to an immutable graph, ending the mutation scope.mutateconstPerforms scoped mutations on a graph, automatically managing the mutation lifecycle.removeEdgeconstRemoves an edge from a mutable graph.removeNodeconstRemoves a node and all its incident edges from a mutable graph.updateEdgeconstUpdates a single edge's data by applying a transformation function.Errors
Algorithms
astarconstFinds the shortest path from the configured source node to the target node using the A pathfinding algorithm.bellmanFordconstFinds the shortest path from the configured source node to the target node using the Bellman-Ford algorithm.connectedComponentsconstFinds connected components in an undirected graph.dijkstraconstFinds the shortest path from the configured source node to the target node using Dijkstra's algorithm.floydWarshallconstFinds shortest paths between all pairs of nodes using the Floyd-Warshall algorithm.isAcyclicconstChecks whether the graph is acyclic (contains no cycles).isBipartiteconstChecks whether an undirected graph is bipartite.stronglyConnectedComponentsconstFinds strongly connected components in a directed graph using Kosaraju's algorithm.Converting
Iterators
bfsconstCreates a lazy breadth-first traversal iterator from the configured start nodes.dfsconstCreates a lazy depth-first traversal iterator from the configured start nodes.dfsPostOrderconstCreates a lazy depth-first postorder traversal iterator from the configured start nodes.edgesconstCreates an iterator over all edge indices in the graph.entriesconstReturns an iterator over [index, data] entries in the walker.externalsconstCreates an iterator over external nodes (nodes without edges in the specified direction).indicesconstReturns an iterator over the indices in the walker.nodesconstCreates an iterator over all node indices in the graph.topoconstCreates a new topological sort iterator with optional configuration.valuesconstReturns an iterator over the values (data) in the walker.Options
Queries
Transforming
filterEdgesconstFilters edges by removing those that don't match the predicate.filterMapEdgesconstFilters and optionally transforms edges in a mutable graph using a predicate function.filterMapNodesconstFilters and optionally transforms nodes in a mutable graph using a predicate function.filterNodesconstFilters nodes by removing those that don't match the predicate.mapEdgesconstTransforms all edge data in a mutable graph using the provided mapping function.mapNodesconstTransforms every node's data in a mutable graph in place using the provided mapping function.reverseconstSwaps source and target nodes for every edge in a mutable graph.updateNodeconstUpdates a single node's data by applying a transformation function.