Expand description
BFS reachability search and orphan/stub detection.
Structs§
- Connectivity
- One entity’s degree counts.
total == incoming + outgoing; kept explicit so the JSON wire shape is self-describing and callers don’t re-derive it.
Functions§
- cmp_
by_ dependency - Centrality ordering: dependency degree (
typed_total) descending first, then rawtotaldescending, thenidlexicographic ascending as a stable deterministic tie-break. Ranking bytyped_totalkeeps a co-mention-inflated hub from outranking a real dependency hub. - connectivity_
for - Compute one entity’s raw and typed degree.
incoming_countsdecides which incoming edges contribute (e.g. source-in-mem scoping for a mem-filtered health view); every outgoing edge always counts. Typed degree excludesEdgeSource::BodyLink(auto-emitted mention) edges. - find_
orphans - Find orphan entities — non-stub entities with no edges at all (completely isolated).
- find_
stubs - Find stub entities — entities created from unresolved references. Returns each stub with the list of entities that reference it.
- most_
connected - Find the most connected non-stub entities, ranked by dependency degree
(typed edges) — see
cmp_by_dependency. Returns up tolimitentries. - reachable
- Find all entities reachable from a starting entity within max_depth hops. Undirected traversal (follows both outgoing and incoming edges). Returns the set of reachable entity IDs including the start node.
- reachable_
distances - Like
reachablebut returns each reached entity’s hop-distance fromfrom— the depth at which BFS first reaches it (fromitself is 0). Undirected (outgoing + incoming), same membership asreachable. The distances drive proximity ranking of arelated_toneighbourhood: nearer first. - reachable_
via - Find all entities reachable from
fromby walking only edges whoserel_typeis inedge_types, up tomax_depthhops. Undirected traversal (outgoing + incoming). Returns one tuple per reached entity — neverfromitself — carrying the edge label used to first reach it and the depth of that first reach (1 = direct neighbour). - would_
cycle - Would adding an edge
from --rel_type--> toclose a cycle in the subgraph restricted to edges ofrel_type? Returns the back-path as[to, …, from]when a cycle exists,Noneotherwise.