diff --git a/lab5/zad1/src/main.rs b/lab5/zad1/src/main.rs index ec9d236..185d697 100644 --- a/lab5/zad1/src/main.rs +++ b/lab5/zad1/src/main.rs @@ -66,12 +66,22 @@ impl Graph { pub fn new_rand(size: usize) -> Self { Self { size, - edges: (0..size).map(|u| - (0..size).map(|v| - if u == v { 0.0 } - else { thread_rng().gen::() } - ).collect::>()) - .collect::>(), + edges: { + let mut edges = vec![vec![0.0; size]; size]; + + for i in 0..size { + for j in 0..size { + if i == j { continue } + + let w = thread_rng().gen::(); + + edges[i][j] = w; + edges[j][i] = w; + } + } + + edges + } } }