mod merge_sort; mod min_cut; mod quick_sort; mod ssc; mod util; use std::cmp::min; use crate::util::read_to_graph; use crate::merge_sort::merge_sort_inversions; use crate::min_cut::min_cut; use crate::quick_sort::quick_sort; use crate::ssc::ssc; use crate::util::read_to_directed_graph; use crate::util::read_to_vector; #[allow(dead_code)] fn c1a2() { let vec = read_to_vector("data/course_1_assignment_2.txt").unwrap(); let (_sorted, inversions) = merge_sort_inversions(vec); println!("course 1 assignment 2: {:?}", inversions); } #[allow(dead_code)] fn c1a3() { let mut vec = read_to_vector("data/course_1_assignment_3.txt").unwrap(); let mut comp_acc: usize = 0; quick_sort(&mut vec, &mut comp_acc); println!("course 1 assignment 3: {:?}", comp_acc); /* 1: 162085 2: 164123 3: 138382 */ } #[allow(dead_code)] fn c1a4() { let g = read_to_graph("data/course_1_assignment_4.txt").unwrap(); let mut smalles_min_cut = u32::MAX; let iterations = g.nodes.len().pow(1); for _ in 0..iterations { let new_min_cut = min_cut(g.clone()); if new_min_cut < smalles_min_cut { smalles_min_cut = new_min_cut; } } /* 17 */ println!("course 1 assignment 4: {:?}", smalles_min_cut); } #[allow(dead_code)] fn c2a1() { // I have not checked in the graph file, because it has 70MB. // let g = read_to_directed_graph("data/course_2_assignment_1.txt").unwrap(); let g = read_to_directed_graph("data/course_2_assignment_1_test.txt").unwrap(); let sizes = ssc(g.0, g.1); let max_size = min(sizes.len(), 5); println!("{:?}", &sizes[0..max_size]); } fn main() { // c1a2(); // c1a3(); // c1a4(); c2a1(); }