Metric Of A Graph The following is question 6 from page 99 of Walter Rudin's Principles Of Mathematical Analysis.  I'm having trouble understanding what the metric of the graph might be (which, as far as I can tell, is not defined in the text or the problem)...

If f is defined on E, the graph of f is the set of points
  $(x,f(x))$, for $x \in E$.  In particular, if E is a set of real
  numbers, and f is real-valued, the graph of f is a subset of the
  plane.
Suppose E is compact, and prove that f is continuous on E if and
  only if its graph is compact.

I think I've been able to prove the forward result.  Suppose that E is compact.  Rudin proves a theorem in the text that states the image of a compact metric space under a continuous function is also compact.  Therefore, we know that $f(E)$ is compact.  Now suppose that $\lbrace G_\alpha \rbrace, \alpha \in A$ is an open cover of the graph, where $G_i = B_i \times C_i$ and $B_i \in E, C_i \in f(E)$.  Then $\lbrace A_\alpha \rbrace$ and $\lbrace B_\alpha \rbrace$ are open covers for E and $f(E)$, respectively.  Because these sets are compact, their open covers contain finite subcovers, $\lbrace A^\prime_\beta \rbrace$ and $\lbrace B^\prime_\gamma \rbrace$, respectively.  Thus, the set of all combinations of $(A^\prime_\beta, B^\prime_\gamma)$ forms a finite open subcover of the graph, proving that the graph is compact.
Actually, I'm really confused at this point, because it's just occured to me while typing the above that I cannot assume that each set $G_i$ can be represented as a set $\lbrace (x,y) \mid x \in A_i, y\in B_i \rbrace$ for open sets $A_i \subseteq E$ and $B_i \subseteq f(E)$.
So at this point, I'm not sure what to do, since I am unable to figure out what the distance metric might be in the metric space containing the graph.  Is there a convention for this sort of problem?  Did Rudin want the reader to only consider real-valued functions for f?
 A: Here, $E$ could be any compact metric space.
Define the function $f_1: E \to E \times E$ by $f_1(x) = (x, f(x))$.  Clearly this function is continuous, so $f_1(E)$ which is the graph is compact.  Now assume that the graph is compact.  We show that the inverse of image of every closed subset of of $E$ is closed in $E$. Define the maps $q_x, q_y$ by $(x, y) \to x$ and $(x, y) \to y$ respectively.  If $U \subset E$ is closed, then $f^{-1}(U) = q_x(q_y^{-1}(U) \cap f_1(E))$.  Both $q_x$ and $q_y$ are continuous, so $q_y^{-1}(U)$ is closed, so $q_y^{-1}(U) \cap f_1(E)$ is a closed subset of the compact set $f_1(E)$ and is therefore compact itself. By continuity of $q_x$, $f^{-1}(U)$ is compact in $E$, and since $E$ is Hausdorff (all metric spaces are), $f^{-1}(U)$ is closed.
A: Based on the words "the graph of f is a subset of a plane," I would interpret this as asking about functions $\mathbb{R}\rightarrow \mathbb{R}.$ The point in the proof you're struggling with is a general issue in showing that a product of compact spaces is compact. Since you get to be in a metric space, I'd recommend using the convergent subsequence definition of compactness instead. 
I'll note, however, that you don't need the full strength of this result here, as Brian's answer shows.
