function sparse = CreateSparseGraph(r,c)
% This function creates a sparse lattice of size (r,c) that details the
% "bond connections" between adjacent vertices.
%
% INPUTS
% r = Number of horizontal rows
% c = Number of vertical columns
%
% OUTPUTS
% sparse = r x c size lattice which details the pairs of adjacent indices 
%          that are connected
%
% ==================================

diagvec1 = repmat([ones(c-1,1); 0],r,1);                                           
diagvec1 = diagvec1(1:end-1);             
diagvec2 = ones(c*(r-1)+1,1);             
sparse = spdiags(diagvec1,-1,r*c,r*c)+spdiags(diagvec2,-c,r*c,r*c).';  

end

