added method to save graph