cringe
This commit is contained in:
parent
f68f7fb00b
commit
6e9137151f
12
src/graph.rs
12
src/graph.rs
@ -108,14 +108,16 @@ pub fn calculate_properties(exzentrizitaeten: &Vec<usize>) -> (usize, usize, Vec
|
||||
pub fn find_components(weg_matrix: &Vec<Vec<usize>>) -> Vec<Vec<usize>> {
|
||||
let mut components: Vec<Vec<usize>> = vec![];
|
||||
let mut component: Vec<usize>;
|
||||
let mut i: usize;
|
||||
|
||||
for i in 0..weg_matrix.len() {
|
||||
for array in weg_matrix.iter() {
|
||||
component = vec![];
|
||||
|
||||
for j in 0..weg_matrix.len() {
|
||||
if weg_matrix[i][j] == 1 {
|
||||
component.push(j + 1);
|
||||
i = 1;
|
||||
for value in array.iter() {
|
||||
if value == &1 {
|
||||
component.push(i);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if !components.contains(&component) {
|
||||
components.push(component);
|
||||
|
@ -22,8 +22,10 @@ pub fn mult(matrix1: &Vec<Vec<usize>>, matrix2: &Vec<Vec<usize>>) -> Vec<Vec<usi
|
||||
let mut sum: u128;
|
||||
|
||||
for i in 0..matrix1.len() {
|
||||
product.push(vec![]);
|
||||
for j in 0..matrix1.len() {
|
||||
if i == 0 {
|
||||
product.push(vec![]);
|
||||
}
|
||||
sum = 0;
|
||||
for k in 0..matrix1.len() {
|
||||
sum += (matrix1[i][k] * matrix2[k][j]) as u128;
|
||||
@ -43,7 +45,7 @@ pub fn show(matrix: &Vec<Vec<usize>>) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_csv(file_name: String) -> Vec<Vec<usize>> {
|
||||
pub fn read_csv(file_name: &str) -> Vec<Vec<usize>> {
|
||||
let mut matrix: Vec<Vec<usize>> = vec![];
|
||||
let dir: String = String::from("/home/rene/projects/Java/graphprogram/csv/");
|
||||
let file_path = dir + &file_name;
|
||||
|
@ -6,7 +6,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn graph() {
|
||||
let mut adjazenz_matrix: Vec<Vec<usize>> = read_csv("art-brck.csv".to_owned());
|
||||
let mut adjazenz_matrix: Vec<Vec<usize>> = read_csv("art-brck.csv");
|
||||
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);
|
||||
@ -47,7 +47,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn matrix() {
|
||||
let adjazenz_matrix: Vec<Vec<usize>> = read_csv("art-brck.csv".to_owned());
|
||||
let adjazenz_matrix: Vec<Vec<usize>> = read_csv("art-brck.csv");
|
||||
|
||||
assert_eq!(adjazenz_matrix, vec![
|
||||
vec![0, 0, 1, 1, 0],
|
||||
|
@ -3,8 +3,7 @@ use crate::graph::{*, matrix::*};
|
||||
pub mod graph;
|
||||
|
||||
pub fn main() {
|
||||
let file_name = String::from("art-brck.csv");
|
||||
|
||||
let file_name = "24n.csv";
|
||||
let mut adjazenz_matrix: Vec<Vec<usize>> = read_csv(file_name);
|
||||
//let mut adjazenz_matrix: Vec<Vec<usize>> = fill_with_random(100);
|
||||
let distanz_matrix: Vec<Vec<usize>> = calculate_distanz_matrix(&adjazenz_matrix);
|
||||
|
Reference in New Issue
Block a user