small changes

This commit is contained in:
René Fuhry 2023-06-01 11:08:59 +02:00 committed by GitHub
parent 30a49b665e
commit 466bfcd102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -43,10 +43,10 @@ pub fn show(matrix: &Vec<Vec<usize>>) {
}
}
pub fn read_csv() -> Vec<Vec<usize>> {
pub fn read_csv(file_name: String) -> Vec<Vec<usize>> {
let mut matrix: Vec<Vec<usize>> = vec![];
let dir: String = String::from("/home/rene/projects/Java/graphprogram/csv/");
let file_path: String = dir + &String::from("art-brck.csv");
let file_path = dir + &file_name;
let mut csv = ReaderBuilder::new()
.has_headers(false)
.delimiter(b';')

View File

@ -6,7 +6,7 @@ mod tests {
#[test]
fn graph() {
let mut adjazenz_matrix: Vec<Vec<usize>> = read_csv();
let mut adjazenz_matrix: Vec<Vec<usize>> = read_csv("art-brck.csv".to_owned());
let distanz_matrix: Vec<Vec<usize>> = calculate_distanz_matrix(&adjazenz_matrix);
let weg_matrix: Vec<Vec<usize>> = calculate_weg_matrix(&adjazenz_matrix);
let exzentrizitaeten: Vec<usize> = calculate_exzentrizitaeten(&distanz_matrix);
@ -46,7 +46,7 @@ mod tests {
#[test]
fn matrix() {
let adjazenz_matrix: Vec<Vec<usize>> = read_csv();
let adjazenz_matrix: Vec<Vec<usize>> = read_csv("art-brck.csv".to_owned());
assert_eq!(adjazenz_matrix, vec![
vec![0, 0, 1, 1, 0],

View File

@ -1,12 +1,9 @@
pub mod graph;
pub fn main() {
output();
}
let file_name = String::from("50n.csv");
// This is just for the pupose of visualising the output
fn output() {
let mut adjazenz_matrix: Vec<Vec<usize>> = graph::matrix::read_csv();
let mut adjazenz_matrix: Vec<Vec<usize>> = graph::matrix::read_csv(file_name);
let distanz_matrix: Vec<Vec<usize>> = graph::calculate_distanz_matrix(&adjazenz_matrix);
let weg_matrix: Vec<Vec<usize>> = graph::calculate_weg_matrix(&adjazenz_matrix);
@ -32,4 +29,4 @@ fn output() {
println!("components: {:?}", components);
println!("bridges: {:?}", graph::find_bridges(&mut adjazenz_matrix, &components));
println!("articulations: {:?}", graph::find_articulations(&adjazenz_matrix, &components));
}
}