Continuous functions and closed graphs I'm working through Mendelson's Introduction to Topology. My question is about a small modification of the following problem from Mendelson:
$\textbf{Problem 6.3:}$ Let $(X,d_1)$ and $(Y,d_2)$ be metric spaces. Let $f:X\to Y$ be continuous. Define a distance function $d$ on $X\times Y$ in the standard manner. Prove that the graph $\Gamma_f$ of $f$ is a closed subset of $(X\times Y,d)$.
$\underline{\text{Proof}}$: By this point in the text, Mendelson has made it clear that by "define a distance function...in the standard manner," he wants the student to give $d$ on $X\times Y$ by
\begin{align*}
d\big((x_1,y_1),(x_2,y_2)\big)=\max\big\{d_1(x_1,x_2),d_2(y_1,y_2)\big\}.
\end{align*}
So, let $(x_0,y_0)\in X\times Y$. Suppose there exists a sequence $\big\{(x_n,y_n)\big\}^{\infty}_{n=1}$ in $\Gamma_f$ with limit $(x_0,y_0)$. Given $\epsilon>0$, there exists $N\in\mathbb{N}$ such that $n\geq N$ implies
\begin{align*}
d\big((x_0,y_0),(x_n,y_n)\big)=\max \big\{d_1(x_0,x_n),d_2(y_0,y_n)\big\}<\epsilon.
\end{align*}
It follows immediately that $x_n\to x_0$ and $y_n\to y_0$. Since $y_n=f(x_n)$ for each $n\in\mathbb{N}$, this becomes $f(x_n)\to y_0$. Since $f(x_n)\to f(x_0)$ by the continuity of $f$, and since limits are unique, we have $f(x_0)=y_0$. Hence, $(x_0,y_0)\in \Gamma_f$. Every limit point of $\Gamma_f$ is the limit of a sequence in $\Gamma_f$. So, we've shown that $f$ contains all its limit points, and so is a closed subset of $(X\times Y,d)$. $\blacksquare$
Assuming the proof is correct, I thought, "Ok, neat. But what about $\mathbb{R}$ as a metric space, with the Euclidean metric?" If I have some arbitrary non-empty subset $E\subset\mathbb{R}$, and $f:E\to\mathbb{R}$ is continuous, then the graph of $f$ needn't be a closed subset of $\mathbb{R}^2$. For example, if $E=[0,1)$ and $f(x)=x$, then the graph of $f$, $\Gamma_f$, won't contain the limit point $(1,1)$. However, then I realized that Mendelson is mapping from the entire metric space $X$, not merely from a subset of $X$. So, my questions are: 
(1) If Mendelson told us that $f$ mapped from some non-empty proper subset $F\subset X$, then we'd need additional hypotheses (like that $F$ is compact) in order to conclude that $\Gamma_f$ is a closed subset of $X\times Y$, correct? (Mendelson hasn't mentioned compactness or completeness of metric spaces, but I know that those ideas, familiar from advanced calculus on the reals, will reappear in metric spaces. I'm not sure he ever gets around to it in this small volume.)
(2) What counts as a closed subset of $X\times Y$ depends on what $X\times Y$ is, right? I mean, if $X=[0,1)$, $Y=\mathbb{R}$, and $f(x)=x$, then the graph of $f$ is a closed subset of $X\times Y=[0,1)\times\mathbb{R}$, since $\Gamma_f$ contains all its limit points in the given space. (The "missing" limit point, $(1,1)$, isn't in $X\times Y$.) 
Thanks for your help here.
 A: 
(1) If Mendelson told us that $f$ mapped from some non-empty proper subset $F \subset X$, then we'd need additional hypotheses (like that $F$ is compact) in order to conclude that $\Gamma_f$ is a closed subset of $X \times Y$, correct?

If the continuous map $f$ came out of a non-empty proper subset $F$ of $X$ (and into $Y$), then the domain of $f$ must be $F$ not $X$ because functions must be defined everywhere in their domains. Thus, the signature of $f$ would look like $f: F \to Y$ and $\Gamma_f$ would be a closed subset of the subspace $F \times Y$ of $X \times Y$. Now, if you want $\Gamma_f$ to be a closed subset of the larger space $X \times Y$, you would need all limit points of $\Gamma_f$ in $X \times Y$ to coincide exactly with all limit points of $\Gamma_f$ in $F \times Y$.
A simple way to achieve this is to require that $F$ be a closed subset of $X$. Then $F \times Y$, being the product of closed sets, will be a closed subset of $X \times Y$. So any limit point $l$ of $\Gamma_f$ in $X \times Y$, must be a limit point of $F \times Y$ in $X \times Y$ as $\Gamma_f \subseteq F \times Y$. Hence, as closed sets contain their limit points, we get $l \in F \times Y$. Thus, $l$ is a limit point of $\Gamma_f$ in $F \times Y$ also. Thus, the closure of $\Gamma_f$ in $X \times Y$ will correspond exactly to the closure of $\Gamma_f$ in $F \times Y$.
Your suggestion of making $F$ into a compact space also works in this case because compact subspaces of Hausdorff spaces (which include metric spaces) are always closed in the larger space.

(2) What counts as a closed subset of $X \times Y$ depends on what $X \times Y$ is, right? I mean, if $X=[0,1)$, $Y = \mathbb{R}$, and $f(x)=x$, then the graph of $f$ is a closed subset of $X \times Y = [0, 1) \times \mathbb{R}$, since $\Gamma_f$ contains all its limit points in the given space. (The "missing" limit point, $(1,1)$, isn't in $X \times Y$.)

Yes, and it seems you have answered your own question here adequately.
Extra Fact if you are interested:
The hypotheses for Mendelson's problem can be weakened substantially to make the overall result stronger. The following is true:


*

*Let $X$ be an arbitrary topological space and let $Y$ be a Hausdorff space. If $f: X \to Y$ be continuous, then the graph of $\Gamma_f$ of $f$ is a closed in the product space $X \times Y$.
(Furthermore, if $Y$ is also in addition compact, then the converse also holds!)
This has a neat proof if you also know this fact about Hausdorff spaces:


*

*$Y$ is a Hausdorff space if and only if the diagonal set $\Delta_Y = \{(y, y) \in Y \times Y\}$ is closed in the product space $Y \times Y$.
For then $\Gamma_f$ must be closed as it is the preimage of the closed diagonal $\Delta_Y$ under the continuous product map $\langle f, \text{identity}_Y\rangle : X \times Y \ni (x, y) \mapsto (f(x), y) \in Y \times Y$.
