2023-06-03 10:12:59 +02:00
|
|
|
use crate::graph::{*, matrix::{read_csv, show}};
|
2023-06-01 12:25:40 +02:00
|
|
|
|
2023-05-30 19:13:41 +02:00
|
|
|
pub mod graph;
|
|
|
|
|
2023-05-31 12:45:45 +02:00
|
|
|
pub fn main() {
|
2023-06-01 14:51:57 +02:00
|
|
|
let file_name = "24n.csv";
|
2023-06-03 10:12:59 +02:00
|
|
|
let mut adjazenz_matrix = read_csv(file_name);
|
|
|
|
//let mut adjazenz_matrix = fill_with_random(45); // with this many verteces, it runs in about 10.2 seconds (2023-06-02 14:39)
|
|
|
|
let distanz_matrix = calculate_distanz_matrix(&adjazenz_matrix);
|
|
|
|
let weg_matrix = calculate_weg_matrix(&adjazenz_matrix);
|
2023-05-31 14:49:55 +02:00
|
|
|
|
2023-05-31 18:29:13 +02:00
|
|
|
println!("adjazen matrix:");
|
2023-06-01 12:25:40 +02:00
|
|
|
show(&adjazenz_matrix);
|
2023-05-31 14:49:55 +02:00
|
|
|
println!("\ndistanz matrix:");
|
2023-06-01 12:25:40 +02:00
|
|
|
show(&distanz_matrix);
|
2023-05-31 14:49:55 +02:00
|
|
|
println!("\nweg matrix:");
|
2023-06-01 12:25:40 +02:00
|
|
|
show(&weg_matrix);
|
2023-05-31 14:49:55 +02:00
|
|
|
|
2023-06-02 14:59:36 +02:00
|
|
|
let exzentrizitaeten = calculate_exzentrizitaeten(distanz_matrix);
|
2023-06-01 12:25:40 +02:00
|
|
|
let properties = calculate_properties(&exzentrizitaeten);
|
2023-05-31 14:49:55 +02:00
|
|
|
|
2023-05-31 23:13:59 +02:00
|
|
|
if properties.3 {
|
2023-06-03 10:12:59 +02:00
|
|
|
println!("\nexzentrizitäten: {exzentrizitaeten:?}");
|
|
|
|
println!(
|
|
|
|
"radius: {}\ndiameter: {}\ncentre: {:?}",
|
|
|
|
properties.0, properties.1, properties.2
|
|
|
|
);
|
2023-05-31 23:13:59 +02:00
|
|
|
} else {
|
|
|
|
println!("\nexzentrizitäten: not connected");
|
|
|
|
println!("radius/diameter/centre: not connected");
|
|
|
|
}
|
2023-05-31 14:49:55 +02:00
|
|
|
|
2023-06-03 10:12:59 +02:00
|
|
|
let components = find_components(weg_matrix);
|
|
|
|
println!("components: {components:?}");
|
2023-06-01 12:25:40 +02:00
|
|
|
|
|
|
|
let result = find_articulations_and_bridges(&mut adjazenz_matrix, &components);
|
|
|
|
println!("bridges: {:?}", result.1);
|
|
|
|
println!("articulations: {:?}", result.0);
|
2023-06-01 11:08:59 +02:00
|
|
|
}
|