graph function coded