function edge_array_calc
% CALCULATE THE EDGE ARRAY (SIMILAR TO PDETOOL)
global lnp 
global edgearray

nlnp=permute(lnp,[3 2 1]);
[numdiv1 numsides numlps] = size(nlnp); numedges=numlps*numsides;
nlnp=reshape(nlnp,[],numedges)';
outeredge=zeros(1,numdiv1);

% first find all outer edges
k=0;
for i=1:numedges
    match=0;
    for j=1:numedges
        if (i~=j & size(unique(nlnp(i,:)),2)==size(unique(nlnp(j,:)),2) & unique(nlnp(i,:))==unique(nlnp(j,:)))
            match=1;
            break
        end
    end
    if match==0
        k=k+1;
        outeredge(k,:)=nlnp(i,:);
    end
end

% now initilize and fill in (relevant parts) of edgearray
[numouteredges npe] = size(outeredge);
edgearray=zeros(7,1);
esn=0;
for i=1:numouteredges
    npe=length(find(outeredge(i,:)));
    for j=1:(npe-1)
        esn=esn+1;
        edgearray(:,esn)=[outeredge(i,j) outeredge(i,j+1) 0 0 i 0 0]';
    end
end
        

