writing graph data to json file