

function [eid] = matlabGxGy_to_matlabEdge ( gx1 , gy1 , gx2 , gy2 )

[ gid1 ] = matlabGxGy_to_matlabGid ( gx1 , gy1 ) ;
[ gid2 ] = matlabGxGy_to_matlabGid ( gx2 , gy2 ) ;
adjG = abs(gid1 - gid2 ) ;
if ((adjG~=1) & (adjG~=max_clm_idx))
    display('error, not adjacent grid') ;
elseif ((gid1 - gid2) == 1)
    [gx, gy] = mapGridPos( gid2 , max_clm_idx ) ;
    eid = getEdgePos( gx, gy, 1 , max_clm_idx ) ;
elseif ((gid2-gid1)==1)
    [gx, gy] = mapGridPos( gid1 , max_clm_idx ) ;
    eid = getEdgePos( gx, gy, 1 , max_clm_idx ) ;
elseif ((gid2 - gid1) == max_clm_idx)
    [gx, gy] = mapGridPos (gid1 , max_clm_idx ) ;
    eid = getEdgePos( gx, gy, 0 , max_clm_idx ) ;
elseif ((gid1 - gid2) == max_clm_idx)
    [gx, gy] = mapGridPos (gid2 , max_clm_idx ) ;
    eid = getEdgePos( gx, gy, 0 , max_clm_idx ) ;
end
