Mathematics / Graph theory basics

Graph theory basics

Dots joined by lines, and the handful of ideas that describe them: degree, paths, cycles and connectivity. Then the seven bridges puzzle that started the subject.

Beginner7 steps~6 min
Vertex — a thing: a person, a town, a land mass
Edge — a link between two vertices
Route — the edges being walked, in red
Degree — edges at a vertex; red when odd
// THE SHORT VERSION

In 30 seconds

A graph is a set of dots (vertices) with lines (edges) joining some pairs. It records only who is linked to whom, which is enough to model road maps, friendships or the web.

A vertex’s degree is its number of edges. A path is a route along edges; a cycle is a path that returns to its start; a graph is connected if every vertex can reach every other.

Euler’s rule: a walk that uses every edge exactly once exists if, and only if, the graph is connected and has zero or two vertices of odd degree.

Graph theory basics, step by step

STEPS01 / 07

Strictly, a route that may revisit vertices but not edges is called a trail; “Euler path” is the everyday name. With 0 odd vertices the walk ends where it began (an Euler circuit).

STEP 01 / 07 Vertices and edges
THE MATH
graph = vertices + edges 6 vertices: A … F 7 edges
  1. Step 1: Vertices and edges. A graph is a set of things, called vertices, and a set of links between pairs of them, called edges. People and friendships, towns and roads, web pages and links are all graphs. Only who is joined to whom matters, not where the dots are drawn or how long the lines are.
  2. Step 2: Degree. The degree of a vertex is the number of edges that meet there. C and D have degree 3, the rest have degree 2. Add up all the degrees and you always get twice the number of edges, because every edge has two ends and is counted once at each.
  3. Step 3: Paths. A path is a route that moves from vertex to vertex along edges without visiting any vertex twice. From A to F the shortest path is A, C, D, F, which uses 3 edges. A, B, C, D, E, F is a longer path between the same two vertices.
  4. Step 4: Cycles. A cycle is a path that returns to where it started: A, B, C and back to A. The triangle D, E, F is another. A cycle means there are two different ways round between its vertices. The edge C to D lies on no cycle, which will matter in the next step.
  5. Step 5: Connectivity. A graph is connected when there is a path between every pair of vertices. Ours is, but only just: take away the edge C to D and it falls into two separate pieces, called components. An edge whose removal disconnects a graph is called a bridge. Edges on a cycle are never bridges.
  6. Step 6: The bridges of Königsberg. Königsberg had seven bridges joining two river banks and two islands. Could a walk cross each bridge exactly once? In 1736 Euler threw away the map and kept only what matters: each land mass becomes a vertex, each bridge an edge. That move is usually counted as the birth of graph theory.
  7. Step 7: Euler’s rule. Each time a walk passes through a vertex it uses two edge ends, one in and one out. So every vertex except the start and the end must have even degree. Königsberg has four odd vertices: no such walk. Our graph has two, C and D, and the walk C, A, B, C, D, E, F, D uses all seven edges once.
VALUES SO FAR
vertices6count
edges7count
degrees····A … F
sum····rule
path····length 3
cycle····length 3
bridge····edge
bridges····degrees
walk····Euler
// BEFORE

Learn this first

Nothing. This concept starts from scratch.

Spotted a mistake on this page?