search and graph function