Skip to content

Chapter 16. Directed Graphs

A directed graph is a graph in which each edge has a direction. Instead of merely saying that two vertices are adjacent, a directed graph records an ordered relation from one vertex to another.

Directed graphs are also called digraphs. Their directed edges are often called arcs. Formally, a directed graph is an ordered pair

D=(V,A), D = (V, A),

where VV is a set of vertices and AA is a set of ordered pairs of vertices. An ordered pair (u,v)(u,v) represents an arc from uu to vv. The first vertex is the tail, source, or initial vertex of the arc. The second vertex is the head, target, or terminal vertex of the arc. This ordered-pair definition is the standard distinction between directed and undirected graphs, where undirected edges are unordered pairs.

16.1 From Undirected Graphs to Directed Graphs

In an undirected graph, the edge {u,v}\{u,v\} has no direction. It connects uu and vv symmetrically. If uu is adjacent to vv, then vv is adjacent to uu.

In a directed graph, the arc (u,v)(u,v) has direction. It goes from uu to vv. The existence of (u,v)(u,v) does not imply the existence of (v,u)(v,u).

Thus the two arcs

(u,v)and(v,u) (u,v) \qquad \text{and} \qquad (v,u)

are distinct.

This distinction is essential. Many relations are asymmetric. A web page may link to another page without receiving a link back. A person may follow another person on a social network without being followed in return. A task may depend on another task without the reverse dependence being true. A directed graph records such one-way structure.

16.2 Arcs

Let D=(V,A)D = (V,A) be a directed graph. If (u,v)A(u,v) \in A, then there is an arc from uu to vv.

The vertex uu is called the tail of the arc. The vertex vv is called the head of the arc. We also say that the arc leaves uu and enters vv.

uv u \longrightarrow v

The vertex vv is an out-neighbor or successor of uu. The vertex uu is an in-neighbor or predecessor of vv. These terms are common in directed graph terminology and follow directly from the orientation of an arc.

For a vertex vv, we define its out-neighborhood by

N+(v)={uV:(v,u)A}. N^+(v) = \{u \in V : (v,u) \in A\}.

This is the set of vertices reached by arcs leaving vv.

We define its in-neighborhood by

N(v)={uV:(u,v)A}. N^-(v) = \{u \in V : (u,v) \in A\}.

This is the set of vertices that have arcs entering vv.

16.3 In-Degree and Out-Degree

In an undirected graph, the degree of a vertex counts incident edges. In a directed graph, incident arcs must be counted with direction.

The out-degree of a vertex vv, denoted deg+(v)\deg^+(v), is the number of arcs leaving vv:

deg+(v)=N+(v). \deg^+(v) = |N^+(v)|.

The in-degree of vv, denoted deg(v)\deg^-(v), is the number of arcs entering vv:

deg(v)=N(v). \deg^-(v) = |N^-(v)|.

A vertex with in-degree zero is called a source. A vertex with out-degree zero is called a sink. In the usual terminology, a source has no incoming arcs, while a sink has no outgoing arcs.

For example, suppose

V={a,b,c,d} V = \{a,b,c,d\}

and

A={(a,b),(a,c),(b,c),(c,a),(c,d)}. A = \{(a,b), (a,c), (b,c), (c,a), (c,d)\}.

Then

N+(a)={b,c},N(a)={c}. N^+(a) = \{b,c\}, \qquad N^-(a) = \{c\}.

Therefore,

deg+(a)=2,deg(a)=1. \deg^+(a) = 2, \qquad \deg^-(a) = 1.

The total out-degree over all vertices equals the total in-degree over all vertices:

vVdeg+(v)=vVdeg(v)=A. \sum_{v \in V} \deg^+(v) = \sum_{v \in V} \deg^-(v) = |A|.

Each arc contributes one to the out-degree of its tail and one to the in-degree of its head.

16.4 Simple Directed Graphs, Loops, and Multiple Arcs

A simple directed graph usually has no loops and no repeated arcs. A loop is an arc of the form

(v,v). (v,v).

It begins and ends at the same vertex.

A directed multigraph allows multiple arcs with the same tail and head. For example, it may contain several copies of (u,v)(u,v). Such graphs are useful when arcs represent distinct objects: several flights from one city to another, several communication channels, or several transitions between two states.

A directed graph with loops allows arcs from a vertex to itself. Whether loops are allowed depends on the convention of the text or application. For this book, unless otherwise stated, a directed graph means a finite directed graph without repeated arcs. Loops will be allowed only when explicitly mentioned.

