Every graph has a core I'm currently going through Godsil/Royle's chapter about graph homomorphisms and using the following definitions I struggle to follow through the proof of the existence of a core of a graph.

A graph $X$ is a core if every homomorphism $f$ from $X$ to itself is a bijection.
A subgraph $Y$ is a core of $X$ if $Y$ is a core and there exists a homomorphism from $X$ to $Y$.

Let $X$ be a finite graph. Since $id_X: V(X) \to V(X), v \mapsto v$ is a homomorphism the family of subgraphs from $X$ to which $X$ has a homomorphism is finite and not empty. Hence, there exists a minimal subgraph $Y$ with respect to inclusion.
Why is $Y$ a core of $X$? It is clear that there exists a homomorphism $X \to Y$ but why is every endomorphism of $Y$ an isomorphism?

You've shown that there exists a $Y$ which is a minimal subgraph of $X$ such that there exists a homomorphism $f:X\rightarrow Y$. Now, suppose that there exists a homomorphism $g:Y\rightarrow Y$ which is not a bijection. This means that $g(Y)$ has less vertices than $Y$. However, homomorphisms are closed under composition, so that $f\circ g$ is a homomorphism from $X$ to $g(Y)$. But $Y$ was minimal in the above sense, which is a contradiction.
