From e144e3427da93b962c7620ce2bd64add8c83cfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 23 May 2016 23:03:23 +0200 Subject: graph: Add 'node-reachable-count'. * guix/graph.scm (node-reachable-count): New procedure. * tests/graph.scm ("node-reachable-count"): New test. --- guix/graph.scm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'guix/graph.scm') diff --git a/guix/graph.scm b/guix/graph.scm index af589c5c67..735d340c2c 100644 --- a/guix/graph.scm +++ b/guix/graph.scm @@ -39,6 +39,7 @@ node-back-edges traverse/depth-first node-transitive-edges + node-reachable-count %graphviz-backend graph-backend? @@ -126,6 +127,13 @@ procedure that, given a node, returns its list of direct dependents; it is typically returned by 'node-edges' or 'node-back-edges'." (traverse/depth-first cons '() nodes node-edges)) +(define (node-reachable-count nodes node-edges) + "Return the number of nodes reachable from NODES along NODE-EDGES." + (traverse/depth-first (lambda (_ count) + (+ 1 count)) + 0 + nodes node-edges)) + ;;; ;;; Graphviz export. -- cgit v1.2.3