Skip to main content
Examonaut

Topic 1 · Lesson 3 of 5

Graphs and their language

The vocabulary

A graph is a set of vertices (or nodes) joined by edges (or arcs). A network is a graph whose arcs carry weights, numbers such as lengths or costs. A digraph has directed arcs, drawn with arrows.

  • The degree (or valency) of a vertex is the number of arcs that meet there. A loop adds 2.
  • A walk is a sequence of arcs, each starting where the last ended. A trail is a walk with no arc repeated; a path is a walk with no vertex repeated.
  • A cycle is a closed path: it ends where it starts and repeats no other vertex. A Hamiltonian cycle visits every vertex exactly once and returns to the start.
  • A graph is connected if there is a path between every pair of vertices.
  • A simple graph has no loops and no more than one arc between any pair of vertices.
  • A subgraph is part of a graph: some of its vertices and arcs.
  • A tree is a connected graph with no cycles. A tree with nn vertices has exactly n−1n - 1 arcs. A spanning tree of a graph is a subgraph that is a tree and includes every vertex.
  • The complete graph KnK_n has nn vertices, each joined to every other: 12n(n−1)\frac{1}{2}n(n - 1) arcs, and every vertex has degree n−1n - 1.
  • Two graphs are isomorphic if they are the same graph drawn differently: there is a way to match up their vertices so that arcs match arcs.

The handshaking lemma

Every arc has two ends, so it adds 2 to the total of the degrees. Therefore

sum of degrees=2×number of arcs\text{sum of degrees} = 2 \times \text{number of arcs}

The sum of the degrees is always even, so the number of vertices of odd degree is always even. This is a quick check on any degree list: there is no graph with degrees 3,3,2,13, 3, 2, 1, because the total, 9, is odd.

Eulerian and semi-Eulerian graphs

A connected graph is Eulerian if there is a closed trail that uses every arc exactly once. This happens exactly when every vertex has even degree: each time the trail passes through a vertex it uses two arcs, one in and one out.

A connected graph is semi-Eulerian if it has exactly two vertices of odd degree. Then there is a trail that uses every arc exactly once, but it must start at one odd vertex and finish at the other. These facts are the basis of the route inspection algorithm.

Matrices

An adjacency matrix has a row and a column for each vertex; the entry is the number of arcs joining the two vertices (a loop counts 2 on the diagonal under some conventions, so read the question). The sum of a row is the degree of that vertex. A distance matrix gives the weight of the arc between each pair of vertices, with a dash where there is no arc. For an undirected graph both matrices are symmetric.

Practise this topic

Both are part of Premium.