function [NewBdyEdges UnusedEdges]= BdyEdgesUpdateInd(EdgeListT, BdyEdges, e, UnusedEdges)
% [NewBdyEdges UnusedEdges]= BdyEdgesUpdateInd(EdgeListT, BdyEdges, e,UnusedEdges)

%Since all boundary edges to be added or removed with be adjacent to the
%non-tree endpoint of the edge e, we first determine this non-tree
%endpoint, which we denote as nonTreeEndpt
EdgeListTEndpts = EdgeListT(:,1:2);
if ismember(e(1),EdgeListTEndpts)
    nonTreeEndpt = e(2);
else
    nonTreeEndpt = e(1);
end


%We need to delete any edge of BdyEdges that has nonTreeEndpt
%as one of its endpoints.
BdyEdgesEndpts = BdyEdges(:,1:2);
[a b] = find(BdyEdgesEndpts == nonTreeEndpt);
BdyEdges(a,:) = []; BdyEdgesEndpts(a,:) = [];
%3.  Next, we find the unused edges that are incident to nonTreeEndpt.  The
%vector a below gives their row indices in UnusedEdges, and the vector b
%gives the columnn index(1 or 2) in which nonTreeEndpt occurs.
UnusedEdgesEndpts = UnusedEdges(:,1:2);
[a b] = find(nonTreeEndpt==UnusedEdgesEndpts);
%We add these edges to BdyEdges
BdyEdges = [BdyEdges; UnusedEdges(a,:)];
%and delete them from UnusedEdges
UnusedEdges(a,:)=[];
NewBdyEdges = BdyEdges;



