relations: weakly-connected components (component, components partition, count) + 11 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 27s
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:
@@ -103,6 +103,37 @@
|
||||
|
||||
;; --- current-db convenience layer ---
|
||||
|
||||
(define
|
||||
relations-component
|
||||
(fn
|
||||
(db node kind)
|
||||
(relations-ureach-bfs db kind (list node) (list node))))
|
||||
|
||||
(define
|
||||
relations-components-loop
|
||||
(fn
|
||||
(db kind remaining acc)
|
||||
(if
|
||||
(= (len remaining) 0)
|
||||
acc
|
||||
(let
|
||||
((comp (relations-component db (first remaining) kind)))
|
||||
(relations-components-loop
|
||||
db
|
||||
kind
|
||||
(filter (fn (n) (not (relations-eng-member? n comp))) remaining)
|
||||
(append acc (list comp)))))))
|
||||
|
||||
(define
|
||||
relations-component-count
|
||||
(fn (db kind) (len (relations-components db kind))))
|
||||
|
||||
(define
|
||||
relations-components
|
||||
(fn
|
||||
(db kind)
|
||||
(relations-components-loop db kind (relations-nodes db kind) (list))))
|
||||
|
||||
(define
|
||||
relations/common-ancestors
|
||||
(fn
|
||||
@@ -116,3 +147,15 @@
|
||||
(define
|
||||
relations/topo-order
|
||||
(fn (kind) (relations-topo-order (relations-ensure-db!) kind)))
|
||||
|
||||
(define
|
||||
relations/component
|
||||
(fn (node kind) (relations-component (relations-ensure-db!) node kind)))
|
||||
|
||||
(define
|
||||
relations/components
|
||||
(fn (kind) (relations-components (relations-ensure-db!) kind)))
|
||||
|
||||
(define
|
||||
relations/component-count
|
||||
(fn (kind) (relations-component-count (relations-ensure-db!) kind)))
|
||||
|
||||
Reference in New Issue
Block a user