diff --git a/Cargo.toml b/Cargo.toml index cbaf3f3..9851f29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,6 @@ name = "graphprogram_rust" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] csv = "1.2.2" fastrand = "1.9.0" @@ -18,4 +16,5 @@ panic = "unwind" incremental = true debug-assertions = false codegen-units = 64 -rpath = false \ No newline at end of file +rpath = false +strip = true diff --git a/src/graph/matrix.rs b/src/graph/matrix.rs index ef8ca50..b79cfea 100644 --- a/src/graph/matrix.rs +++ b/src/graph/matrix.rs @@ -148,13 +148,12 @@ pub fn show(matrix: &Vec>) { } } -pub fn read_csv(file_name: &str) -> Vec> { +pub fn read_csv(file: &str) -> Vec> { let mut matrix: Vec> = vec![]; - let dir: String = "/home/rene/projects/Java/graphprogram/csv/".into(); let mut csv = csv::ReaderBuilder::new() .has_headers(false) .delimiter(b';') - .from_path(dir + file_name) + .from_path(file) .unwrap(); for (index, result) in csv.records().enumerate() { diff --git a/src/lib.rs b/src/lib.rs index e4bc40a..17f5d47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ mod tests { #[test] fn graph() { - let adjazenz_matrix = read_csv("art-brck.csv"); + let adjazenz_matrix = read_csv("/home/rene/projects/Java/graphprogram/csv/art-brck.csv"); let distanz_matrix = calculate_distanz_matrix(&adjazenz_matrix); let weg_matrix = calculate_weg_matrix(&adjazenz_matrix); diff --git a/src/main.rs b/src/main.rs index 66d3bfb..12d64dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +use std::env::args; + #[allow(unused_imports)] use crate::graph::{ matrix::{fill_with_random, read_csv, show}, @@ -7,9 +9,14 @@ use crate::graph::{ pub mod graph; pub fn main() { - let file_name = "24n.csv"; - let adjazenz_matrix = read_csv(file_name); - //let adjazenz_matrix = fill_with_random(320); // with 320 verteces, it runs in about 10 seconds on an Intel i5-10300H @4.3 GHz (2023-06-05 15:48) + let args: Vec = args().collect(); + let adjazenz_matrix: Vec>; + + if args[1].trim().parse::().is_ok() { + adjazenz_matrix = fill_with_random(args[1].parse::().unwrap()); // with 320 verteces, it runs in about 10 seconds on an Intel i5-10300H @4.3 GHz (2023-06-05 15:48) + } else { + adjazenz_matrix = read_csv(&args[1]); + } let distanz_matrix = calculate_distanz_matrix(&adjazenz_matrix); let weg_matrix = calculate_weg_matrix(&adjazenz_matrix);