TITLE: Difference between a function and a graph of a function?
QUESTION [22 upvotes]: Formally, I learned that a function $f: X \to Y$ is a subset $f \subset X \times Y$ subject to the condition that for every $x \in X$, there is exactly one $y \in Y$ such that $(x, y) \in f$. We write $y = f(x)$.
The graph of a function $f: X \to Y$ is the set $\{(x, f(x)) : x \in X\}$.
Based on these two definitions, the graph of a function is, well, just the function (i.e $\operatorname{graph} f = f$), which makes me wonder why would you consider the "graph" of a function if it doesn't tell you anything new?

REPLY [5 votes]: Well, of course, even those most hung up on set-theoretic regimentations, don't really, really, believe that functions are identical to their graphs, i.e. identical to sets of tuples (or are identical to set-theoretic triples of domains, codomains and sets of tuples, or whatever).

Which set of pairs implements the function $fx = y$? We can use the set of pairs $\langle x, y \rangle$ but the set of pairs $\langle y, x \rangle$ would do just as well, mutatis mutandis. And which unordered sets implement the ordered pairs? Lots of choices there too. Any implementation of functions as sets involves a number of arbitrary choices. So none can be said to be 'really' the function.
Some functions are "too big" to have graphs according to standard set theories, e.g. the function that maps sets to their singletons.
And in any case, functions belong to a different logical type to objects such as sets (including sets of tuples). A one-place function $f$ takes single arguments and outputs values; a set [so to speak] just sits there. Of course, we can feed $x$ plus $f$'s graph $G$ as two arguments to a new dyadic evaluation function which returns the value $y$ just in case $(x, y) \in G$: but -- on pain of regress -- we can't keep trading in functions for their graphs.

So, the set-theoretic modelling (representation, implementation) of functions by their graphs is just that: modelling or representation or implementation, however you like to put it. And like any modelling, there are different ways to go depending on what features of what you are modelling you really care about representing. What the graph modelling (for workaday functions, if not nasties like $x \mapsto \{x\}$) nicely highlights is extensionality and plenitude (the idea that there is a function for every arbitrary pairing of arguments and values).
Whether you also want to build in codomains to your definition of a function when modelling in set terms will depend on whether that is going to matter, as I think @BrianM.Scott is saying in his comment on another answer. There is surely no question of right or wrong here, just assessments of overall neatness and convenience.