16.5 Underlying Undirected Graph

Every directed graph has an underlying undirected graph. It is obtained by replacing each arc (u,v)(u,v) with the undirected edge {u,v}\{u,v\}, ignoring direction.

If both (u,v)(u,v) and (v,u)(v,u) occur, they still correspond to the same undirected edge {u,v}\{u,v\} in the underlying graph, unless multiplicities are being kept.

The underlying graph is useful when we want to study ordinary connectivity while temporarily ignoring direction. For example, a directed graph may be weakly connected because its underlying undirected graph is connected, even though not every vertex can reach every other vertex by directed paths.

16.6 Orientation of an Undirected Graph

An orientation of an undirected graph is obtained by assigning a direction to each edge.

If G=(V,E)G = (V,E) is an undirected graph, then an orientation of GG replaces each edge {u,v}\{u,v\} by exactly one of the arcs

(u,v)or(v,u). (u,v) \qquad \text{or} \qquad (v,u).

The resulting directed graph is called an oriented graph.

An oriented graph has no pair of opposite arcs between the same two vertices. That is, it cannot contain both (u,v)(u,v) and (v,u)(v,u). This distinguishes an oriented graph from a general directed graph, where both directions may occur.

Orientations are useful when an undirected relationship receives direction from a rule. A road network may assign directions to streets. A tournament may orient each edge from the winner to the loser. A dependency graph may orient an edge from a prerequisite to a dependent task.

16.7 Directed Walks, Paths, and Cycles

A directed walk is a sequence of vertices

v0,v1,,vk v_0, v_1, \ldots, v_k

such that

(vi1,vi)A (v_{i-1}, v_i) \in A

for each i=1,2,,ki = 1,2,\ldots,k.

The direction of every arc must be followed. It is not enough that the vertices are adjacent in the underlying graph.

A directed path is a directed walk with no repeated vertices. A directed cycle is a directed path together with an arc from the last vertex back to the first.

Thus a directed cycle has the form

v0v1vk1v0. v_0 \to v_1 \to \cdots \to v_{k-1} \to v_0.

Directed cycles are important because they represent circular dependence. If aa depends on bb, bb depends on cc, and cc depends on aa, then no object in the cycle can be completed before the others.

16.8 Reachability

A vertex vv is reachable from a vertex uu if there exists a directed path from uu to vv.

Reachability is directional. It may be true that vv is reachable from uu, while uu is not reachable from vv.

For example, if

abc, a \to b \to c,

then cc is reachable from aa, but aa is not reachable from cc.

Reachability is one of the central relations in directed graph theory. It appears in program analysis, dependency resolution, network routing, database queries, automata theory, and scheduling.

16.9 Strong and Weak Connectivity

Directed graphs have more than one useful notion of connectivity.

A directed graph is weakly connected if its underlying undirected graph is connected. Direction is ignored.

A directed graph is strongly connected if for every pair of vertices u,vVu,v \in V, there is a directed path from uu to vv and also a directed path from vv to uu. Standard graph theory distinguishes weak connectivity from strong connectivity in exactly this way.

Strong connectivity is stricter. It says that every vertex can reach every other vertex while respecting directions.

For example, the directed cycle

abca a \to b \to c \to a

is strongly connected. From any vertex, one can follow directions around the cycle to reach any other vertex.

The directed path

abc a \to b \to c

is weakly connected but not strongly connected. Its underlying undirected graph is connected, but there is no directed path from cc back to aa.

16.10 Adjacency Matrix of a Directed Graph

Let D=(V,A)D = (V,A) be a directed graph with vertices

V={v1,v2,,vn}. V = \{v_1, v_2, \ldots, v_n\}.

The adjacency matrix of DD is the n×nn \times n matrix MM defined by

Mij={1,if (vi,vj)A,0,otherwise. M_{ij} = \begin{cases} 1, & \text{if } (v_i,v_j) \in A, \\ 0, & \text{otherwise.} \end{cases}

Rows represent tails. Columns represent heads.

For example, if

V={a,b,c} V = \{a,b,c\}

and

A={(a,b),(b,c),(c,a)}, A = \{(a,b), (b,c), (c,a)\},

with vertex order a,b,ca,b,c, then

M=[010001100]. M = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}.

The entry in row aa, column bb is 11, because there is an arc from aa to bb. The matrix need not be symmetric. Symmetry would mean that whenever (u,v)(u,v) is present, (v,u)(v,u) is also present.

