73 lines
2.0 KiB
Matlab
Executable File
73 lines
2.0 KiB
Matlab
Executable File
function Bench_metis
|
|
% Compare recursive bisection and direct k-way partitioning,
|
|
% as implemented in the Metis 5.0.2 library.
|
|
|
|
% Add necessary paths
|
|
addpaths_GP;
|
|
|
|
% Graphs in question
|
|
load('airfoil1.mat');
|
|
G1 = Problem.A;
|
|
w1 = Problem.aux.coord;
|
|
map_r1_16 = metismex('PartGraphRecursive',G1,16);
|
|
map_k1_16 = metismex('PartGraphKway',G1,16);
|
|
map_r1_32 = metismex('PartGraphRecursive',G1,32);
|
|
map_k1_32 = metismex('PartGraphKway',G1,32);
|
|
|
|
load('crack.mat');
|
|
G2 = Problem.A;
|
|
w2 = Problem.aux.coord;
|
|
map_r2_16 = metismex('PartGraphRecursive',G2,16);
|
|
map_k2_16 = metismex('PartGraphKway',G2,16);
|
|
map_r2_32 = metismex('PartGraphRecursive',G2,32);
|
|
map_k2_32 = metismex('PartGraphKway',G2,32);
|
|
|
|
figure;
|
|
title('Recursive METIS partition of Airfoil graph for n=32');
|
|
drawgraph(G1, w1, map_r1_32, 'air_n');
|
|
figure;
|
|
title('K-way METIS partition of Airfoil graph for n=32');
|
|
drawgraph(G1, w1, map_k1_32, 'air_k');
|
|
figure;
|
|
title('Recursive METIS partition of Crack graph for n=32');
|
|
drawgraph(G2, w2, map_r2_32, 'crack_n');
|
|
figure;
|
|
title('K-way METIS partition of Crack graph for n=32');
|
|
drawgraph(G2, w2, map_k2_32, 'crack_k');
|
|
|
|
fprintf('Algorithm\tAirfoil16\tAirfoil32\t Crack16\t Crack32\n');
|
|
fprintf('Recursive\t%9d\t%9d\t%9d\t%9d\n', ...
|
|
ec(G1, map_r1_16), ec(G1, map_r1_32), ...
|
|
ec(G1, map_r2_16), ec(G1, map_r2_32));
|
|
fprintf('K-way \t%9d\t%9d\t%9d\t%9d\n', ...
|
|
ec(G1, map_k1_16), ec(G1, map_k1_32), ...
|
|
ec(G1, map_k2_16), ec(G1, map_k2_32));
|
|
end
|
|
|
|
function n = ec(A, map)
|
|
EG = A;
|
|
hold on;
|
|
for i = min(map):max(map)
|
|
part = find(map == i)';
|
|
EG(part, part) = 0;
|
|
end
|
|
n = nnz(triu(EG));
|
|
end
|
|
|
|
function drawgraph(A, xy, map, n)
|
|
EG = A;
|
|
hold on;
|
|
for i = min(map):max(map)
|
|
part = find(map == i)';
|
|
EG(part, part) = 0;
|
|
|
|
A_p = A(part, part);
|
|
coord = xy(part, :);
|
|
|
|
gplot(A_p, coord);
|
|
end
|
|
|
|
gplot(EG, xy, '-k');
|
|
hold off;
|
|
%matlab2tikz('showInfo', false, sprintf('../../ex5_%s.tex', n));
|
|
end |