The graph of $f$ is $G(f) = \{(x,f(x)) : x\in X\} \subseteq X\times Y$
$X$ and $Y$ are metric spaces. $Y$ is compact.
$f$ is continuous iff $G(f)$ is a closed set.
I got the closest answer here but I tried it by myself first and got stuck at one point and I need help on that particular situation which I didn't get anywhere else/
$\Rightarrow$ part: Let $(z_n)=(x_n,f(x_n))\in G_f$ be a convergent sequence of $G(f)$. If $(x,y)$ is its limit. We have to show that $y=f(x)$ in other words $(x,y)\in G_f$.
$x_n \to x$ $\Rightarrow$ $f(x_n)\to f(x)$[By continuity of $f$.] $\Rightarrow f(x)=y$ by uniqueness of the limit. Hence $G_f$ is closed.
$\Leftarrow$ part: Let $x\in X$ and $(x_n)$ a convergent sequence with limit $x$. You have to prove that $(f(x_n))$ is convergent in $Y$ with limit $f(x)$. I have used the sequence $z_n=(x_n,f(x_n))$ and $G_f$ is closed in the compact space $Y$ and hence $G_f$ is compact. Then there is subsequence $(x_{n_k},f(x_{n_k})) \to (x,y)\in G_f$. Then we will have $y=f(x)$ but how do I prove that $f(x_n) \to f(x)$? It is true that every subsequence of $f(x_n)$ has a subsequence converging to $f(x)$.