$p$-$V$ diagram and internal energy

I recently learned that if the initial state is equal to the final state in the $$p$$-$$V$$ diagram then the internal energy is equal to zero so that means $$Q=W$$. My question is how can you know that only from the $$p$$-$$V$$ diagram without knowing the amount of Q? ( I'm taking generally not only in the case of ideal gasses)