Matching graphs with polynomial functions