A continuous function and a closed graph

I remember doing a similar problem where working by contradiction was easier.

Suppose $a_i$ converges to $a$ but $f(a_i)$ does not converge to $f(a)$. Then there exists an $\epsilon>0$ such that for all $N\in \mathbb{N}$, there exists an $i_N>N$ such that $f(a_{i_N})\notin B(f(a),\epsilon)$.

If $B$ is compact, then there is a subsequence $b_i$ of the $a_{i_N}$ such that $f(b_i)$ converges. Then the sequence $(b_i,f(b_i))$ must converge (since each of its coordinates converge) and since the graph is closed it converges to a point $(b,f(b))$. But then it follows that $b=a$, and so $f(b_i)$ converges to $f(b)=f(a)$, however this is an absurdity because every element of any subsequence of $f(a_{i_N})$ is more than $\epsilon$ from $f(a)$.

Hence, $f$ preserves convergent sequences, and is continuous.


For the $(\Rightarrow)$ direction, start, as you did, with an arbitrary point $a\in A$ and a sequence $\langle a_k:k\in\Bbb N\rangle$ converging to $a$. Because $B$ is compact, $\langle f(a_k):k\in\Bbb N\rangle$ has a convergent subsequence; say $\langle f(a_{n_k}):k\in\Bbb N\rangle\to b$. Now you want to show that $b=f(a)$ and that the sequence $\langle f(a_k):k\in\Bbb N\rangle$ converges to $b$. We've already used compactness of $B$, so this must be where the assumption that $G$ is closed comes in. Can you take it from here? If not, just ask, and I'll expand this a bit further.

Added: Let $p=\langle a,b\rangle$. You can easily show that that $$\Big\langle\langle a_{n_k},f(a_{n_k})\rangle:k\in\Bbb N\Big\rangle\to p\;.$$ Since the sequence lies in the closed set $G$, we must have $p\in G$, and hence $f(a)=b$. But we're still not quite done, because so far we know only that the subsequence $\langle f(a_{n_k}):k\in\Bbb N\rangle$ converges to $b$, and we need to conclude that $\langle f(a_k):k\in\Bbb N\rangle\to b$. It clearly can't converge to anything else, but it conceivably might not converge. To prove that it does, just show that every subsequence converges to $b$. This does still require a little work.