Struct modular_decomposition::MDTree
source · pub struct MDTree { /* private fields */ }Expand description
A modular decomposition tree. The tree contains at least one node.
Implementations§
source§impl MDTree
impl MDTree
sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Return the number of nodes in the modular decomposition tree.
sourcepub fn module_kind(&self, module: ModuleIndex) -> Option<&ModuleKind>
pub fn module_kind(&self, module: ModuleIndex) -> Option<&ModuleKind>
Access the ModuleKind of a module.
If the module does not exist, return None.
sourcepub fn module_kinds(&self) -> impl Iterator<Item = &ModuleKind>
pub fn module_kinds(&self) -> impl Iterator<Item = &ModuleKind>
Return an iterator yielding references to ModuleKinds for all nodes.
sourcepub fn children(
&self,
module: ModuleIndex
) -> impl Iterator<Item = ModuleIndex> + '_
pub fn children( &self, module: ModuleIndex ) -> impl Iterator<Item = ModuleIndex> + '_
Return an iterator for the children of a node.
sourcepub fn into_digraph(self) -> DiGraph<ModuleKind, ()>
pub fn into_digraph(self) -> DiGraph<ModuleKind, ()>
Convert to DiGraph.
Examples found in repository?
examples/adj_vector_graph.rs (line 74)
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
fn main() {
let graph = Graph::from_edges([(0, 1), (1, 2), (2, 3)]);
let tree = modular_decomposition(&graph).map(|tree| tree.into_digraph()).unwrap_or_default();
println!("{:?}", Dot::with_config(&tree, &[EdgeNoLabel]));
let mut factorizing_permutation = Vec::new();
let root = tree.externals(Incoming).next().unwrap();
let mut dfs = Dfs::new(&tree, root);
while let Some(node) = dfs.next(&tree) {
if let ModuleKind::Node(u) = tree[node] {
factorizing_permutation.push(u);
}
}
let factorizing_permutation: Vec<_> = factorizing_permutation.iter().map(|u| u.index()).collect();
println!("{:?}", factorizing_permutation);
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for MDTree
impl RefUnwindSafe for MDTree
impl Send for MDTree
impl Sync for MDTree
impl Unpin for MDTree
impl UnwindSafe for MDTree
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more