function varargout = aamdisp_plotEdges(varargin)
% function varargout = aamdisp_plotEdges(varargin)
%
% Dr. A. I. Hanna (2007)
if mod(length(varargin),2) ~= 0
    % input args have not com in pairs, woe is me
    error(['Arguments to ', mfilename, ' must come param/value in pairs.'])
end
pts =[];
edges=[];
dim=2;
axish = [];
col = 'w';
width = 1;

for i=1:2:length(varargin)
    switch lower(varargin{i})
        case 'pts'
            pts = varargin{i+1};
        case 'edges'
            edges = varargin{i+1};
        case 'parent'
            axish = varargin{i+1};
        case 'edgecolour'
            col = varargin{i+1};
        otherwise
            error(['Unknown parameter name passed to ', mfilename, '.  Name was ' varargin{i}])
    end
end
if isempty(pts)
    error('Parameter pts must be supplied');
end
ph = [];

% Begin change by js, 080130
% Begin original code


% End original code
% Begin replacement code

dim = size(pts, 2);

if dim == 3
%     col = 'r';
    width = 2;
end

% End replacement code
% End change by js, 071217


switch dim
    case 3
        for i=1:size(edges,1)
            ph = cat(2, ph, plot3(axish, [pts(edges(i,1),1), pts(edges(i,2),1)], [pts(edges(i,1),2), pts(edges(i,2),2)], [pts(edges(i,1),3), pts(edges(i,2),3)]));
        end
    case 2
        for i=1:size(edges,1)
            ph = cat(2, ph, plot(axish, [pts(edges(i,1),1), pts(edges(i,2),1)], [pts(edges(i,1),2), pts(edges(i,2),2)]));
        end
end
set(ph, 'Color', col, 'LineWidth', width);
varargout{1} = ph;
return