Now set up a square table, with one row for each possible x or y and
one column for each. Fill in the cell at position (x,y) with
a true or false marker that indicates whether xRy holds. The
relation has been represented as a matrix. And in passing we have shown
that any graph can be represented as a matrix, and any matrix that
has just boolean values can be interpreted as a graph. To give yourself
concrete example, try drawing the graphs and matrices for the relations =and < as they apply to the set
.
Now I can come back to the transitive closure of a relation. A typical application is to start with a set consisting of cities, and a relation which is true if there is a direct non-stop rail link between the two cities involved. Then the transitive closure of this relation will indicate whether there is any way of travelling by rail between two places, ignoring the original requirements that the journey be direct and non-stop. In terms of graph operations this is now probably reasonably easy to visualise.
Interpreted in this new image, a reflexive closure just adds little loops to each vertex in the graph so you can do a small round trip and get back to where you started. Note the difference between being somewhere and being able to get somewhere by taking a single step of a journey--adding the loops does make a real difference.
A symmetric closure extends the rail network so that if it is possible to go from A to B then it is also possible to get back from B to A.
There are a great many natural and important problems that are naturally thought of in terms of graphs--and so relations can provide some mathematical notation and underpinning while sometimes boolean matrices may be a useful concrete representation for computers to use. Sample problems include:
A special sort of graph (and hence relation) has all arcs starting in one subset of its vertices (call that subset A), and ending in another (B), and only one arc issuing from any one vertex. This can be seen as a way of representing a function from the set A to B.
Looking at relations and functions as graphs is probably the easiest way of working out how many of them there are. For instance for a set X with size n the number of relations possible is 2n2. These range from the vacuuous one where the relation is never true to the almost equally silly one where it is always satisfied. See this by observing that each relation on X can be seen as an n by n matrix with boolean entries, so there are n2entries in all, and each can be either true or false (2 possible values) so there are 2n2 possibilities in all.