-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented function to calculate treewidth given graph with HashSets…
… as vertex weights
- Loading branch information
1 parent
3b461b5
commit 85ca3fc
Showing
3 changed files
with
16 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use petgraph::{graph::NodeIndex, Graph}; | ||
use std::collections::HashSet; | ||
|
||
/// Returns the maximum size of one of the bags in the tree decomposition graph. | ||
/// This equals the highest len of one of the vertices in the graph. Returns 0 if the graph has no vertices | ||
pub fn find_width_of_tree_decompositionpub<E>( | ||
graph: Graph<HashSet<NodeIndex>, E, petgraph::prelude::Undirected>, | ||
) -> usize { | ||
if let Some(bag) = graph.node_weights().max_by_key(|b| b.len()) { | ||
bag.len() | ||
} else { | ||
0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters