Reversing the Direction of a Relation
The inverse of a relation reverses each ordered pair. It remains a relation even if one reversed entry has several results.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace an asymmetric example
If team A uses tools X and Y, and team B uses X, reversing yields X used by A and B and Y used by A. A function to one team would lose a pair. See relations as pairs.
Use the representation suited to the query
A dictionary from tool to lists of teams supports repeated lookups by tool after building it once. The reverse index must preserve all matches for repeated values.[1]
Swap endpoints without collapsing shared destinations
The pairs for employees A and B in group red and C in group blue invert to red paired with A and B and blue paired with C. This inverse relation still has three pairs. A source-to-single-value lookup would collapse red's two results. See reverse mapping indexes.
Original: {(A,red), (B,red), (C,blue)}
Inverse: {(red,A), (red,B), (blue,C)}
Invert again: original three pairs
Check which properties survive reversal
Reversing a symmetric relation returns the same graph. A relationship that was a function in the forward direction can fail that property after reversal. When implementing an inverse, test a repeated destination and an unused target value.