Skip to content

Chapter 17. In-Degree and Out-Degree

In an undirected graph, the degree of a vertex counts the number of edges incident with that vertex. In a directed graph, this single number splits into two numbers: the number of arcs entering the vertex and the number of arcs leaving the vertex.

These two numbers are called the in-degree and the out-degree. They measure how a vertex receives directed connections and how it sends directed connections. Standard graph terminology defines in-degree as the number of directed edges leading into a vertex, and out-degree as the number leading away from it.

17.1 Incoming and Outgoing Arcs

Let

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

be a directed graph. The set VV contains the vertices, and the set AA contains the arcs. Each arc is an ordered pair

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

The arc (u,v)(u,v) leaves uu and enters vv. The vertex uu is the tail of the arc. The vertex vv is the head of the arc.

Thus an arc has two local meanings:

RoleVertexMeaning
Tailuuthe arc leaves this vertex
Headvvthe arc enters this vertex

For a fixed vertex vv, an arc of the form

(u,v) (u,v)

is incoming to vv. An arc of the form

(v,w) (v,w)

is outgoing from vv.

Direction matters. The arc (u,v)(u,v) contributes to the out-degree of uu and to the in-degree of vv. It does not contribute to the in-degree of uu or the out-degree of vv.

17.2 In-Degree

The in-degree of a vertex vv is the number of arcs whose head is vv. It is denoted by

deg(v). \deg^-(v).

Formally,

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

This counts all vertices uu that send an arc into vv. If the directed graph is a directed multigraph, then repeated arcs are counted with multiplicity.

The superscript minus sign suggests movement into the vertex. It records incoming incidence.

For example, suppose

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

Then three arcs enter cc:

(a,c),(b,c),(d,c). (a,c), \qquad (b,c), \qquad (d,c).

Therefore,

deg(c)=3. \deg^-(c) = 3.

The arc (c,a)(c,a) leaves cc, so it does not increase the in-degree of cc.

17.3 Out-Degree

The out-degree of a vertex vv is the number of arcs whose tail is vv. It is denoted by

deg+(v). \deg^+(v).

Formally,

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

This counts all vertices uu reached by an arc leaving vv. If repeated arcs are allowed, each repeated outgoing arc is counted separately.

The superscript plus sign suggests movement out of the vertex. It records outgoing incidence.

For example, suppose

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

Then three arcs leave aa:

(a,b),(a,c),(a,d). (a,b), \qquad (a,c), \qquad (a,d).

Therefore,

deg+(a)=3. \deg^+(a) = 3.

The arc (c,a)(c,a) enters aa, so it does not increase the out-degree of aa.

17.4 In-Neighborhood and Out-Neighborhood

The in-degree and out-degree are often described through neighborhoods.

The out-neighborhood of vv is

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

It is the set of vertices reached directly from vv.

The in-neighborhood of vv is

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

It is the set of vertices that point directly into vv.

For a simple directed graph,

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

and

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

For a directed multigraph, this equality may fail if neighborhoods are treated as sets, because several arcs may connect the same ordered pair of vertices. In that case, degree counts arcs, while neighborhood size counts distinct neighboring vertices.

17.5 Example

Let

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

and

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

We compute the in-degree and out-degree of each vertex.

For aa, one arc enters it:

(c,a). (c,a).

Two arcs leave it:

(a,b),(a,c). (a,b), \qquad (a,c).

So

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

For bb, one arc enters it:

(a,b). (a,b).

One arc leaves it:

(b,c). (b,c).

So

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

For cc, four arcs enter it:

(a,c),(b,c),(d,c),(e,c). (a,c), \qquad (b,c), \qquad (d,c), \qquad (e,c).

Two arcs leave it:

(c,a),(c,d). (c,a), \qquad (c,d).

So

deg(c)=4,deg+(c)=2. \deg^-(c)=4, \qquad \deg^+(c)=2.

For dd, one arc enters it:

