TITLE: Prove that if a function $f: X\to Y$ continuous then its graph is closed
QUESTION [12 upvotes]: 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).

REPLY [2 votes]: 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.