Show that if $f:X\to Y$ is a continuous function if and only if the graph of $f$ is a closed subset of $X\times Y$ 
Given a function $f:X\to Y$, we define the graph of $f$ as the set
  $$G(f)=\{(x,f(x)),x\in X\}$$ Show that if $X$ is compact then $f$ is a
  continous function if and only if $G(f)$ is a closed subset of
  $X\times Y$.

I know that a set $X$ is called compact when every open cover of $X$ have a finite subcover. Then I need to show that


*

*If $f$ is continous then $G(f)$ is a closed subset of $X\times Y$.

*If $G(f)$ is a closed subset of $X\times Y$ then $f$ is continous.
How I can show that?

Your purported equivalence can fail in both directions, if we don't add extra assumptions on $Y$.
The implication $G(f)$ closed implies $f$ continuous can fail for compact $X$:
Let $X = [0,1]$ in the cofinite topology; this is a compact space. 
Let $Y = [0,1]$ in the discrete topology.
Define $f(x) =x$ from $X$ to $Y$, then $f$ is not continuous, as $f^{-1}[\{0\}] = \{0\}$ is not open in $X$, but $\{0\}$ is open in $Y$.
But $G(f)$ is closed in $X \times Y$: suppose $(p,q) \notin G(f)$, then $q \neq p$ and then the set $(X\setminus\{q\}) \times \{q\}$ is an open neighbourhood of $(p,q)$ that misses $G(f)$.
We can drop the compactness of $X$ and replace it by the compactness of $Y$; then the implication does hold:
Suppose then that $G(f)$ is closed. Kuratowski's theorem says that $\pi_X: X \times Y \to X$ is a closed map for compact $Y$.
Let $C \subseteq Y$ be closed and check that:
$$f^{-1}[C] = \pi_X[(X \times C)\cap G(f)]$$ which is the image of a closed set of $X \times Y$ under $\pi_X$, so $f^{-1}[C]$ is closed for all closed $C \subseteq Y$, meaning that $f$ is continuous.
The implication $f$ continuous implies $G(f)$ closed can also fail for compact $X$ (even for compact $Y$): 
Let $X = \{0,1\}$ in the discrete topology, $Y$ the same set in the indiscrete (trivial) topology. Again $f$ is the identity. This $f$ is continuous, but a basic open neighbourhood $(0,1)$ contains $\{0\} \times \{0,1\}$ which intersects $G(f)$. So $(0,1) \in \overline{G(f)} \setminus G(f)$, so $G(f)$ is not closed.
If we add the condition that $Y$ is Hausdorff, we don't need compactness of $X$ at all to see that $f: X \to Y$ continuous implies $G(f)$ is closed. This then always holds.
