graph structures
Directed Graphs
You should know: graph basics
Overview
A directed graph (or digraph) is a graph in which edges have a direction, running from one vertex to another rather than simply connecting them. Each edge is an ordered pair (u, v), meaning there is a connection from u to v but not necessarily from v to u. Directed graphs naturally model asymmetric relationships — following on social media, one-way streets, task dependencies, and web hyperlinks. Key notions unique to digraphs include in-degree and out-degree, directed paths, strongly connected components, and directed acyclic graphs (DAGs), which forbid directed cycles and underlie scheduling and dependency resolution.
Intuition
Think of a directed graph as a city of one-way streets: you can drive from vertex A to vertex B along an edge, but that doesn't mean there's a street letting you drive back from B to A. Twitter's 'follows' relationship works the same way — you can follow a celebrity without them following you back. That asymmetry is exactly what an ordered-pair edge (u, v) captures, versus an undirected edge which is symmetric.
Formal Definition
A directed graph is an ordered pair of a vertex set and a set of ordered-pair edges:
Worked Examples
Out-degree of A counts edges leaving A: A→B and A→C, so deg⁺(A) = 2.
In-degree of C counts edges entering C: B→C and A→C, so deg⁻(C) = 2.
Answer: deg⁺(A) = 2, deg⁻(C) = 2.
Practice Problems
A digraph has edges A→B, A→C, B→D, C→D, D→A. What is deg⁻(D)?
A course-prerequisite system has edges Calc1→Calc2, Calc2→Calc3, Calc1→LinAlg. Is this digraph a DAG, and why does that matter for scheduling?
In a digraph, what does it mean for two vertices u and v to be 'strongly connected', and how does that differ from ordinary (weak) connectivity in the underlying undirected graph?
Quiz
Summary
- A directed graph's edges are ordered pairs (u, v), representing a one-way connection from u to v.
- In-degree and out-degree replace the single 'degree' of undirected graphs; both sum to |E| across all vertices.
- A digraph with no directed cycle is a DAG — the structure guaranteeing a valid topological order (scheduling, build systems, prerequisites).
References
- WebsiteWikipedia — Directed graph
Mathematics