Graph of a continuous function is closed

Let $f: \mathbb{R} \to \mathbb{R}$ be continuous. Then $G = \{ (x, f(x) ) : x \in \mathbb{R} \} $ is a closed set.

My try: Suppose $(z_n) = (x_n, f(x_n) ) $ is sequence in $G$ with limit $(x,y)$. We must show $(x,y) \in G$. Since $x_n \to x$ and since $f$ is continuous, then we must have that $f(x_n) \to f(x) $. Since limits are unique. Then $y = f(x) $. Is this enough to conlude that $(x,y) \in G $ ? Hence showing $G$ is closed ?

thanks


Let $\{(x_n, f(x_n))\}_{n=1}^{\infty}$ be a convergent sequence in $G$, say $(x_n, f(x_n)) \to (x,y)$. So $x_n \to x$. So $f(x_n) \to f(x)$. So $f(x) = y$, and so $(x_n, f(x_n)) \to (x, f(x)) \in G$. So $G$ is closed.


Let's define a map $F(x,y) :R^2 \to R$ such that : $F(x,y) = y - f(x)$. Then $F$ is a continuous function, and $\{0\}$ is a closed set of $R$, so the graph of $f$ , $G =\{(x,f(x)) : x \in R\}$ is the pre-image $F^{-1}(0)$ which is a closed set in $R^2$.