rewrite graph