If the graph of a function $f: A \rightarrow \mathbb R$ is compact, is $f$ continuous where $A$ is a compact metric space? I have seen answers to this question, which go beyond my understanding of compactness and continuity. I was wondering whether we can cook up a proof using sequential compactness and certain equivalent definitions of continuity such as the inverse image of any closed set is closed.
Here is what I have been able to conjure up so far.
Assume that the graph of $f$ is compact. This means that it is also closed and bounded. The graph is a closed and bounded subset of $A \times f(A)$. All we need to show is that $f(A)$ is compact, and we are are home free, right? (since continuous functions take compact sets to compact sets).
Question is: how do we show that $f(A)$ using the fact that the graph is compact. Can we claim that $f(A)$ is closed and bounded (since by Heine-Borel, any closed and bounded subset of $\mathbb R$ is compact)?
I feel like I am really close. Can anyone help me out?
 A: First, to answer the question in your comment, it seems that you claim:
If $A$ is a compact metric space, for all functions $f:A\to\Bbb R$, $f(A)$ compact implies $f$ continuous.
This claim is false. For example, consider $A=[-1,1]$ as a metric subspace of $\Bbb R$ and define $f:A\to\Bbb R$ by
$$f(x)=\begin{cases} 1&\text{if } x\gt 0\\ -1&\text{otherwise}\end{cases}.$$
Thus $f(A)$ is the compact set $\{-1,1\}$ but $f$ is not continuous.
Second, I'll give a proof using sequential compactness, something equivalent to continuity, namely sequential continuity, something else.
Proof.
Assume then that $(A,d)$ is a compact metric space, and $f:A\to\Bbb R$ is a function such that
$$G=\{(x,f(x)):x\in A\}$$
is compact in $(A\times\Bbb R,D)$ where $D$ is the usual product metric (one of the usual metrics) given by
$$D((u,x),(v,y))=d(u,v)+|y-x|.$$
Since we are dealing with metric spaces, it is enough to show that $f$ is sequentially continuous.
Then, consider a sequence $(x_n)$ in $A$ with
$$\lim_{n\to\infty} x_n=x\in A.$$
We must show that
$$\lim_{n\to\infty} f(x_n)=f(x).$$
As says the "abstract thing" stated here, it is enough to show that every subsequence $(f(x_{n_k}))_{k\in\Bbb N}$ has a subsequence $(f(x_{n_{k_j}}))_{j\in\Bbb N}$ converging to $f(x)$.
So, consider $(f(x_{n_k}))_{k\in\Bbb N}$ a subsequence of $(f(x_n))_{n\in\Bbb N}$. We will prove that this subsequence has a subsequence converging to $f(x)$.
Since $G$ is a compact metric space, $G$ is sequentially compact, thus, the sequence $((x_{n_k},f(x_{n_k})))_{k\in\Bbb N}$ in $G$ must have a convergent subsequence, say $((x_{n_{k_j}},f(x_{n_{k_j}})))$ with
$$\lim_{j\to\infty} (x_{n_{k_j}},f(x_{n_{k_j}}))=(y,f(y))\in G.$$
Notice that for each $j\in\Bbb N$ we have
$$D((x_{n_{k_j}},f(x_{n_{k_j}})),(y,f(y)))\geq d(x_{n_{k_j}},y)\geq 0,$$
so
$$\lim_{j\to\infty} d(x_{n_{k_j}},y)=0$$
i.e.
$$\lim_{j\to\infty} x_{n_{k_j}}=y.\tag{1}$$
By similar arguments it follows that
$$\lim_{j\to\infty} f\left(x_{n_{k_j}}\right)=f(y).\tag{2}$$
Since convergent sequences can have at most one limit, $(1)$ says
$$x=y,$$
therefore by $(2)$
$$\lim_{j\to\infty} f\left(x_{n_{k_j}}\right)=f(x)$$
as we wanted.
A: Corrected 2 December 2021.
Suppose that $f$ is not continuous. Then there are a point $x\in A$, an $\epsilon>0$, and a sequence $\langle x_n:n\in\Bbb N\rangle$ in $A$ converging to $x$ such that $\left|f(x_n)-f(x)\right|\ge\epsilon$. (Why?) Let $G$ be the graph of $f$. Then $\big\langle\langle x_n,f(x_n)\rangle:n\in\Bbb N\big\rangle$ is a sequence in the compact metric space $G$, so it has a convergent subsequence $\big\langle\langle x_{n_k},f(x_{n_k})\rangle:k\in\Bbb N\big\rangle$.

*

*Show that the limit of this subsequence must be of the form $\langle x,\alpha\rangle$ for some $\alpha\in\Bbb R$. (Recall that $x$ is the limit of $\langle x_n:n\in\Bbb N\rangle$.)


*Show that $\alpha\ne f(x)$. Conclude that $\langle x,\alpha\rangle\notin G$.
This contradicts the compactness of $G$; how?
A: I will add one more proof, which works in greater generality and is shorter, as its requires no sequences, no inequalities, just pure thought:
Theorem. Suppose that $X, Y$ are topological spaces, $X$ is Hausdorff, and $f: X\to Y$ is a map whose graph $G_f\subset X\times Y$ is compact. Then $f$ is continuous.
Proof. Consider the surjective map
$$
F: X\to G_f, F(x)=(x, f(x)).
$$
Continuity of $F$ is equivalent to continuity of $f$, thus, I will be proving that $F$ is continuous. The inverse map to $F$ is the restriction to $G_f$ of the projection $\pi_X: X\times Y\to X$. The projection $\pi_X$ is continuous, so is its restriction to $G_f$. Now, the map
$$
F^{-1}=\pi_X|_{G_f}: G_f\to X
$$
is a continuous bijection from a compact space to a Hausdorff space. Hence, $F^{-1}$ is a homeomorphism (see for instance here). Thus, its inverse, $F$, is also continuous. qed
