Fixed bug in WriteGraph