1. Introduction

In this tutorial, we’ll explain node degrees in a graph.

2. Node Degree

Let G=(V, E) be a graph.

The degree of a node \boldsymbol{u \in V} is the number of edges with \boldsymbol{u} at one end.

If the graph is simple, there can be no more than one edge between any two nodes. In that case, the degree of a node is equal to the number of its neighbors.

For example, the degree of A is 4, and the degree of B is 5 in this graph since they have 4 and 5 neighbors, respectively:

Node degrees in an undirected graph

3. Directed Graphs

We differentiate between a node’s indegree and outdegree in a directed graph.

The indegree of a node u is the number of edges whose target is u. The outdegree of u is analogously defined. It’s the number of edges whose source is u.

In the example below, the indegree of A is 3, and its outdegree is 1:

Indegree and outdegree in a directed graph.

The degree of a node is equal to the sum of its indegree and outdegree. Only nodes in a directed graph have the indegree and outdegree.

4. Degree Distribution

The degree distribution of a graph shows, for each possible degree \boldsymbol{k \in \{0, 1, 2, \ldots \}}, the fraction of nodes whose degree is \boldsymbol{k}.

Let n_k be the number of nodes whose degree is k. The degree distribution P is:

    \[P(k) = \frac{n_k}{n}\]

where n is the total number of nodes in the graph.

This way, we get a probability distribution over natural numbers. We can use it to describe a graph or simulate graphs in numerical experiments.

For example, the distribution of the node degrees in the undirected graph above is:

    \[\begin{pmatrix} 0 & 1 & 2 & 3 & 4 & 5 & \geq 6\\ 0 & 5/8 & 1/8 & 0 & 1/8 & 1/8 & 0 \end{pmatrix}\]

5. Conclusion

In this article, we explained a node’s degree, indegree, and outdegree.

The degree of a node is the number of edges incident to it. In directed graphs, a node’s indegree is the number of edges directed into it, whereas its outdegree is the number of edges directed out of it.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.