relations: weakly-connected components (component, components partition, count) + 11 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 27s

tree.sx, reuses ureach-bfs. 158/158 across 9 suites.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 13:43:20 +00:00
parent c0d02c229c
commit f1d65c0953
6 changed files with 209 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ links. Reuses `lib/datalog/` — does not reimplement the engine.
## Status (rolling)
`bash lib/relations/conformance.sh`**147/147** (Phases 14 complete + extensions)
`bash lib/relations/conformance.sh`**158/158** (Phases 14 complete + extensions)
## Ground rules
@@ -114,9 +114,22 @@ lib/relations/federation.sx
cleanup: retract every local edge touching a node, all kinds, both directions —
for domain object deletion; leaves federated peer links alone). api.sx,
`lib/relations/tests/bulk.sx`.
- [x] **weakly-connected components**`component` (the undirected cluster of a
node), `components` (partition of all nodes for a kind), `component-count`. In
tree.sx, reusing `ureach-bfs`. `lib/relations/tests/comp.sx`.
## Progress log
- **Extension: weakly-connected components** (158/158). `relations-component`
(the undirected cluster containing a node = `ureach-bfs` from it),
`relations-components` (greedy partition: pop a remaining node, take its
component, repeat) and `relations-component-count`, in tree.sx, + `relations/...`
wrappers. `lib/relations/tests/comp.sx` (11 tests: cluster from either end, self-
loop as its own component, partition contents, count, kind isolation, api).
Engine surface now feels SATURATED — base roadmap + 5 graph-algorithm extensions
cover direct/transitive/undirected reach, paths (shortest + all routes), cycles,
roots/leaves, siblings/degree, ancestors/LCA/topo, components, federation, and
bulk lifecycle. Pacing down.
- **Extension: bulk lifecycle** (147/147). `relations-relate-many!` (batch
`dl-assert!` over a list of (src dst kind) triples) and `relations-unrelate-node!`
(query `rel` for every edge with the node as src or dst, across all kinds, then