Expand description
Generic topological sorting for any data structure.
This module provides topological sorting that works with any graph-like structure via higher-order functions, similar to the generic cycle detection.
§Submodules
impact- Impact analysis (descendants, ancestors, blast radius)metrics- Graph metrics and statistics
§Examples
use ascii_dag::layout::generic::topological_sort_fn;
// Example: Sort tasks by dependencies
let get_deps = |task: &&str| match *task {
"deploy" => vec!["test", "build"],
"test" => vec!["build"],
"build" => vec!["compile"],
"compile" => vec![],
_ => vec![],
};
let tasks = ["deploy", "test", "build", "compile"];
if let Ok(sorted) = topological_sort_fn(&tasks, get_deps) {
// sorted = ["compile", "build", "test", "deploy"]
assert_eq!(sorted[0], "compile"); // No dependencies, comes first
assert_eq!(sorted[3], "deploy"); // Depends on everything, comes last
}Modules§
Traits§
- Topologically
Sortable - Trait for types that support topological sorting.
Functions§
- topological_
sort_ fn - Performs topological sorting on a collection of items using a dependency function.