Algorithm Library

The eighth and outermost of ArcFlow's eight layers. Owns the built-in procedure surface — graph algorithms, vector search, RAG primitives, GPU-accelerated kernels — every one invoked by name through the standard CALL syntax.

If the Query Engine is the parser-planner-executor for general-purpose Cypher, the Algorithm Library is the catalogue of named operations the engine ships out of the box. PageRank, BFS, shortest path, Leiden community detection, HNSW vector probes, cosine similarity, embedding-aware procedures — all reachable through one consistent invocation shape:

CALL algo.pageRank() YIELD node, score
RETURN node.name, score ORDER BY score DESC LIMIT 10

What the library provides#

FamilyExamplesProcedure namespace
Graph algorithmsPageRank, BFS, DFS, shortest path, connected components, Leiden, LouvainCALL algo.*
Causal reasoningBFS over CAUSED_BY with cumulative confidence; shortest causal chain; ancestry / delta / root / fanoutCALL arcflow.causalLineage(), CALL arcflow.causalPath(), CALL arcflow.causalAncestry(), CALL arcflow.causalDelta(), CALL arcflow.causalRoot(), CALL arcflow.causalFanout()
Multi-source disagreementCategorical / numeric / spatial weighted-median resolution across sourcesCALL arcflow.multi_source_disagreement()
Trajectory analyticsNearest-at-frame, leverage gain, release point, line-of-sight shadowCALL arcflow.trajectory.*
Counterfactual branchingBranch the World Graph at a WAL seq for hypothetical rolloutsCALL arcflow.counterfactual.branchAt()
Statistical testsChi-square goodness-of-fit, Mann-Whitney U, Kolmogorov-SmirnovCALL arcflow.chiSquare(), CALL arcflow.mannWhitneyU(), CALL arcflow.kolmogorovSmirnov()
Bias detectionSubstrate-native composer — group a typed label by category, run a test, return per-group statistic + p-value. Optional confidence_weight argument weights per-row contributions by _confidence (or any numeric property) so low-credibility observations don't anchor the group statistic.CALL arcflow.biasDetection(label, group_by, target, test?, confidence_weight?) (chi-square / mann_whitney_u / kolmogorov_smirnov)
Spatial autocorrelationMoran's I global statistic — are spatially-near nodes correlated, dispersed, or random in a chosen scalar? Plus LISA per-node hot-spot mapping and Getis-Ord G* per-node z-score for explain-then-locate. Optional confidence_weight? arg on Moran's I weights per-node contributions by _confidence or any numeric property.CALL arcflow.moransI(label, coords_property, value_property, k?, confidence_weighted?), CALL arcflow.localMoransI(label, coords_property, value_property, k?, significance_threshold?), CALL arcflow.getisOrdGStar(label, coords_property, value_property, k?, significance_threshold?)
Spatial point-patternMulti-radius point-density analysis — Ripley's K across N radii to characterise clustering vs CSR vs dispersion at each scale.CALL arcflow.ripleysK(label, ...)
Anomaly detectionDensity-based per-node outlier scoring — Local Outlier Factor surfaces points whose local density is materially lower than their neighbours'.CALL arcflow.localOutlierFactor(label, ...)
Vector primitivesCosine, dot product, embedarcflow.cosine(), arcflow.embed()
Vector searchHNSW similarity probeCALL arcflow.similar()
Graph-aware retrievalMulti-hop RAG with citation provenanceCALL arcflow.graphrag()
SpatialR*-tree probes, nearest-neighbour, range queryCALL algo.nearestNodes()
WorkflowDurable workflows over a graphextension family
IntrospectionEngine capabilities, GPU status, query plansCALL db.*

The complete surface is enumerated in the Procedures reference; the full algorithm catalogue with worked examples lives at Graph Algorithms. This page documents the layer — why it exists, where it sits, and what guarantees it offers.

Why algorithms are a separate layer#

A graph algorithm could be an external library that walks the graph through the client SDK. That works for one-off scripts, but at the engine layer four properties stop being optional:

  • No projection. The algorithm runs against the live in-memory adjacency. There is no "project the graph into a separate analytical store first" step.
  • Backend dispatch. PageRank on CPU, PageRank on Metal, PageRank on CUDA — same procedure name. The engine picks the backend per host capability and reports the choice through db.capabilities(). No silent downgrade.
  • Typed results. A procedure returns typed columns: numbers stay numbers, node references stay node references. Agents do not parse strings.
  • Composability. CALL algo.* results pipe into the rest of the Cypher pipeline — WHERE, RETURN, further MATCH, WITH aggregation. An algorithm is a node in the query plan, not a black-box external call.

Why this matters for agents#

For an agent, the Algorithm Library is a vocabulary of named graph operations it can reach for without implementing the algorithm itself. PageRank a knowledge graph, find the shortest causal chain, probe a vector index for similar entities, run multi-hop RAG with provenance — every one is a CALL in a Cypher query, with the same parameter shape and the same typed result.

The library also defines the additive-surface boundary for ArcFlow's release contract. New algorithms are additive — they extend the catalogue without changing existing surface. An agent that wrote code against algo.pageRank last quarter will find it works identically next quarter; new procedures only add capability.

What the library does NOT do#

An algorithm is a function over the graph at a point in time. Combining algorithms with the layers below them — running PageRank inside a behavior that fires on a live-view delta — is how an agent assembles real applications.

See also#