(c,d). (c,d).

One arc leaves it:

(d,c). (d,c).

So

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

For ee, no arcs enter it. One arc leaves it:

(e,c). (e,c).

So

deg(e)=0,deg+(e)=1. \deg^-(e)=0, \qquad \deg^+(e)=1.

The result is summarized below.

VertexIn-degreeOut-degree
aa12
bb11
cc42
dd11
ee01

17.6 Sources and Sinks

A vertex with in-degree zero is called a source. It has no incoming arcs. A vertex with out-degree zero is called a sink. It has no outgoing arcs. These names are standard in directed graph theory.

Thus vv is a source if

deg(v)=0. \deg^-(v)=0.

The vertex vv is a sink if

deg+(v)=0. \deg^+(v)=0.

In the example above, ee is a source, since no arc enters ee. There is no sink, since every vertex has at least one outgoing arc.

Sources and sinks are important in applications. In a dependency graph, a source may represent a task with no prerequisites. A sink may represent a task on which no later task depends. In a flow network, a source sends flow into the network, while a sink receives flow from the network.

17.7 Balanced Vertices and Balanced Directed Graphs

A vertex vv is balanced if its in-degree equals its out-degree:

deg(v)=deg+(v). \deg^-(v) = \deg^+(v).

A directed graph is balanced if every vertex is balanced. Balanced directed graphs are important in the study of Eulerian circuits, because a directed Eulerian circuit requires each vertex to have the same number of incoming and outgoing arcs, together with the appropriate connectivity condition.

For example, in the directed cycle

abca, a \to b \to c \to a,

each vertex has one incoming arc and one outgoing arc. Therefore each vertex is balanced.

In contrast, in the directed path

abc, a \to b \to c,

we have

deg(a)=0,deg+(a)=1, \deg^-(a)=0, \quad \deg^+(a)=1, deg(b)=1,deg+(b)=1, \deg^-(b)=1, \quad \deg^+(b)=1, deg(c)=1,deg+(c)=0. \deg^-(c)=1, \quad \deg^+(c)=0.

Only bb is balanced.

17.8 Total In-Degree and Total Out-Degree

For every finite directed graph,

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

This identity is the directed version of the handshaking lemma. Each arc has exactly one tail and exactly one head. Therefore each arc contributes 11 to the total out-degree and 11 to the total in-degree.

The proof is immediate from double counting.

Count the arcs by their tails. Each arc is counted once in the out-degree of its tail, so

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

Count the same arcs by their heads. Each arc is counted once in the in-degree of its head, so

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

Therefore the two sums are equal. This formula is a standard property of directed graphs.

17.9 Loops

A loop is an arc of the form

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

It leaves vv and enters vv at the same time. Therefore a loop contributes 11 to the out-degree of vv and 11 to the in-degree of vv. This convention preserves the identity

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

For example, if A={(a,a)}A = \{(a,a)\}, then

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

The single loop is counted once as incoming and once as outgoing.

17.10 Degree Sequences of Directed Graphs

The degree sequence of a directed graph records the in-degree and out-degree of each vertex.

For a directed graph with vertices

v1,v2,,vn, v_1, v_2, \ldots, v_n,

the directed degree sequence may be written as

((deg(v1),deg+(v1)),(deg(v2),deg+(v2)),,(deg(vn),deg+(vn))). ((\deg^-(v_1),\deg^+(v_1)), (\deg^-(v_2),\deg^+(v_2)), \ldots, (\deg^-(v_n),\deg^+(v_n))).

Some authors list the out-degree first. The convention must be stated before use.

A degree sequence is a graph invariant. If two directed graphs are isomorphic, then their degree sequences agree after a suitable relabeling of vertices. The converse does not hold in general. Two non-isomorphic directed graphs may have the same degree sequence.

A necessary condition for a list of pairs

(d1,d1+),,(dn,dn+) (d_1^-,d_1^+), \ldots, (d_n^-,d_n^+)

