function [e]=Energy2(V,Matrix)
%The input is a vector V that is a scalar function on some graph, in
%addition to Matrix, which is the Laplacian matrix of the same graph.
%The output is the energy of the graph associated with V, and will be
%stored in the variable e.
e=0;
[m,n]=size(Matrix);
%This block of code will find the energy.
for j = 1:m-1
for k= j+1:m
if Matrix(j,k)==0;
e=e;
else
e=e+(V(k)-V(j))^2;
end
end
end
end