From 7690f4b23daa67e64d69339ba95a0332cfa60d31 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Wed, 28 Oct 2020 14:04:35 +0100 Subject: [PATCH] mp3: Corrections --- mp1/project_1_Maggioni_Claudio.pdf | Bin 574935 -> 577567 bytes .../src/Bench_rec_bisection.m | 2 +- .../src/bisection_inertial.m | 4 ++-- .../src/bisection_spectral.m | 6 +++--- .../src/ex2_bisection_table.m | 6 ++++-- .../src/ex3_plots.m | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mp1/project_1_Maggioni_Claudio.pdf b/mp1/project_1_Maggioni_Claudio.pdf index aac45a0bbdbd2023fa5e829f20bd5d4781819eee..00575c28979ac4ba88569a5a13289b8e5a998b58 100644 GIT binary patch delta 2522 zcmb_eO=ufO6t0^l5d(#Wq=okMhzYSt(C+O27T3kLB5INlM;5KpxRAAWoG8e$QYj9cZD@LvKCgR$6*(FFEAUQ{UTBELmC^n-q!JVQ2Pz-+b?H zUVJ0O<9XpXyxDLacd7U@U9+g!7B~hkIxgVmiipEjR2MO`v+wb{NCXM!w7r7s zVd5nM=gM3dBq=V%;ABhF(@X?Dk8o^lPDV|O7J2jcwI8>;hVXt z81%LRh9Mu4%zory{qlgRp`8>J8F_?^ArUksWRIXl;KKr0a^F4#O1E7(N+H6xWGM9T zZQ?$RZ}Uu={~h0!%J=Xc0vg75x-r%tup`yY0%ULJcj&kk=)7eZ>NasVpL_Kbz^s%OD zDpxfd!@||gFIDv<{wJ~3wvuaM1QX*puSVY5n(#p>d(D^{ZS_p8SZ+0&%U%$Oh;@G5 zDyZ)*O;kk<&NXfbAfrni_Pp@X2THY(G!Y5SEVh=fi+V!y&XujgNroLZ5?+EZolmz4 z@25;zh(fp774oUR`8CAi%A`lrJ2+LWt1Wkc6y zW=)&V8oE<5)w1EJuBpwdyon2MJFu||8mH7)K#evMCsdFN@np|U+j_!!W4KQup zH7vOIXLJlxX0fq>UT|=6K3EAe02#NazhJa3sVbo3rh=Y3tJ2O7LMyj0ey)HcmMzZ diff --git a/mp3/Project_3_Maggioni_Claudio/src/Bench_rec_bisection.m b/mp3/Project_3_Maggioni_Claudio/src/Bench_rec_bisection.m index 547b5c0..afbc652 100755 --- a/mp3/Project_3_Maggioni_Claudio/src/Bench_rec_bisection.m +++ b/mp3/Project_3_Maggioni_Claudio/src/Bench_rec_bisection.m @@ -74,7 +74,7 @@ for c = 1:nc A = params.Adj; coords = params.coords; - W = A - diag(diag(A)); + W = A; % 2. Recursive routines % i. Spectral diff --git a/mp3/Project_3_Maggioni_Claudio/src/bisection_inertial.m b/mp3/Project_3_Maggioni_Claudio/src/bisection_inertial.m index 4ef46f4..066dbaf 100755 --- a/mp3/Project_3_Maggioni_Claudio/src/bisection_inertial.m +++ b/mp3/Project_3_Maggioni_Claudio/src/bisection_inertial.m @@ -1,4 +1,4 @@ -function [part1,part2] = bisection_inertial(A,xy,picture) + function [part1,part2] = bisection_inertial(A,xy,picture) % INERTPART : Inertial partition of a graph. % % p = inertpart(A,xy) returns a list of the vertices on one side of a partition @@ -20,7 +20,7 @@ function [part1,part2] = bisection_inertial(A,xy,picture) % Steps % 1. Calculate the center of mass. -m = sum(xy, 1) / size(xy, 1); +m = sum(xy, 1) ./ size(xy, 1); xm = m(1); ym = m(2); diff --git a/mp3/Project_3_Maggioni_Claudio/src/bisection_spectral.m b/mp3/Project_3_Maggioni_Claudio/src/bisection_spectral.m index df7a92f..350c184 100755 --- a/mp3/Project_3_Maggioni_Claudio/src/bisection_spectral.m +++ b/mp3/Project_3_Maggioni_Claudio/src/bisection_spectral.m @@ -18,9 +18,9 @@ function [part1,part2] = bisection_spectral(A,xy,picture) % Steps % 1. Construct the Laplacian. -[i, j, ~] = find(triu(A)); -G = graph(i, j); -L = laplacian(G); +D = diag(sum(A, 1)); +W = -1 .* A; +L = D + W; % 2. Calculate its eigensdecomposition. [V, ~] = eigs(L,2,'smallestabs'); diff --git a/mp3/Project_3_Maggioni_Claudio/src/ex2_bisection_table.m b/mp3/Project_3_Maggioni_Claudio/src/ex2_bisection_table.m index c6b32ee..6b29c7c 100644 --- a/mp3/Project_3_Maggioni_Claudio/src/ex2_bisection_table.m +++ b/mp3/Project_3_Maggioni_Claudio/src/ex2_bisection_table.m @@ -7,6 +7,8 @@ addpaths_GP; [W4,c4] = gridt(40); [W5,c5] = grid9(30); +global W +global c W = {W1, W2, W3, W4, W5, Smallmesh, Tapir, Eppstein}; c = {c1, c2, c3, c4, c5, Smallmesh_coords, Tapir_coords, Eppstein_coords}; @@ -24,8 +26,8 @@ function runtest(implementation) global W global c for i=1:8 - out = implementation(W{i}, c{i}); - ne = cutsize(W{i},out); + [part1, ~] = implementation(W{i}, c{i}); + ne = cutsize(W{i},part1); fprintf('%d\t', ne); end fprintf('\n'); diff --git a/mp3/Project_3_Maggioni_Claudio/src/ex3_plots.m b/mp3/Project_3_Maggioni_Claudio/src/ex3_plots.m index b0e80f1..40f8250 100644 --- a/mp3/Project_3_Maggioni_Claudio/src/ex3_plots.m +++ b/mp3/Project_3_Maggioni_Claudio/src/ex3_plots.m @@ -11,4 +11,4 @@ bisection_spectral(Smallmesh, Smallmesh_coords, 2); figure; bisection_spectral(Eppstein, Eppstein_coords, 2); -%matlab2tikz( '../../ex3_eppstein.tex'); \ No newline at end of file +%matlab2tikz('../../ex3_eppstein.tex'); \ No newline at end of file