Let $f: R \to R$ be a function such that the closure of its graph contains as a subset the graph of a uniformly continuous function. Does there exist a dense subset $S$ of $R$ such that the restricted function $f|S: S \to R$ is uniformly continuous?



A problem in real analysis of a topological nature
Consider the following modification of the Dirichlet "popcorn" function:
$$f(x) = \begin{cases} 1/q, & \text{$x \in \mathbb{Q}$, $x=p/q$ in lowest terms} \\
-1, & x \notin \mathbb{Q},\, x < 0 \\
-2, & x \notin \mathbb{Q}, \, x > 0.\end{cases}$$
Since every real number can be approximated by rationals with arbitrarily large denominator, the closure of the graph of $f$ contains the $x$-axis, which is the uniformly continuous function $0$. 


Let $S \subset \mathbb{R}$ be dense. If $f|\_S$ is uniformly continuous, then it extends to a unique uniformly continuous function $g$ on all of $\mathbb{R}$, and we have $f=g$ on $S$. 


If $S$ contains a negative irrational number $x$, then $g(x) = f(x) = -1$. Let $y$ be any positive number in $S$. If $y$ is rational, we have $g(y) = f(y) = 0$. Then by the continuity of $g$, there would have to be some $z \in S$ with $f(z) = g(z) \in (-3/4, -1/4)$ which is impossible. If $y$ is irrational, we get a similar contradiction since $g(y) = f(y) = -2$. So $S$ does not contain any negative irrational. Similarly, $S$ does not contain any positive irrational. 


So we must have $S \subset \mathbb{Q}$. But this is similarly impossible. The rationals in $S$ cannot all have the same denominator (in lowest terms), so let $x\_1 = p\_1/q\_1, x\_2 = p\_2/q\_2 \in S$, where $q\_1 < q\_2$. Then by the continuity of $g$ there must be some $y \in S$ with $f(y) = g(y) \in (\frac{1}{q\_1}, \frac{1}{q\_1+1})$, but $f$ never takes on any such value.


