summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Guschin <guschin.drew@gmail.com>2022-05-11 11:12:16 +0400
committerAndrew Guschin <guschin.drew@gmail.com>2022-05-11 11:12:16 +0400
commit0a19410cb83f20fa505f764abf36cbc89222fe74 (patch)
tree2fd48b589c2b20b74ff3d007a1cfae19c3614107
parent527d395e80b62fcc177151b1a1fa1de496afefcc (diff)
Added function for getting minimal degree in graph
-rw-r--r--src/main.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 5014ec5..e8ad69d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -100,6 +100,17 @@ impl Graph {
return sum;
}
+ fn min_degree(&self) -> usize {
+ let mut min = self.size + 1;
+ for i in 0..self.size {
+ let d = self.degree(i);
+ if d < min {
+ min = d;
+ }
+ }
+ return min;
+ }
+
fn get_closure_traced(&self, trace_steps: bool) -> Graph {
let mut step = if trace_steps { 2 } else { 1 };
@@ -289,6 +300,8 @@ fn main() {
if is_complete {
let components_count = g.count_components();
println!("Components count: {components_count}");
+ let min_degree = g.min_degree();
+ println!("Minimal degree: {min_degree}");
println!("Graph: {line}\n{g}");
println!("Graph cutsets:");