What is a directed graph?
A directed graph (digraph) is a graph in which every edge has a direction.
Formally: A directed graph is a set of vertices V and a set of ordered pairs of vertices E, that is, G = (V, E), where each edge is (u, v), not just {u, v}.
Main idea
An edge (u → v) means a connection only from u to v, not the other way around.
Example
If there are vertices A, B, C, and edges:
- A → B,
- B → C, then you can get from A to C, but not the other way around, if there are no reverse edges.
Typical applications
- Follows on social networks (A follows B ≠ B follows A).
- Data or process flows.
- Dependencies between tasks (for example, a dependency graph during compilation).
Summary: in a directed graph, edges lead in a specific direction, which makes connections one-way.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.