pub fn compute_transitive_closure<'a>(
initial: impl IntoIterator<Item = &'a str>,
get_deps: impl Fn(&str) -> Option<&'a [String]>,
) -> HashSet<String>Expand description
Compute the transitive closure of dependencies from an initial set.
Given a set of starting nodes and a function to retrieve dependencies, returns all nodes reachable by following dependency edges.
§Arguments
initial- Starting set of node namesget_deps- Function that returns dependencies for a given node name
§Example
ⓘ
use cuenv_task_graph::compute_transitive_closure;
use std::collections::HashMap;
let deps: HashMap<&str, Vec<String>> = [
("build", vec![]),
("test", vec!["build".to_string()]),
("deploy", vec!["test".to_string()]),
].into_iter().collect();
let closure = compute_transitive_closure(
["deploy"],
|name| deps.get(name).map(|v| v.as_slice()),
);
// closure contains: {"deploy", "test", "build"}