Skip to main content

Module algo

Module algo 

Source
Expand description

Graph algorithms: PageRank, weakly-connected components, degree centrality.

§Dependency rule note

This module lives in core-api (not core-query) because it must read the unified topology — manual edges plus derived edges written by the rule engine via GraphMut. core-query has no dependency on core-rules and therefore cannot see derived provenance. GraphDb fields are private; the algorithms are pure functions called from GraphDb methods that pass in a TopologyView over the in-memory overlay and the mmap V8 base. Reading the view (not the bare overlay Topology) is required: after a snapshot reopen the derived edges live in the base, and using the overlay alone would report zero degree/rank for every node.

§When to use views vs degree_centrality

degree_centrality is a one-shot compute: call it, get a snapshot sorted by degree, done. It does not persist anywhere and is not maintained as properties change. Use it for offline analysis, ranking a batch, or feeding write_scores once.

A Degree materialized view (ViewDef { kind: AggFn::Degree, … }) is maintained incrementally: every insert_edge / delete_edge / insert_node re-computes just the affected node’s count and stores it as a live property. Use it when you need the degree of individual nodes at query time with zero latency (e.g. MATCH (n) WHERE n.out_degree > 5 RETURN n).

Rule of thumb: if you need the top-K by degree once → degree_centrality; if you need the degree of every node available in every Cypher query → create a Degree view.

Structs§

Community
One detected community.
CommunityReport
Result of [GraphDb::communities].
DegreeConfig
Configuration for [GraphDb::degree_centrality].
DegreeReport
Result of [GraphDb::degree_centrality].
LouvainConfig
Configuration for [GraphDb::communities].
PageRankConfig
Configuration for [GraphDb::pagerank].
PageRankReport
Result of [GraphDb::pagerank].
WccConfig
Configuration for [GraphDb::connected_components].
WccReport
Result of [GraphDb::connected_components].

Enums§

AlgoDir
Direction semantics for algo methods (mirrors Dir but serializable).