MathLabs

Combinatorics and discrete mathematics

Graphs, degree, and paths

Graphs as networks of vertices and edges: degree, walks and Eulerian circuits, bipartite matching, colouring, and planarity — from the Seven Bridges of Königsberg to open questions in Ramsey theory.

IntuitionWhat is a graph?

A graph is just points (vertices) joined by lines (edges): a map of who is connected to whom. A friendship network, a road map, a molecule's bonds, pages of the web linked to each other — all of these are graphs. What matters is not where the points sit on the page, but which pairs are joined.

A graph with four vertices representing the two riverbanks and two islands of Königsberg, joined by seven edges representing the seven bridges; one vertex has five edges, the other three each have three edges.
The four landmasses of Königsberg (two riverbanks and two islands) and the seven bridges joining them, drawn as a graph: one vertex per landmass, one edge per bridge.

SchoolVertices, edges, and degree

Definition: Graph, degree

A graph G=(V,E)G = (V, E) consists of a set of vertices VV and a set of edges EE, each edge joining two vertices. The degree deg⁡(v)\deg(v) of a vertex vv is the number of edges touching it.

∑v∈Vdeg⁡(v)=2∣E∣\sum_{v \in V} \deg(v) = 2|E|

In any finite graph, the sum of all vertex degrees equals twice the number of edges: ∑v∈Vdeg⁡(v)=2∣E∣\sum_{v \in V} \deg(v) = 2|E|. In particular, the number of vertices of odd degree is always even.

Why is it true?

Each edge is counted exactly twice when we sum degrees: once from each of its two endpoints. So the sum is even, and since the even-degree vertices already contribute an even amount to the total, the odd-degree vertices must appear an even number of times.

Proof

Take any finite graph G=(V,E)G = (V, E). Build the set of all vertex-edge incidence pairs (v,e)(v, e) where vertex vv is an endpoint of edge ee, and count this set two different ways. Counting by vertex: each vertex vv contributes exactly deg⁡(v)\deg(v) incidence pairs (one for every edge touching it), so the total count is ∑v∈Vdeg⁡(v)\sum_{v \in V} \deg(v). Counting by edge: every edge e={u,w}e = \{u, w\} has exactly 22 endpoints, uu and ww, so it contributes exactly 22 incidence pairs, and summing over all ∣E∣|E| edges gives 2∣E∣2|E|.

Since both counts tally the same set of pairs, they must agree: ∑v∈Vdeg⁡(v)=2∣E∣\sum_{v \in V} \deg(v) = 2|E|. For the second claim, split the sum into vertices of even and odd degree: ∑v evendeg⁡(v)\sum_{v \text{ even}} \deg(v) is a sum of even numbers, hence even, so ∑v odddeg⁡(v)\sum_{v \text{ odd}} \deg(v) must also be even (their total 2∣E∣2|E| is even). A sum of odd numbers is even only when there is an even number of terms, so the number of odd-degree vertices OO is even.

Example: Counting degrees in K4K_4

In the complete graph K4K_4 (four vertices, every pair joined), what is ∑vdeg⁡(v)\sum_v \deg(v), and how many edges does K4K_4 have?

Solution

Each of the 4 vertices is joined to the other 3, so every degree is 3 and ∑vdeg⁡(v)=4×3=12\sum_v \deg(v) = 4 \times 3 = 12. By the handshaking lemma, ∣E∣=12/2=6|E| = 12 / 2 = 6.

Example: Snowplow and courier route planning (the Chinese Postman Problem)

A municipal snowplow must clear every street in a connected district of ∣V∣=6|V| = 6 intersections whose street-degrees are 4,4,4,4,2,24, 4, 4, 4, 2, 2, starting and ending at the depot. (1) How many street segments does the district have, and can the snowplow clear every street segment exactly once without deadheading (re-traversing an already cleared street)? (2) If a new road is built between two intersections uu and ww that previously had degree 22, changing their degrees to 33, is a closed route without deadheading still possible?

Solution

(1) By the handshaking lemma, ∑v∈Vdeg⁡(v)=4+4+4+4+2+2=20\sum_{v \in V} \deg(v) = 4+4+4+4+2+2 = 20, so the district has ∣E∣=20/2=10|E| = 20 / 2 = 10 street segments. Because the graph is connected and all six intersections have even degree (00 odd-degree vertices), Euler's circuit theorem guarantees an Eulerian circuit: the snowplow can clear every street segment exactly once and return to the depot with zero wasted mileage.

(2) Adding the edge between uu and ww raises their degrees from 22 to 33, creating 22 vertices of odd degree. By Euler's theorem, a closed Eulerian circuit no longer exists — only an open Eulerian trail starting at uu and ending at ww. To return to the depot, the snowplow must re-traverse a shortest path between uu and ww (effectively duplicating those edges so every degree becomes even again). In operations research, minimising total deadhead distance by pairing odd-degree vertices via a minimum-weight perfect matching is the Chinese Postman Problem (Mei-Ko Kwan, 1962), used daily in garbage collection, street sweeping, and power-line inspection.

