This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp3/Project_3_Maggioni_Claudio/src/bisection_coordinate.m

34 lines
864 B
Mathematica
Raw Normal View History

2020-10-21 13:21:51 +00:00
function [part1,part2] = bisection_coordinate(A,xy,picture)
% COORDPART : Coordinate bisection partition of a mesh.
%
% [part1,part2] = bisection_coordinate(A,xy,picture) returns a list of the vertices on one side of a partition
% obtained by bisection perpendicular to a coordinate axis. We try every
% coordinate axis and return the best cut.
% Input A is the adjacency matrix of the mesh;
% each row of xy is the coordinates of a point in d-space.
%
% coordpart(A,xy,1) also draws a picture.
d = size(xy,2);
best_cut = inf;
for dim = 1:d
v = zeros(d,1);
v(dim) = 1;
[p1,p2] = partition(xy,v);
this_cut = cutsize(A,p1);
if this_cut < best_cut
best_cut = this_cut;
part1 = p1;
part2 = p2;
end
end
if picture
clf reset
gplotpart(A,xy,part1);
title('Coordinate bisection')
end
end