function [z] = Varz(gamma,Matrix,ResMatrix)
%The inputs are a constant gamma, a Laplacian matrix: Matrix, and the
%resistance matrix of Matrix: ResMatrix.
%The output is a vector z, where each entry corresponds to the gamma'th
%spacial variance of the graph of some eigenfunction.
[m,n]=size(Matrix);
[V,D]=eig(Matrix);
%The column vectors of matrix V are the eigenfunctions of the input matrix.
%The matrix D is the diagonal matrix of the eigenvalues of the input
%matrix.
%From left to right, the columns of D contain the spectra of the
%input matrix in increasing order.
%Each column of V is the eigenfunction of the eigenvalue in the
%corresponding column of D.
z=zeros(m,1);
%This vector will store the spacial variances of the eigenfunctions in the order
%they are listed in V.
%These two blocks of code calculate the spacial variances.
for j=1:m
for k=1:m-1
for l=k+1:m
z(j)=z(j)+(ResMatrix(k,l))^(gamma)*V(k,j)^2*V(l,j)^2;
end
end
end
for j=1:m
z(j)=(z(j))/m;
end
end