to be the degree sequence of a finite directed graph is

i=1ndi=i=1ndi+. \sum_{i=1}^n d_i^- = \sum_{i=1}^n d_i^+.

Both sums must equal the number of arcs. This condition alone may not be sufficient when loops or multiple arcs are restricted.

17.11 Degree and Adjacency Matrices

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

v1,,vn. v_1,\ldots,v_n.

Its adjacency matrix 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}

In a simple directed graph, the out-degree of viv_i is the sum of row ii:

deg+(vi)=j=1nMij. \deg^+(v_i) = \sum_{j=1}^n M_{ij}.

The in-degree of vjv_j is the sum of column jj:

deg(vj)=i=1nMij. \deg^-(v_j) = \sum_{i=1}^n M_{ij}.

Rows describe arcs leaving a vertex. Columns describe arcs entering a vertex.

For example, let

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

The first row has sum 22, so

deg+(v1)=2. \deg^+(v_1)=2.

The first column has sum 11, so

deg(v1)=1. \deg^-(v_1)=1.

This matrix view is useful in algorithms and spectral graph theory. It allows degree calculations through row sums and column sums.

17.12 Degree and Incidence Matrices

The incidence matrix also records in-degree and out-degree.

Let BB be the directed incidence matrix using the convention

Bik={1,if vi is the tail of arc ak,1,if vi is the head of arc ak,0,otherwise. B_{ik} = \begin{cases} -1, & \text{if } v_i \text{ is the tail of arc } a_k, \\ 1, & \text{if } v_i \text{ is the head of arc } a_k, \\ 0, & \text{otherwise.} \end{cases}

Then the number of 1-1 entries in row ii is the out-degree of viv_i. The number of 11 entries in row ii is the in-degree of viv_i.

This representation is especially useful when arcs carry flow. A positive entry means flow enters the vertex through that arc. A negative entry means flow leaves the vertex through that arc.

17.13 Interpretation in Networks

In-degree and out-degree often have direct meaning.

NetworkIn-degreeOut-degree
Web graphnumber of pages linking to a pagenumber of links from a page
Social follow graphnumber of followersnumber of followed accounts
Citation graphnumber of later papers citing a papernumber of cited references
Dependency graphnumber of prerequisites or dependents, depending on conventionopposite direction count
Road networknumber of incoming one-way roadsnumber of outgoing one-way roads
Control-flow graphnumber of incoming control pathsnumber of outgoing control paths

The direction convention must always be checked. In a dependency graph, one author may write uvu \to v to mean uu must happen before vv. Another may write uvu \to v to mean uu depends on vv. These conventions reverse the interpretation of in-degree and out-degree.

The mathematics remains the same. The interpretation depends on the meaning assigned to each arc.

17.14 Common Mistakes

A common mistake is to count adjacent vertices without considering direction. In a directed graph, adjacency alone does not determine degree. One must distinguish incoming arcs from outgoing arcs.

Another mistake is to assume that (u,v)(u,v) and (v,u)(v,u) are the same. They are different arcs. If both are present, each contributes separately.

A third mistake is to forget the loop convention. A loop contributes to both in-degree and out-degree. It does not contribute twice to either one.

A fourth mistake is to interpret degree sequence as a complete description of a graph. Degree sequences give useful summaries, but they rarely determine a directed graph uniquely.

17.15 Summary

In-degree and out-degree refine the notion of degree for directed graphs.

The in-degree of vv counts arcs entering vv:

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

The out-degree of vv counts arcs leaving vv:

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

A source has in-degree zero. A sink has out-degree zero. A balanced vertex has equal in-degree and out-degree.

For every finite directed graph,

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

This identity follows because every arc has one tail and one head. In-degree and out-degree are elementary local quantities, but they support many later topics: directed paths, strong connectivity, Eulerian circuits, flow networks, ranking systems, dependency graphs, and directed graph algorithms.