Homomorphisms of graphs and automata