Prove that $f$ is continuous-Proof-Verification. 
Let $(X,d)$ be a compact  metric space.
  Let $f:X\to X$ be a function such that graph(f)=$(G(f))=\{(x,f(x):x\in X\}$
  is closed.
Prove that $f$ is continuous.

TRY:
To show that $f$ is continuous enough to show that if $x_n\to x$ then  $f(x_n)\to f(x)$.
Let $x_n\to x$ ;;
since $X$ is compact so $f(x_n)$ has a convergent subsequence say $f(x_{n_k})\to y$.
Consider the corresponding terms  in the sequence $x_n$ then $(x_{n_k },f(x_{n_k}))\to (x,y).$
Now $(x_{n_k },f(x_{n_k}))\in G(f)$  which is closed hence $(x,y)\in G(f))$ which in turn implies that $y=f(x)$
So $f(x_{n_k})\to f(x)$.
But I need to show that $f(x_n)\to f(x)$
How can I show that??Please help me out.
 A: Suppose $x_n$ is a sequence converging to $x$, but $f(x_n)$ doesn't converge to $f(x)$.
Suppose $f(x_n)$ is not convergent at all.
In a compact space, a non convergent sequence has at least two distinct limit points. Thus you find subsequences $x_{n'_k}$ and $x_{n''_k}$ such that $f(x_{n'_k})\to y$ and $f(x_{n''_k})\to z$, with $y\ne z$. Since the graph is closed, you have both $(x,y)$ and $(x,z)$ in $G(f)$, a contradiction.
Therefore $f(x_n)$ is convergent. By your argument it converges to $f(x)$, because a subsequence does.
A: You have founded a function $f\colon X\to X$ satisfying the following condition: for every sequence $(x_n)_n$ in $X$ with $x_n\to x$ there exist a subsequence $(x_{n_k})_k$ such that $f(x_{n_k})\to f(x)$.
Suppose $f$ is not continuous at $x$. Then there exists $\varepsilon>0$ such that for all $n\in\mathbb N$ there exists $y_n\in B(x,\frac1n)$ with $f(y_n)\notin B(f(x),\varepsilon)$.
Therefore, the sequence $(y_n)_n$ do not satisfy the given condition ($(y_n)_n$ converges to $x$ but do not exist a subsequence $(y_{n_k})_k$ such that $f(y_{n_k})\to f(x)$).
Hence, $f$ (with such condition) must be continuous.

Let me elaborate it a little bit more.
We say that $f$ is continuous at $x$ if for every $\varepsilon > 0$ there exists $\delta > 0 $ such that $d(f(y),f(x))<\varepsilon$ whenever $d(y,x)<\delta$, or equivalently: $f(y)\in B(f(x),\varepsilon)$ whenever $y\in B(x,\delta)$.
When it was supposed that $f$ is not continuous at $x$, we got some $\varepsilon > 0$ such that for every $\delta > 0$ there exist $y\in B(x,\delta)$ with $f(y)\notin B(f(x),\varepsilon)$.
In that way, I have just taken $\delta = 1/n$.
