Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Representation of Relations using Graph
A relation can be represented visually using a directed graph (digraph). This graphical representation makes it easy to understand which elements are related and in what direction.
How to Represent a Relation as a Graph
The rules for converting a relation into a directed graph are −
- The number of vertices equals the number of elements in the set.
- For each ordered pair (x, y) in the relation R, draw a directed edge from vertex x to vertex y.
- If there is an ordered pair (x, x), draw a self-loop on vertex x.
Example
Suppose there is a relation R = { (1, 1), (1, 2), (3, 2) } on set S = { 1, 2, 3 }. This can be represented by the following directed graph ?
In the graph above −
- The self-loop on vertex 1 represents the ordered pair (1, 1).
- The directed edge from 1 to 2 represents the ordered pair (1, 2).
- The directed edge from 3 to 2 represents the ordered pair (3, 2).
- Vertex 3 has no incoming edges and no self-loop, meaning no element maps to 3 in this relation.
Identifying Relation Properties from a Graph
The graph representation also helps identify properties of the relation at a glance −
| Property | What to Look for in Graph | R = {(1,1),(1,2),(3,2)} |
|---|---|---|
| Reflexive | Self-loop on every vertex | No (missing loops on 2 and 3) |
| Symmetric | If edge x→y exists, y→x must too | No ((1,2) exists but (2,1) does not) |
| Transitive | If x→y and y→z, then x→z must exist | Yes (no chain violates transitivity) |
Conclusion
A relation on a set can be represented as a directed graph where vertices are the set elements and directed edges represent ordered pairs. Self-loops indicate elements related to themselves. This visual representation makes it easy to identify relation properties like reflexivity, symmetry, and transitivity.