UndergraduateWalks, trails, and Eulerian circuits

Definition: Eulerian circuit

A walk is a sequence of vertices where consecutive ones are joined by an edge. A trail is a walk that never repeats an edge. An Eulerian circuit is a closed trail (starts and ends at the same vertex) that uses every edge of the graph exactly once.

A connected graph with at least one edge has an Eulerian circuit if and only if every vertex has even degree. More generally, it has an open Eulerian trail between two distinct vertices u,vu, v if and only if uu and vv are exactly the two vertices of odd degree.

Why is it true?

Follow any trail; each time you pass through a vertex (other than the start/end) you use up two of its edges, so a vertex where you could get stuck (other than the two endpoints) must have even degree — this is the easy direction. The converse (even degree is enough) follows by an inductive argument: peel off closed trails and splice them together (Hierholzer's construction, 1873).

Proof

(Necessity.) Suppose a connected graph GG has an Eulerian circuit CC, a closed trail using every edge exactly once. Every time CC passes through a vertex vv other than the start/end vertex, it enters along one edge and leaves along a different, previously unused edge, consuming exactly 22 of vv's incident edges; since CC uses every edge of vv exactly once by the time it finishes, deg⁡(v)\deg(v) must be even for every vertex, including the start/end vertex where the first departing edge pairs with the final arriving edge.

(Sufficiency.) Suppose instead every vertex of the connected graph GG has even degree. Start at any vertex and greedily walk along unused edges; because every vertex has even degree, whenever the walk enters a vertex other than the start it can always leave again (an even number of incident edges can never be reduced to exactly 11 unused edge), so the walk cannot get stuck except back at the starting vertex, producing a closed trail CC. If CC already uses every edge, we are done. Otherwise, since GG is connected, some vertex vv on CC has an unused incident edge; the unused edges also all have even degree at every vertex (removing the even-degree closed trail CC preserves parity), so by the same argument they form another closed trail C′C' through vv. Splicing C′C' into CC at vv produces a longer closed trail; repeating this splicing process (Hierholzer's construction, 1873) until no unused edges remain yields an Eulerian circuit.

The same four-vertex Königsberg graph with vertex degrees marked: one vertex of degree five and three vertices of degree three, all four degrees odd.
The Königsberg graph again, this time highlighting degree: the four vertices have degrees 5, 3, 3, 3 — all odd. By Euler's theorem, no Eulerian circuit can exist, and not even an open Eulerian trail, since there are four odd-degree vertices, not two.

This is exactly Euler's original argument, and the puzzle itself is now catalogued in the library as the great problem Seven Bridges of Königsberg.

The complete graph on five vertices, K5, with all 10 edges drawn and each of the five vertices marked with degree four.
The complete graph K5K_5: every vertex has degree 4 (even), so by Euler's theorem it does have an Eulerian circuit — a closed trail using all 10 edges exactly once.

AdvancedBipartite graphs and Hall's marriage theorem

Definition: Bipartite graph

A graph is bipartite if its vertices split into two sets X,YX, Y with every edge joining a vertex of XX to a vertex of YY (no edge inside XX or inside YY). Bipartite graphs model matching problems: jobs to workers, students to schools.

The complete bipartite graph K3,3 with two groups of three vertices, all nine cross edges drawn, and the two groups shown in two different colours.
The complete bipartite graph K3,3K_{3,3}: three vertices on each side, every vertex on one side joined to every vertex on the other. A proper 2-colouring (one colour per side) shows it is bipartite.

Let GG be a bipartite graph with parts XX and YY. There is a matching that covers every vertex of XX if and only if for every subset S⊆XS \subseteq X, the neighbourhood N(S)N(S) satisfies ∣N(S)∣≥∣S∣|N(S)| \ge |S| (Hall's condition).

Why is it true?

If some SS has ∣N(S)∣<∣S∣|N(S)| < |S|, the vertices of SS have nowhere near enough neighbours to be matched injectively, so the condition is clearly necessary. That it is also sufficient is proved by finding an augmenting path whenever a matching is not yet complete (the König–Egerváry augmenting-path argument).

Proof

(Necessity.) If some S⊆XS \subseteq X had ∣N(S)∣<∣S∣|N(S)| < |S|, then the vertices of SS have fewer than ∣S∣|S| possible partners among all of YY combined, so no matching can inject SS into YY injectively — hence no matching covering all of XX can exist. So Hall's condition ∣N(S)∣≥∣S∣|N(S)| \ge |S| is clearly necessary.

(Sufficiency.) Suppose Hall's condition holds but some matching MM leaves a vertex x0∈Xx_0 \in X unmatched. Build an alternating tree from x0x_0: follow non-matching edges out of XX-vertices and matching edges back from YY-vertices, exploring all vertices reachable this way. If this tree ever reaches a YY-vertex yy not covered by MM, the path from x0x_0 to yy alternates non-matching/matching edges and has odd length, so swapping matched and unmatched edges along it (taking the symmetric difference M△PM \triangle P) strictly increases the matching size by one, contradicting that MM was already as large as possible along this branch — repeat until no unmatched x0x_0 remains, or Hall's condition is violated on the set SS of XX-vertices reached, since then every YY-vertex reached is matched back into SS, forcing ∣N(S)∣≤∣S∣−1|N(S)| \le |S| - 1. Since Hall's condition holds by assumption, this contradiction cannot occur, so every vertex of XX must eventually be matched — this is the König–Egerváry augmenting-path argument.

The Petersen graph drawn as an outer pentagon and inner pentagram connected by five spokes, 10 vertices each of degree three, coloured with three colours so that no edge joins two vertices of the same colour.
The Petersen graph: 10 vertices, each of degree 3, famous for needing 3 colours (its chromatic number) despite having no triangles, and for being a rich source of counterexamples in graph theory.

Colouring a whole map rather than an abstract graph leads to the most famous colouring question of all, the great problem Four colour theorem: every planar map can be coloured with four colours so that neighbouring regions differ. Deciding which graphs are planar in the first place is answered exactly by Kuratowski's theorem, below.

Definition: Planar graph

A graph is planar if it can be drawn in the plane with no two edges crossing (except at shared endpoints).

∣E∣≤3∣V∣−6(planar),∣E∣≤2∣V∣−4(triangle-free planar)|E| \le 3|V| - 6 \quad (\text{planar}), \qquad |E| \le 2|V| - 4 \quad (\text{triangle-free planar})

A finite graph is planar if and only if it contains no subgraph that is a subdivision of K5K_5 or of K3,3K_{3,3}.

Why is it true?

K5K_5 and K3,3K_{3,3} are themselves non-planar (checked directly with Euler's formula V−E+F=2V - E + F = 2), and any subdivision (replacing edges by paths) preserves non-planarity. Kuratowski's 1930 theorem is the surprising converse: these two graphs are the only obstructions.

Proof

(Necessity: K5K_5, K3,3K_{3,3}, and their subdivisions are non-planar.) In any connected simple planar graph with V≥3V \ge 3 drawn without crossings, every face FF is bounded by at least 33 edges and each edge borders at most 22 faces, so counting edge-face incidences gives 2E≥3F2E \ge 3F. Substituting F=E−V+2F = E - V + 2 from Euler's formula V−E+F=2V - E + F = 2 yields 2E≥3(E−V+2)2E \ge 3(E - V + 2), i.e. E≤3V−6E \le 3V - 6. For K5K_5 we have V=5V = 5 and E=10E = 10, violating 3V−6=9<103V - 6 = 9 < 10, so K5K_5 is non-planar. For the bipartite graph K3,3K_{3,3}, there are no odd cycles (hence no triangles), so every face requires at least 44 edges: 2E≥4F2E \ge 4F, which combines with V−E+F=2V - E + F = 2 to give E≤2V−4E \le 2V - 4. Since K3,3K_{3,3} has V=6V = 6 and E=9E = 9, violating 2V−4=8<92V - 4 = 8 < 9, K3,3K_{3,3} is also non-planar.

Subdividing an edge (replacing it by a path through new vertices of degree 22) does not affect whether a graph can be drawn in the plane without crossings, so any graph containing a subdivision of K5K_5 or K3,3K_{3,3} is non-planar. For the converse (sufficiency), proved by Kuratowski in 1930, one proceeds by induction on ∣V∣+∣E∣|V| + |E|: a minimal non-planar graph GG must be 33-connected, and deleting an edge ee produces a planar graph G−eG - e whose cycle around the endpoints of ee has alternating chords on both the inside and the outside, which forces a subdivision of either K5K_5 or K3,3K_{3,3} inside GG.

The cube graph Q3 drawn as two nested squares connected by four edges, 8 vertices each of degree three, with no edges crossing.
The cube graph Q3Q_3: 8 vertices (the corners of a cube), each of degree 3, bipartite, and — unlike K5K_5 and K3,3K_{3,3} — planar: it can be drawn with no crossing edges.

By the handshaking lemma, a graph with 5 edges has vertex degrees summing to

Among K4K_4, K5K_5, K3,3K_{3,3}, and the Petersen graph, which one has an Eulerian circuit?

In a bipartite graph with parts X,YX, Y, two vertices x1,x2∈Xx_1, x_2 \in X have only one common neighbour, i.e. N({x1,x2})={y1}N(\{x_1, x_2\}) = \{y_1\}. What does Hall's theorem tell us?

Which pair of graphs are exactly the forbidden subdivisions in Kuratowski's theorem?

References

  1. Vigleik Angeltveit, Brendan D. McKay (2024). R(5,5) ≤ 46 · arXiv:2409.15709 [preprint, not peer-reviewed]
  2. Marcelo Campos, Simon Griffiths, Robert Morris, Julian Sahasrabudhe (2023). Towards fully exponential bounds for the diagonal Ramsey numbers · arXiv:2303.09521 [preprint, not peer-reviewed]
  3. Reinhard Diestel (2017). Graph Theory
  4. Leonhard Euler (1736). Solutio problematis ad geometriam situs pertinentis