Skip to content
Part IA Lent Term

Graph Terminology

Vertices and Edges

A graph G=(V,E)G = (V, E) consists of a set of vertices (nodes) VV and a set of edges (arcs) EV×VE \subseteq V \times V. We only consider finite graphs where V|V| and E|E| are finite.

Directed graphs have ordered pairs (u,v)E(u, v) \in E, drawn with an arrow from uu (tail) to vv (head). uu is the source and vv the destination of the edge. Undirected graphs have unordered pairs (or the edge relation is symmetric); an undirected edge {u,v}\{u, v\} is conceptually equivalent to having both directed edges (u,v)(u, v) and (v,u)(v, u).

A simple graph has no self-loops (edges from a vertex to itself: (v,v)(v, v)) and no parallel edges (multiple edges between the same ordered pair of vertices). Unless stated otherwise, the syllabus deals with simple graphs. A multigraph allows parallel edges; a pseudograph also allows self-loops.

A weighted graph associates a real number with each edge via a function w:ERw: E \to \mathbb{R}. Weights represent cost, distance, time, capacity, or any additive metric. Unweighted graphs can be considered as having unit weight on every edge.

Degree

The degree deg(v)\deg(v) of a vertex in an undirected graph is the number of edges incident at that vertex. In directed graphs:

  • In-degree deg(v)\deg^{-}(v): number of edges entering vv.
  • Out-degree deg+(v)\deg^{+}(v): number of edges leaving vv.

Handshaking lemma: For an undirected graph, vVdeg(v)=2E\sum_{v \in V} \deg(v) = 2|E|. For directed graphs, deg(v)=deg+(v)=E\sum \deg^{-}(v) = \sum \deg^{+}(v) = |E|. A corollary: the number of odd-degree vertices in any undirected graph is always even.

Paths, Walks, and Cycles

A walk is any sequence of vertices where consecutive pairs are edges. A trail is a walk with no repeated edges. A path is a walk with no repeated vertices (except possibly the first/last). A simple path has no repeated vertices at all. The length of an unweighted path is the number of edges traversed (k1k-1 for kk vertices). For weighted graphs, the path length is the sum of edge weights along the path.

A cycle (or circuit) is a path of length at least 1 that starts and ends at the same vertex with no other vertex repeated. A graph with no cycles is acyclic.

Connectivity

An undirected graph is connected if there exists a path between every pair of vertices. A connected component is a maximal connected subgraph. The components partition the vertex set.

For directed graphs, we distinguish:

  • Weak connectivity: the underlying undirected graph (ignoring edge directions) is connected.
  • Strong connectivity: for every ordered pair (u,v)(u, v), there is a directed path from uu to vv.

Subgraphs

  • Subgraph: G=(V,E)G' = (V', E') with VVV' \subseteq V and EEE' \subseteq E.
  • Induced subgraph: select VVV' \subseteq V and include all edges from EE whose both endpoints are in VV'.
  • Spanning subgraph: V=VV' = V (contains all vertices, subset of edges).

Trees and Forests

A free tree (or simply tree) is a connected, acyclic undirected graph. Equivalent characterisations for a graph with nn vertices:

  1. Connected and has exactly n1n-1 edges.
  2. Acyclic and has exactly n1n-1 edges.
  3. Any two vertices are connected by exactly one simple path.
  4. Connected, and removing any edge disconnects the graph (minimally connected).
  5. Acyclic, and adding any edge creates exactly one cycle (maximally acyclic).

A forest is an acyclic undirected graph (a collection of disjoint trees). A forest with cc components has ncn-c edges.

Density

ClassificationEdge countExample
SparseE=O(V)\lvert E \rvert = O(\lvert V \rvert)Road network, planar graph
DenseE=Θ(V2)\lvert E \rvert = \Theta(\lvert V \rvert^2)Complete graph KnK_n

A complete graph has E=(n2)=n(n1)2|E| = \binom{n}{2} = \frac{n(n-1)}{2}. Most real-world graphs are sparse.

Example

Consider a road network: Cambridge (C), Oxford (O), London (L), York (Y). Roads: C—O (80), C—L (55), L—Y (210).

  • V={C,O,L,Y}V = \{C, O, L, Y\}, V=4|V|=4. E={(C,O),(C,L),(L,Y)}E = \{(C,O), (C,L), (L,Y)\}, E=3|E|=3.
  • deg(C)=2\deg(C)=2, deg(O)=1\deg(O)=1, deg(L)=2\deg(L)=2, deg(Y)=1\deg(Y)=1.
  • The graph is connected but not complete (missing 3 possible edges).
  • E=3=O(4)|E| = 3 = O(4), so it is sparse.

Summary

TermDefinition
GraphG=(V,E)G = (V, E)
DirectedOrdered pairs (u,v)(u, v)
UndirectedUnordered pairs {u,v}\{u, v\}
Simple graphNo self-loops, no parallel edges
Weighted graphw:ERw: E \to \mathbb{R}
DegreeIncident edges per vertex
PathSequence of distinct vertices connected by edges
CycleClosed path, no vertex repeated except start=end
ConnectedPath exists between every pair
TreeConnected and acyclic; E=V1\lvert E \rvert = \lvert V \rvert - 1
SparseE=O(V)\lvert E \rvert = O(\lvert V \rvert)
DenseE=Θ(V2)\lvert E \rvert = \Theta(\lvert V \rvert^2)

Past paper questions: y2025p1q9 (connected components, BFS on adjacency matrix).