Is the function argmin continuous? Let $X$ and $Y$ be topological spaces, and $f:X\times Y\rightarrow \mathbb{R}$ be continuous.
Now lets define the function $g:Y\rightarrow X$ as follows:
$$g(y)=\underset{x}{\operatorname{argmin}}f(x,y)$$


*

*If $g(y)$ is a point of $X$ for all $y\in Y$, is $g$ continuous?

*If $g(y)$ is a non-empty compact set of $X$ for all $y\in Y$, is the graph of $g$ closed?


If not, which is a counterexample?, and which assumptions do I need to have continuity/closed graph.
 A: For the first question you might consider the case $X = Y = \mathbb{R}$
and $f(x, y) = (xy - 1)^2 (x^2 + y^2)$. This gives $g(y) = \frac{1}{y}$ for
$y \ne 0$ and $g(0) = 0$, which clearly is not continuous at $0$.
However, the graph of $g$ is closed without any assumptions of $g(y)$, just
because $f$ is continuous.
To see that this is true, it suffices to show that for arbitrary $y \in Y$ and
$x \in X \setminus g(y)$ there is a neighbourhood of $(x, y)$ that does not
meet this graph.
Since $x \notin g(y)$ there is an $m \in X$ such that $f(m, y) < f(x, y)$.
Put $z = \frac12 f(m, y) + \frac12 f(x, y)$.
By continuity of $f$ there is a neighbourhood $V$ of $y$ such that 
$f(m, v) < z$ for all $v \in V$. It follows that $f(u, v) < z$ whenever
$(u, v)$ is a point on the graph of $g$ with $v \in V$.
Again by continuity of $f$, there is a neighbourhood $U$ of $(x, y)$ such that $f(u, v) > z$ for all $(u, v) \in U$. But then $U \cap (X \times V)$
is a neighbourhood of $(x, y)$ that does not contain any point of the graph.
