Skip to content

Commit

Permalink
basic tweaks of docs and test
Browse files Browse the repository at this point in the history
  • Loading branch information
askhamwhat committed Jun 1, 2024
1 parent a0ef90c commit 4648a09
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
23 changes: 17 additions & 6 deletions chunkie/+lege/pols.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
function [pols,ders] = pols(xs,n)
%LEGE.POLS evaluate up to nth order Legendre polynomial via recursion
%LEGE.POLS evaluate up to nth degree Legendre polynomial via recursion
%
% output is (n+1) x size(xs) array
% Syntax:
%
% [pols,ders] = lege.pols(xs,n);
%
% Input:
% xs - points where you want to evaluate the Legendre polynomials
% n - highest degree polynomial of interest
%
% Output:
% pols - (n+1) x size(xs) array of polynomial values. pols(i,j) has the
% value P_{i-1}(xs(j))
% ders - (n+1) x size(xs) array of polynomial derivative values.
% ders(i,j) has the value P'_{i-1}(xs(j))
%
% see also LEGE.POL

%
% Copyright (C) 2009: Vladimir Rokhlin
%
% This software is being released under a modified FreeBSD license
%

%
% if n=0 or n=1 - exit
%

assert(n>=0,'n must be non-negative');
szx = size(xs);
xs = xs(:);
Expand Down
33 changes: 26 additions & 7 deletions chunkie/@chunkgraph/plot_regions.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function plot_regions(obj,iflegend)
function plot_regions(obj,iflabel)
%PLOT_REGIONS plots regions of a chunkgraph in 2 dimensions
% All regions in the chunkgraph are plotted in a different color.
%
Expand All @@ -8,17 +8,18 @@ function plot_regions(obj,iflegend)
% cgrph - chunkgraph object
%
% Optional input:
% iflegend - boolean (default true), include a Legend showing the region
% numbers
% iflabel - integer (default 2), include a Legend showing the region
% numbers and label edges if 2, include only the region legend if 1,
% no labels if 0.
%
% Output:
% none
%

% author: Jeremy Hoskins

if nargin < 2 || isempty(iflegend)
iflegend = true;
if nargin < 2 || isempty(iflabel)
iflabel = 2;
end


Expand Down Expand Up @@ -68,10 +69,28 @@ function plot_regions(obj,iflegend)
plot(plyrgn);
end

if nr > 1 && iflegend
legend(legtext);
if nr > 1 && iflabel > 0
legend(legtext,'AutoUpdate','off');
end

plot(obj,'k-');

if iflabel > 1
rmin = min(obj.r(:,:),[],2);
diam = max(obj.r(:,:)-rmin,[],2);
rmin = rmin-0.1*diam;
text(rmin(1),rmin(2),'region 1');

nedge = length(obj.echnks);
for j = 1:nedge
wts = obj.echnks(j).wts;
l1 = sum(wts(:));
l2 = cumsum(wts(:));
ind = find(l2 > l1/2,true,'first');
r = obj.echnks(j).r(:,ind);
text(r(1),r(2),"edge "+num2str(j),'HorizontalAlignment','center')
end
end

hold off

Expand Down
2 changes: 1 addition & 1 deletion devtools/test/chunkgraph_basicTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

% testing multiply connected

verts = [1 0 -1 4 3 2; 0 1 0 0 1 0];
verts = [1 0 -1 2 0 -2; 0 1 0 -0.5 2 -0.5];
edgends = [1 2 3 4 5 6; 2 3 1 5 6 4];
cg1 = chunkgraph(verts,edgends);

Expand Down

0 comments on commit 4648a09

Please sign in to comment.