From 01a7a76f04067e23818b706dd1c310ee57f1fbcb Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Sat, 22 Jun 2024 18:41:06 +0200 Subject: [PATCH] I have brain damage --- lab5/zad1/src/main.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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 + } } }