Graph Degree Calculator

Paste an edge list for an undirected or directed graph to compute vertex degrees, degree sequence, isolated and pendant vertices, and check the handshake lemma.

Graph type

In an undirected graph edges have no orientation. In a directed graph each edge goes from a tail (source) to a head (target).

Use this if you want to include isolated vertices that do not appear in any edge. Separate labels with commas or spaces.

Format: u v per line, where u and v are vertex labels (e.g. A, B, v1, 1). Extra text after the first two tokens on a line is ignored.

Graph summary

Number of vertices |V|:
Number of edges |E|:
Min degree:
Max degree:
Average degree:
Isolated vertices:
Pendant vertices (deg = 1):
Regular graph?

Degree sequence: —

Handshake lemma check (undirected): —

Vertex degrees

The table below lists each vertex with its degree. For directed graphs you also see in-degree, out-degree, total degree and a simple classification (source, sink, isolated, balanced).

Vertex Degree Type
Enter a graph and click “Calculate degrees” to see vertex degrees here.

Degree of a vertex in a graph

Let \(G = (V, E)\) be a finite graph with vertex set \(V\) and edge set \(E\). The degree of a vertex \(v \in V\) is the number of edges incident to \(v\). In an undirected graph, each loop (edge from a vertex to itself) contributes 2 to the degree.

For directed graphs (digraphs) we distinguish:

  • In-degree \(\deg^{-}(v)\): number of incoming edges to \(v\).
  • Out-degree \(\deg^{+}(v)\): number of outgoing edges from \(v\).
  • Total degree \(\deg(v) = \deg^{-}(v) + \deg^{+}(v)\).

Degree sequence and basic classifications

The degree sequence of a graph is the list of vertex degrees, usually written in non-increasing order:

\((d_1, d_2, \dots, d_n)\) with \(d_1 \ge d_2 \ge \dots \ge d_n\).

The calculator reports the degree sequence (for undirected graphs) or the sequence of total degrees (for directed graphs) and highlights some important vertex types:

  • Isolated vertices: degree 0.
  • Pendant vertices: degree 1 in an undirected graph.
  • Source (directed): in-degree 0, out-degree > 0.
  • Sink (directed): in-degree > 0, out-degree 0.
  • Balanced vertex (directed): \(\deg^{-}(v) = \deg^{+}(v)\).

Handshake lemma (undirected graphs)

In any finite undirected graph, the sum of all vertex degrees equals twice the number of edges:

\(\displaystyle \sum_{v \in V} \deg(v) = 2 |E|.\)

This is sometimes called the handshake lemma: if each edge is a “handshake” between two vertices, then counting handshakes by people gives twice the number of handshakes. An important corollary is that the number of vertices of odd degree is always even.

The calculator checks this identity numerically for the undirected mode and reports the sum of degrees and \(2|E|\).

Directed graphs and degree balances

In a directed graph every edge contributes 1 to some vertex’s in-degree and 1 to some vertex’s out-degree. Therefore

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

The calculator uses this to verify that the total in-degree and out-degree both equal the number of directed edges, which is a basic consistency check when analysing networks or adjacency lists.

Regular graphs

A graph is called regular if every vertex has the same degree. If all vertices have degree \(k\), the graph is \(k\)-regular. For example:

  • A cycle on \(n\) vertices is 2-regular.
  • A complete graph on \(n\) vertices is \((n-1)\)-regular.

The summary box flags a graph as regular if all vertex degrees (or total degrees in the directed case) are equal.

Worked examples

Undirected example

Consider the simple graph with edges \(\{A,B\}, \{A,C\}, \{B,C\}, \{C,D\}\). The degrees are:

  • \(\deg(A) = 2\)
  • \(\deg(B) = 2\)
  • \(\deg(C) = 3\)
  • \(\deg(D) = 1\) (pendant vertex)

Degree sequence: (3, 2, 2, 1), |V| = 4, |E| = 4.

The handshake lemma holds: \(2 + 2 + 3 + 1 = 8 = 2|E|\).

Directed example

Let a directed graph have edges \(A \to B\), \(A \to C\), \(C \to A\), \(C \to D\). Then:

  • \(\deg^{-}(A) = 1, \deg^{+}(A) = 2, \deg(A) = 3\)
  • \(\deg^{-}(B) = 1, \deg^{+}(B) = 0, \deg(B) = 1\) (sink)
  • \(\deg^{-}(C) = 1, \deg^{+}(C) = 2, \deg(C) = 3\)
  • \(\deg^{-}(D) = 1, \deg^{+}(D) = 0, \deg(D) = 1\) (sink)

|V| = 4, |E| = 4, sum in-degrees = sum out-degrees = 4.

FAQ – Graph degree calculator

Can I use arbitrary vertex labels?

Yes. As long as your labels do not contain spaces, you can use letters (A, B, C), strings (v1, v2), or integers (1, 2, 3). The calculator treats labels as opaque identifiers.

How are multiple edges and loops handled?

Each line in the edge list is treated as a separate edge. Multiple identical lines therefore represent multiple edges, and degrees grow accordingly. For undirected graphs a loop contributes 2 to the degree of its vertex; for directed graphs a loop contributes 1 to in-degree and 1 to out-degree of the same vertex (total degree +2).

Why specify a separate vertex list?

When you only provide edges, the vertex set is inferred from the edge endpoints. This means vertices that do not appear in any edge (isolated vertices) would not be included. The optional vertex list lets you add such vertices explicitly so they appear with degree 0.

Is this calculator suitable for very large graphs?

The calculator is designed for small to medium graphs where step-by-step inspection is useful (teaching, homework, small network analysis). For very large graphs, specialized software libraries such as NetworkX (Python) or iGraph are more appropriate.