continuous function and graph

Hello,

i have to show following statement:

If X,Y are Hausdorff spaces with Y compact. f:X->Y some map.

When the Graph Gr f:={(x,f(x)) $\displaystyle \in$ X x Y: x $\displaystyle \in $ X}

is closed in X x Y, then f must be continuous.

I'm not sure, why i need compactness of Y.

Let U be an open subset of Y. If A:=f^(-1) (U) is empty, there is nothing to show.

So we can assume that A is not empty.

Now i don't know how i can continue the proof...

have someone a idea for me?

Thank you