small changes
This commit is contained in:
parent
30a49b665e
commit
466bfcd102
@ -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 mut matrix: Vec<Vec<usize>> = vec![];
|
||||||
let dir: String = String::from("/home/rene/projects/Java/graphprogram/csv/");
|
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()
|
let mut csv = ReaderBuilder::new()
|
||||||
.has_headers(false)
|
.has_headers(false)
|
||||||
.delimiter(b';')
|
.delimiter(b';')
|
||||||
|
@ -6,7 +6,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn graph() {
|
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 distanz_matrix: Vec<Vec<usize>> = calculate_distanz_matrix(&adjazenz_matrix);
|
||||||
let weg_matrix: Vec<Vec<usize>> = calculate_weg_matrix(&adjazenz_matrix);
|
let weg_matrix: Vec<Vec<usize>> = calculate_weg_matrix(&adjazenz_matrix);
|
||||||
let exzentrizitaeten: Vec<usize> = calculate_exzentrizitaeten(&distanz_matrix);
|
let exzentrizitaeten: Vec<usize> = calculate_exzentrizitaeten(&distanz_matrix);
|
||||||
@ -46,7 +46,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn matrix() {
|
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![
|
assert_eq!(adjazenz_matrix, vec![
|
||||||
vec![0, 0, 1, 1, 0],
|
vec![0, 0, 1, 1, 0],
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
pub mod graph;
|
pub mod graph;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
output();
|
let file_name = String::from("50n.csv");
|
||||||
}
|
|
||||||
|
|
||||||
// This is just for the pupose of visualising the output
|
let mut adjazenz_matrix: Vec<Vec<usize>> = graph::matrix::read_csv(file_name);
|
||||||
fn output() {
|
|
||||||
let mut adjazenz_matrix: Vec<Vec<usize>> = graph::matrix::read_csv();
|
|
||||||
let distanz_matrix: Vec<Vec<usize>> = graph::calculate_distanz_matrix(&adjazenz_matrix);
|
let distanz_matrix: Vec<Vec<usize>> = graph::calculate_distanz_matrix(&adjazenz_matrix);
|
||||||
let weg_matrix: Vec<Vec<usize>> = graph::calculate_weg_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!("components: {:?}", components);
|
||||||
println!("bridges: {:?}", graph::find_bridges(&mut adjazenz_matrix, &components));
|
println!("bridges: {:?}", graph::find_bridges(&mut adjazenz_matrix, &components));
|
||||||
println!("articulations: {:?}", graph::find_articulations(&adjazenz_matrix, &components));
|
println!("articulations: {:?}", graph::find_articulations(&adjazenz_matrix, &components));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user