Counting the Degree of a Vertex

Degree counts incident edge ends. A directed graph distinguishes incoming from outgoing edges.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Count a directed example
  2. Check an undirected convention
  3. Compute incoming and outgoing counts separately
  4. Use conservation totals as a small input check

Count a directed example

With edges A to B, A to C, and C to A, A has outdegree two and indegree one. A self-loop adds one to each directed count. Directed connections provide the orientation for both calculations.

Check an undirected convention

A loop contributes two ends to undirected degree. Summing degrees then gives twice the number of edges because every edge has two ends. See parallel edges and loops for when neighbor counting must retain edge multiplicities.[1]

Compute incoming and outgoing counts separately

Consider arrows A to B, C to B, and a self-loop at B. Vertex B has indegree three and outdegree one. Its loop contributes one to each count. In an undirected interpretation a loop similarly contributes twice to degree. See loops and parallel edges.

Vertex   incoming   outgoing
A               0          1
B               3          1
C               0          1
Totals          3          3

Use conservation totals as a small input check

For a directed graph the sum of outdegrees and sum of indegrees both equal the edge count. For an undirected graph total degree is twice the edge count. A failure suggests dropped, duplicated or misclassified endpoints.

References

  1. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