The graph of a function is the subset that “carves out” of the cartesian product .
The traditional standard definition of a graph of a function is this:
This can be understood as a special case of a graph of a functor by the following observation
For a function, define a function
Then is the characteristic function of in that the diagram
is a pullback diagram.
In other words this means that in the context of (-1)-category-enriched category theory the graph of a function , regarded as an enriched functor is the category of elements of the corresponding profunctor. More on this at graph of a functor.
It is easy to identify the properties of those subsets of that are the graphs of functions, and if they have the same graph (given and ). Consequently, it is common, especially (but not only) in material set theory, to define a function from to as such a subset, that is to identify a function with its graph. On the other hand, from a more categorial foundation, as discussed above, it's common to define a subset to be a characteristic function!
More generally, we can say that the graph of a binary relation from to is a subset of ; belongs to the graph if and only if is related to . (Note that every subset of defines a unique relation; such a subset is the graph of a function if and only if the relation is both functional and entire.)
is the relation regarded as a subset of in the traditional sense;
is the characteristic function of this subset.
So in this sense the ordinary notion of relation as a subset does really define the graph of the relation, while the relation itself is more naturally understood as the corresponding 0-profunctor/characteristic function .
The graph of a binary relation from to is related to the notion of graph from graph theory; more precisely, such relations correspond to directed loop graphs (in the sense defined at graph) with vertex set , and either can be defined as a subset of . In a similar way, spans from to correspond to directed pseudographs with vertex set .
For the case of a relation from to without , see under the cograph below.
Bill Lawvere has also considered the cograph of a function, which is dually a quotient set of the disjoint union ; is identified with if (and additional identifications may follow). However it may make more sense to define the cograph to be a quotient poset of (the discrete poset) ; we declare if (and no additional relationships follow). By regarding again a set as a 0-category, the latter notion of cograph is a special case of the notion of cograph of a functor, as follows:
wich is computed by the strict pullback
The cograph of in the sense of Lawvere is the set of connected components of this category, i.e. .
The notion of cograph of a function may be even more related to the sense of graph in graph theory; although the identifications are not done there, the cograph draws a picture in which any relation (or multispan) of any arity becomes a directed graph (or directed multigraph) whose vertex set is the disjoint union of the relation's domains. When the vertex set is broken up into a disjoint union in this way, graph theorists study this as multipartite graphs; in particular, directed bipartite graphs with vertex set broken up as correspond precisely to binary relations from to .
Accordingly, the notion of cograph of a function is a special case of the notion of cograph of a functor.
Eric: I think it might be neat to take the opportunity here to relate graph of a function more explicitly to other things here on the nLab. As I read this, I thought of a category with one object (monoid in Set?) and one morphism
Then a graph (or is it cograph?) is a category of elements of this category.
Then you could maybe talk more generally about graph of a morhism. Or something…
Toby: The above graph of a function definitely generalises to the graph of a morphism; I didn't say anything about it, because I didn't want to have to think about what categories it's possible to do this in. (Probably a regular category or something like that.)
I don't understand what you're saying above. You seem to introduce the trivial category and then ask for its category of elements. Categories don't have categories of elements, objects of categories do; but this category has just one object, so I'll use that. But the category of elements of that one object is also trivial. The real problem is that nothing in this category has to do with any function ; all you've done is label an abstract morphism with the same name ‘’. Can you try to explain again what you mean?
When we explode that simple category, we get one object (which will be a node of the graph) for each element in . We also get one morphism for any two elements and for which .
As usual, it is just an idea and I was hoping that if it made any sense at all we could clean it up and include it in the main text.
For example, let and with
When we “explode” this simple category
we get a graph with three nodes and three directed edges forming a ring.
I guess, to be a little more explicit, I can call that concrete category , i.e.
and we have a functor . Then is really a set and is really a function.
This category of elements seems to warrant being associated with the graph of a function . Furthermore, this allows us to consider the graph of an endomorphism. But then, I could be confused.
Toby: Ah, I understand now! is equipped with a functor to (or potentially to something else); I should have guessed this, since you'd linked to category of elements, and I interpreted the phrase differently. Also, is not an identity morphism of ; instead, is freely generated by an endomorphism , so its morphisms are in fact for . The a functor from to is a set equipped with an endofunction, and a functor from to is an object of equipped with an endomorphism.
OK, so if we explode this functor, then an object of the explosion is an element of , and a morphism is a natural number such that . You seem to have wanted a morphism to exist only if , but this won't work, since then you won't be able to compose morphisms . My way, you can compose them, by adding the s.
Then I get this result: If we take this function , treat a function as a special kind of relation, convert between relations and directed loop graphs (see today's graph for the definition), treat a directed loop graph as a special directed pseudograph aka digraph, and form the quiver of that digraph, then the result is the same as the above category of elements!
Eric: Neat! :) You are right. My category wasn’t even a category. Oops! But it generates a category the way you outlined. However, an endofunction does generate a digraph in the obvious way, i.e. each element of is a node and we have a directed edge if . This digraph generates a quiver and this quiver corresponds to the category of elements obtained from the category generated by the endofunction. Phew! :)
Let me recap to make sure I got it…
Given an endofunction , we can do two things with it:
The quiver and the category of elements coincide. That is cool, unfortunately, I don’t know if it is relevant to graph of a function.
Doh! Now, I think I know what I did wrong. In trying to make things simpler by considering just one object, I made them more complicated.
What we really want is a concrete category with TWO objects and and one morphism . Now, composition does not come into the picture.
Now, I think,
is the graph of a morphism .
If there is any truth to that, then this can be applied to any morphism of any concrete (or regular?) category.
PS: By the way, I think I’m confused and should probably remove this discussion unless you think there is anything worth extracting from it.
Toby: I was going to say something about what if without , but I also fell into the trap of trying the simpler one first. Yes, let's take the abstract general category (the interval category) and make it a concrete category with representing an arbitrary arrow in . Then the category of elements has the disjoint union as its set of objects, with the only nonidentity morphisms being arrows such that . Then this looks like a (simple) directed graph on the vertex set ; if we mod out by the equivalence relation generated by the adjacency relation of this graph, then we get the cograph in the sense of Lawvere. To get the graph as a subset of , we can think of as a subset of , note that every (non-loop) edge of the directed graph above (which can be thought of as a subset of ) belongs to the first summand, and restrict the target to get a subset of , which is the graph of .
Eric: I was thinking about adding the category theoretic version in your last comment as the main definition above. It is the one most suitable to the nLab I think.
Toby: What do you mean, ‘the one’? the one definition? or the one concept? What you wrote above is not a definition of what most people call the ‘graph’ of a function, which is a subset of the cartesian product . It's an interesting concept, but I don't see why it's more suitable for the nLab than the subset of , or the other ideas (the quotient set of and the simple directed graph on , which your definition at least mentions).
Eric: Moved the definition back down here. Sorry. I thought I was just transcribing what you had written.
Consider a function to be the image of the interval category of a functor with
The graph of is the category of elements .
I’m probably making a combination of mistakes. I thought you were suggesting this category of elements was the same thing as the graph of a function. My time allotted to thinking about this is 15 second spurts every 3-4 hours, so I’m bound to get confused.
Maybe what I’m after is a nice arrow theoretic definition of graph of a morphism and then a graph of a function becomes a special case. It’s obviously not a requirement, but I tend to try to rethink standard definitions here on the nLab arrow theoretically.
What I saw in the original version of this page is something that would be at home in a standard text and was hoping to nLab-ify it. Probably misguided.
Toby: It was all correct except for the claim that what it defines is the graph of the function!
Part of the problem is that the graph of a function isn't really a concept that we can try to turn around and see from another, more categorial, point of view. That's because it is itself just a way of looking at the function itself! Compare how they do it in material set theory: the function is its graph, literally. When I started this page, I didn't think that there was anything very -categorial to do in it; it was just something obvious to write in contrast to graph.
But now that you've brought up this bit with the category of elements, I do think that there is a place for it. I'll try to rewrite the page to make things clearer: that a function (or even relation) might be viewed as being given by a ‘graph’ in various senses, which we are describing here. Then we can mention all of them.
Urs Schreiber: have only had a chance to look at your conversation here now. I think that the notion of both graph as well as cograph of a function are usefully regarded as special cases of graph of a functor and cograph of a functor. I have created these entries and added more details there, and I have now also expanded the discussion above, incorporating your discussion here as well as indicating the way this fits into the more general picture.
Toby: Thanks, Urs, that's great!