Add graph hook for serialization.