For directed multigraphs, the entry MijM_{ij} may count the number of arcs from viv_i to vjv_j. This convention is common for multidigraphs and graphs with loops.

16.11 Incidence Matrix of a Directed Graph

Another useful representation is the incidence matrix.

Let D=(V,A)D = (V,A), where

V={v1,,vn} V = \{v_1,\ldots,v_n\}

and

A={a1,,am}. A = \{a_1,\ldots,a_m\}.

The incidence matrix is an n×mn \times m matrix BB. Each column corresponds to an arc.

For an arc ak=(u,v)a_k = (u,v), one common convention is

Bik={1,if vi=u,1,if vi=v,0,otherwise. B_{ik} = \begin{cases} -1, & \text{if } v_i = u, \\ 1, & \text{if } v_i = v, \\ 0, & \text{otherwise.} \end{cases}

Thus the tail receives 1-1, and the head receives 11.

This matrix form is useful in flow problems, electrical networks, conservation laws, and optimization. The signs encode direction.

16.12 Directed Acyclic Graphs

A directed acyclic graph, or DAG, is a directed graph with no directed cycles.

DAGs are fundamental in scheduling and dependency analysis. If an arc uvu \to v means that uu must occur before vv, then a directed cycle would mean that some task must occur before itself through a chain of dependencies. This is impossible.

For example,

ab,ac,bd,cd a \to b, \qquad a \to c, \qquad b \to d, \qquad c \to d

is a DAG. It says that aa must precede both bb and cc, and both bb and cc must precede dd.

DAGs admit topological orderings, which will be studied in a later chapter. A topological ordering lists the vertices so that every arc goes from an earlier vertex to a later vertex.

16.13 Tournaments

A tournament is an orientation of a complete graph.

For every pair of distinct vertices uu and vv, exactly one of the arcs

(u,v)or(v,u) (u,v) \qquad \text{or} \qquad (v,u)

is present.

Tournaments model pairwise competitions. If uvu \to v, then uu defeated vv. Since every pair competes, exactly one directed edge is assigned between every two vertices.

Tournaments provide a simple but rich class of directed graphs. They contain many nontrivial questions about ranking, dominance, cycles, and transitive subtournaments.

16.14 Directed Graphs as Relations

A directed graph can be viewed as a binary relation on a set.

Let VV be a set. A binary relation RR on VV is a subset of

V×V. V \times V.

A directed graph D=(V,A)D = (V,A) has exactly this form, since

AV×V. A \subseteq V \times V.

Thus directed graphs provide a visual and combinatorial language for relations.

If (u,v)A(u,v) \in A, then uu is related to vv. Properties of relations correspond to properties of directed graphs:

Relation propertyGraph interpretation
ReflexiveEvery vertex has a loop
SymmetricEvery arc has the reverse arc
AntisymmetricNo two distinct vertices have arcs both ways
TransitiveIf uvu \to v and vwv \to w, then uwu \to w
AcyclicNo directed cycle

This connection explains why directed graphs appear throughout discrete mathematics, order theory, logic, and computer science.

16.15 Applications

Directed graphs model systems with one-way relations.

ApplicationVerticesArcs
Web graphWeb pagesLinks
Social networkAccountsFollows
Task schedulingTasksDependencies
Compiler analysisProgram blocksControl flow
AutomataStatesTransitions
TransportationLocationsOne-way routes
Knowledge graphEntitiesDirected relations
Version controlCommitsParent relations
Build systemsFiles or targetsDependency edges

In each case, direction carries meaning. Ignoring direction may destroy the structure of the problem.

For example, in a dependency graph, an arc

uv u \to v

may mean that vv depends on uu. Reversing this arc changes the meaning completely.

16.16 Summary

A directed graph is a graph whose edges have direction. It is written as

D=(V,A), D = (V,A),

where VV is a set of vertices and AA is a set of ordered pairs of vertices.

The main objects are arcs, tails, heads, in-neighbors, out-neighbors, in-degree, out-degree, directed paths, reachability, and directed cycles. Directed graphs support richer connectivity notions than undirected graphs, especially weak and strong connectivity.

Directed graphs are the natural language of asymmetric structure. They describe links, dependencies, flows, transitions, precedence, control, and reachability. Subsequent chapters develop these ideas through directed paths, strong components, acyclic graphs, topological ordering, weighted digraphs, and directed graph algorithms.