The existence of 2-factors in squares of graphs