Implement graph serializer.