The polynomial endomorphisms of graph algebras