Repository navigation
v2.5.0
Minor Changes
-
#43
e87aceeThanks @davidkpiano! - Tighten algorithm contracts:- Breaking:
getMinCuttakes{ from, to }(was{ source, sink }) and returnscutEdgesas edge objects, matchinggetMaxFlow. - Breaking: unknown node ids are "not found" instead of errors or fabricated results.
getMaxFlow,getMinCut, andgetSteinerTreereturnundefined(getSteinerTreealso when the terminals are disconnected),getDominatorTreereturns{},hasPath(g, x, x)isfalsefor an unknownx, and path queries no longer yield a trivial self-path for an unknown source. - Breaking:
getDegreecounts every self-loop twice, including non-directed ones, so degrees sum to2 × edges.length. hasPathaccepts{ direction }and runs on the CSR snapshot.isAcyclicis iterative, so deep graphs no longer overflow the call stack, runs in O(n + m) for graphs mixing directed and non-directed edges (previously exponential in the worst case), and is cached until the graph changes.genCyclesis now lazy: Johnson's algorithm per biconnected block, iterative, O((n + m) · (cycles + 1)). Taking the first cycle of a dense graph no longer enumerates all of them first, and long cycles no longer overflow the call stack. Cycle order may differ.- New
getCyclereturns one cycle (orundefined) in O(n + m). - Breaking:
isTreereturnsfalsefor the empty graph. It ignores edge direction (a → c ← bis a tree). - New
isArborescencechecks for a rooted tree whose edges all point away from the root, optionally at{ from }. - New
genTopologicalSort; both topological sorts accept{ from }to emit chosen nodes first. - Lazy generators (
genShortestPaths,genSimplePaths,genCycles,genAllPairsShortestPaths,genShortestSimplePaths,genPreorders,genPostorders,genGirvanNewmanCommunities) no longer return wrong results or crash when the graph is mutated mid-iteration. - Breaking:
getDepthreturnsundefined(was-1) for an unknown node, andisLeaf/isCompoundreturnfalsefor one. isIsomorphicis a VF2-style matcher: breadth-first matching order, candidates from neighbors of matched nodes, O(degree) checks, iterative. Large sparse graphs that previously never finished now take milliseconds. It also no longer pairs a directed self-loop with a non-directed one, and pairs parallel edges exactly underedgeMatchinstead of greedily.- No more call-stack overflows on deep inputs:
genSimplePaths/getSimplePath, tied shortest-path reconstruction (genShortestPaths, Floyd–Warshall),getDescendants,deleteNodecascades,getFlattenedGraph,getTransitiveReduction, and maximum bipartite matching are iterative. genPreorders/genPostordersbacktrack with an undo log instead of copying state per step (a chain no longer costs O(n²)), and no longer drop orders that end at a dangling edge.getPreorderno longer rescans neighbors when returning to a node.getTransitiveReductionno longer crashes on an edge from a missing node.- Fix a memory leak: the graph index no longer keeps a
WeakRefmemo, which kept every graph indexed during one synchronous call alive until it returned (e.g. ~2.8 GB forgetShortestSimplePathson a 3,000-node chain, now ~200 MB). getModularityruns in O(n + m) (was quadratic in community size), ignores dangling edges, and tolerates unknown ids in communities.getFlattenedGraphruns in linear time on deep hierarchies (was quadratic) by resolving leaf ranges and initial states once.getMaxFlow/getMinCutandgetGreedyModularityCommunitiesno longer crash on dangling edges; random walks no longer step onto them.- Breaking:
getTSPTourreturnsundefinedfor an unknownfrom(previously started at the first node);genPredefinedWalkyields nothing from an unknown start;getCoverageno longer counts an unknown start node as visited.
- Breaking:
-
#39
047e583Thanks @davidkpiano! - Add@statelyai/graph/xstatewithcreateGraphFromMachine(machine, options?): one machine→graph path that enumerates events from the machine's own descriptors, serializes nodes as{ value, context }(same ids asxstate/graph), and attaches guard text (hypothesized: true), actions, and selected transition definitions to edges.getCoverageTargetson the result yields stable state / transition / transition-pair targets.xstatev5 is an optional peer dependency.
Patch Changes
-
#40
898a277Thanks @davidkpiano! - Preserve quoted Mermaid state stereotypes and flowchart labels while expanding compact links and semicolon-separated statements correctly. -
#42
db0f3e5Thanks @davidkpiano! - ExportFlowchartClickfrom the Mermaid subpath and document literal Mermaid data fields.