added writing of sample graph in rewriting step