function G=grid(m,n)
    s=[];
    t=[];
    for i=1:m*n-1
        if (mod(i,m)~=0)
            s=[s i];
            t=[t i+1];
        end
        if (i+m<=m*n)
            s=[s i];
            t=[t i+m];
        end
    end
    G=graph(s,t);
end