Mathematics RU

Practice · Chapter 46

Graph problems

Vertex degrees and the handshake lemma, whether every edge can be walked once, the shortest path by Dijkstra's algorithm and Euler's formula V − E + F = 2.

How to solve it

A graph is points (vertices) and lines between them (edges). Acquaintances, roads, bridges — all graphs. Much is told by the degrees of the vertices, the number of edges at each: they add up to twice the number of edges, and there is always an even number of odd degrees.

Step by step

  1. Degrees: their sum is $2E$, so it must be even. If it is odd, no such graph exists.
  2. Walking every edge once (an Euler path): the graph is connected and has $0$ odd vertices (you can return to the start) or $2$ (a path from one odd vertex to the other). Otherwise it is impossible.
  3. The shortest path (Dijkstra): mark vertices one by one — each time the unmarked one closest to the start — and update the distances to its neighbours.
  4. A connected planar graph: $V - E + F = 2$, counting the outer face too.
The number of vertices. The number of edges. The number of faces, the pieces of the plane, the outer one included. Example: $14$ vertices and $29$ edges: $F = 2 - 14 + 29 = 17$ faces.

Common mistakes

  • Thinking the degrees add up to the number of edges. It is twice that — each edge counts at both ends.
  • Checking the degrees for an Euler path but forgetting connectivity.
  • Marking a vertex in Dijkstra's algorithm before it is the closest, and missing a shorter detour.
  • Not counting the outer face in Euler's formula.

Example