Problem
The graph $G$ of $f$ is defined as the points $(x, f(x))$ for $x \in E$.
Suppose $E \subset \mathbb{R}$ is compact, then $f : E \to \mathbb{R}$ is continuous iff its graph is compact.
Question
My solution doesn't use the fact that $E$ is a subset of $\mathbb{R}$ nor the fact that $f$ is a real function. Are these necessary hypotheses?
My solution
Let $Y$, some metric space, be the codomain of $f$, then $G$ is a subset of $E \times Y$. Define a metric on $E \times Y$ - the choice of metric is irrelevant.
If $x$ is continuous because it's a polynomial, and $f(x)$ is continuous by hypothesis. Then $g := (x, f(x))$ is continuous (Theorem 4.10 in Rudin). Since $E$ is compact, so is $G$ since $g$ is a continuous mapping from $E$ to $G$.
Suppose $G$ is compact. We have $g^{-1} (x, f(x)) = x$; clearly $g^{-1}$ is bijective. The inverse of $g^{-1}$, i.e. $g$ itself, is continuous since $G$ is compact and $g^{-1}$ is bijective. Thus $f(x)$ is also continuous.
Is this right? I don't think we need real-valued or $E \subset \mathbb{R}$. I'm a bit skeptical because usually all given hypotheses are necessary so that the strongest possible statement is proven.