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.
 A: 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.
A: To see the forward part (which is not the question from the title by the way..)
Suppose $G_f$ is closed and $x_n \to x$ and $f(x_n) \to y$. 
Then $(x_n, f(x_n)) \to (x,y)$ and these points $(x_n, f(x_n))$ lie in $G_f$ so when $G_f$ is closed this means that their limit $(x,y) \in G_f$ as well, so $y=f(x)$ by definition. This implication holds regardless of $X$, $Y$ or whether $f$ is continuous.
For the reverse (sequence condition gives closedness of $G_f$ we need that $X \times Y$ is sequential (so certainly true when $X$ and $Y$ are metrisable):
Let's show $G_f$ is sequentially closed: let $((x_n, y_n))_n$ be a sequence of points from $G_f$  that converges to $(x,y) \in X \times Y$.
This means that $x_n \to x$ and $y_n \to y$. Being in $G_f$ means that $f(x_n) = y_n$. Now apply the right hand side sequence condition, and we get $y = f(x)$ so $(x,y) \in G_f$, and $G_f$ is (sequentially) closed. Again this holds for all $f$.
Now, if $f$ is continuous it will have $G_f$ closed ($Y$ Hausdorff is enough for this to hold) but $G_f$ closed is not enough to get continuity of $f$ as Santos' standard example of $f(x) = \frac{1}{x}$ shows.
