function energy = compute_energy(conn_mat,occ) % Compute the energy of a NxN fully-connected chain energy = occ*conn_mat*occ' ;