I have the following problem: Let $X$ be a compact metric space, $Y$ any metric space, and suppose $f: X \rightarrow Y$ is continuous. Let $ G \subset X \times Y, G = \{(x,f(x)) : x \in X\}$. If $G$ is compact, prove it. Otherwise show why $G$ is not compact.
This is what I have so far: We know that the continuous image of a compact metric space is compact, so therefore $ f(X) \in Y$ is compact. Also note that because of the way $G$ is defined, $ G \subset X \times f(X)$. Given a sequence $\{(x_n,f(x_n))\} \in G$, by the compactness of $X$ and $f(X)$, we know that any sequences $\{x_n\}$ and $\{f(x_n)\}$ will have convergent subsequences, so therefore $\{(x_n,f(x_n))\}$ will have a convergent subsequence.
Does this logic actually work? The main thing I'm iffy on is if the sequence would be defined as $\{(x_n,f(x_n))\}$, or if it would be something like $\{(x_n,f(x_k))\}$ instead. Also, I was initially planning on showing that $G$ was closed, because I know that the closed subset of a compact set is compact, but this method seemed slightly less cumbersome.