implement graph marshalling