Suppose that $X$ and $K$ are metric spaces, and $K$ is compact, and the graph of $f:X\rightarrow K$ is a closed subset of $X\times K$. Prove that $f$ is continuous. Show that compactness of $K$ cannot be omitted from the hypothesis, even when X is compact.
My solution: i tried doing it by proving the continuity by sequential criterion and for this i start with a sequence $\{x_n\}_{n=0}^{\infty}$ converging to some $x\in X$. Then $S=\big(\bigcup\limits_{n=1}^{\infty} \{x_{n}\}\big)\cup \{x\}$ is compact subset of X and hence $S^*=\big(\bigcup\limits_{n=1}^{\infty} (x_{n},f(x_n))\big)\cup (x,f(x))$ is closed in $X\times K$ and since $(S\cup \{x\})\times K$ is compact hence $S^*$ is compact and hence have a convergent subsequence. i am not able to move forward. any type of help will be appreciated. Thanks in advance.