Add graph generating code