Expand description
Dependency graph utilities.
Functions in this module operate on the unit Index to answer
graph-related questions: cycle detection, topological ordering,
tree rendering, and subtree statistics.
Most callers should use the wrappers in crate::api rather than
calling these functions directly.
§Example
use mana_core::api::{load_index, find_mana_dir};
use mana_core::graph::{detect_cycle, build_dependency_tree};
use std::path::Path;
let mana_dir = find_mana_dir(Path::new(".")).unwrap();
let index = load_index(&mana_dir).unwrap();
// Check whether adding a dep would create a cycle
if detect_cycle(&index, "5", "1").unwrap() {
eprintln!("Adding 5 -> 1 would create a cycle");
}
// Render a tree rooted at unit 1
let tree = build_dependency_tree(&index, "1").unwrap();
println!("{}", tree);Functions§
- build_
dependency_ tree - Build a dependency tree rooted at
id. Returns a string representation with box-drawing characters. - build_
full_ graph - Build a project-wide dependency graph as a text tree. Shows all dependencies rooted at units with no parents.
- count_
subtree_ attempts - Count total verify attempts across all descendants of a unit.
- detect_
cycle - Detect a cycle in the dependency graph.
- find_
all_ cycles - Find all cycles in the dependency graph. Returns a list of cycle paths.