How to show a function is continuous when the graph is closed. 
Let $X$, $Y$ be metric spaces and $f:X\to Y$. Then $G_f$ is closed in $X\times Y$ if and only if whenever $x_n\to x$ in $X$, $f(x_n)\to y$ in $Y$ , we have $y=f(x)$.

Here $G_f=\{(x,f(x)):x \in X\}.$
We know that the graph of a continuous function from a space into a Hausorff space is closed so I think the reverse part can be proved  by this but I'm stuck to prove the ($\implies$) part.
Please someone help..
Thank you.

It seems to me that you are asking two distinct question.
If the question is “Is it true that $f$ is continuous if and only if $G_f$ is closed?”, then the answer is negative. Consider the map$$\begin{array}{rccc}f\colon&\mathbb R&\longrightarrow&\mathbb R\\&x&\mapsto&\begin{cases}\frac1x&\text{ if }x\neq0\\0&\text{ if }x=0.\end{cases}\end{array}$$It is not continuous, but its graph is closed.
On the other hand, the question asked at the beginning of your post has an affirmative answer, at least on metric spaces. That's because a subset $S$ of a matric space is closed if and only if whenever a sequence of points of $S$ converges, then the limit belongs to $S$ too.
