Prove that if a function $f: X\to Y$ continuous then its graph is closed The graph of $f$ is $G(f) = \{(x,f(x)) : x\in X\} \subseteq X\times Y$
$X$ and $Y$ are metric spaces.
a) Suppose $f$ is continuous and prove that $G(f)$ is a closed set.
b) Suppose that $G(f)$ is compact and prove that $f$ is continous
For a), the definition of a closed set that comes to my mind is a set that contains all its limit points (or was it accumulation points?), is there another equivalent definition that may b more helpful to prove a)? Is it possible to prove this directly? Because at first glance the only way I could imagine to prove this is by contradiction or contrapositive. 
I imagine that the proof of b) will be immediately derived from a).
 A: a) Let $(z_n)=(x_n,f(x_n))$ be a convergent sequence of $G(f)$. If $(x,y)$ is its limit, show that $y=f(x)$.
b) 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)$. Use the sequence $z_n=(x_n,f(x_n))$ and use the fact that $G(f)$ is compact to prove that $(f(x_n))$ has $f(x)$ as an accumulation point. 
Then prove that any subsequence of $(f(x_n))$ has $f(x)$ as an accumulation point. 
A: Hint: For (a), every metric space is Hausdorff, the result is frue for any Hausdorff space $Y$. Choose any (x,y)\in $X\times Y\setminus G(f)$. Then $x\in X$ and $y\ne f(x)$. Use Hausdorff condition in $Y$.
A: We want to show that every sequence which converges in $X\times Y$ has a limit in $G(f)$. 
A sequence $(x_n, y_n)$ converges to $(x, y)$ if and only if $x_n\rightarrow x$ and $y_n\rightarrow y$. 
Note that $(x_n, y_n)\in N_\epsilon(x, y)\implies(x_n)\in N_\epsilon(x) $ and $(y_n)\in  N_\epsilon(y)$ respectively.
Conversely, if $x_n \in N_{\epsilon/2}(x)$ and $y_n \in N_{\epsilon/2}(y)$, then $(x_n, y_n)\in N_\epsilon(x, y)$. 
So now we see that if $(x_n, y_n)\in G(f)$, $(x_n,y_n) \rightarrow (x,y)$, then $y_n\rightarrow f(x_n)$ as defined by $G(f)$ and $x_n \rightarrow x, f(x_n)\rightarrow y.$
Since $f$ is assumed to be continuous, $f(x_n)\rightarrow f(x)$ so $y=f(x)$. Therefore $(x,y)\in G(f)$ and we conclude $G(f)$ is closed.
