fix graph function