
function [eid] = matlabGid_to_matlabEdge ( gid1 , gid2, max_clm_idx )

adjG = abs(gid1 - gid2 ) ;
if ((adjG~=1) & (adjG~=max_clm_idx))
    display('error, not adjacent grid') ;
elseif ((gid1 - gid2) == 1)   %%vertical
    [gx, gy] = matlabGid_to_matlabGxGy ( gid2 , max_clm_idx ) ;
    eid = matlabGetEdgePos( gx, gy, 1 , max_clm_idx ) ;
elseif ((gid2-gid1)==1)
    [gx, gy] = matlabGid_to_matlabGxGy( gid1 , max_clm_idx ) ;
    eid = matlabGetEdgePos( gx, gy, 1 , max_clm_idx ) ;
elseif ((gid2 - gid1) == max_clm_idx)
    [gx, gy] = matlabGid_to_matlabGxGy (gid1 , max_clm_idx ) ;
    eid = matlabGetEdgePos( gx, gy, 0 , max_clm_idx ) ;
elseif ((gid1 - gid2) == max_clm_idx)
    [gx, gy] = matlabGid_to_matlabGxGy (gid2 , max_clm_idx ) ;
    eid = matlabGetEdgePos( gx, gy, 0 , max_clm_idx ) ;
end
