Thermodynamics-Consistent Graph Neural Networks