Reversing All Edges in a Directed Graph
The reverse graph keeps the same vertices and reverses the start and end of each directed edge.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace how reachability changes
For A to B and B to C, the reverse graph has C to B and B to A. C reaches A in the reverse exactly because A reaches C in the original. This is relation inversion applied to graph edges.
Choose multiple lookups efficiently
If many queries need incoming neighbors as well as outgoing ones, store separate indexes or build the reverse representation once. Neighbor lists can describe either orientation consistently.[1]
Use reversed edges to answer a predecessor reachability question
With A→B, B→D and C→D, reversing every arrow lets a traversal from D find B and C, then A. These are exactly the vertices that could reach D in the original graph. Reversing changes edge direction while preserving vertex IDs. See inverting a relation.
Original paths to D: A→B→D, B→D, C→D
Reversed outgoing from D: B,C
Reversed outgoing from B: A
Reachable in reverse from D: D,B,C,A
Include isolated vertices and self-loops
An isolated vertex retains an empty row. Reversing a self-loop yields the same loop. As a structural test, reversing twice should restore all original logical edges including multiplicities and attributes your graph preserves.