156. Connectivity in graphs

We talk about walks, paths and circuits in graphs in much the same way as for digraphs.

156.1 Definition: walk

A walk from node $p$ to node $q$ in a graph is a sequence

$$\langle n_{0},e_{1},n_{1},e_{2},\ldots,n_{k-1},e_{k},n_{k}\rangle$$

of alternating nodes and edges for which $n_{0}=p$, $n_{k}=q$, and $e_{i}$ is incident on $n_{i-1}$ and $n_{i}$ for $i=1,2,\ldots,k$. The length of such a walk is $k$, which is the number of edges occurring in the list (counting repetitions), or one less than the number of nodes ocurring in the list.

156.2 Definition: path

A path in a graph is a walk in which no edges are repeated. A simple path is a path in which no nodes are repeated.

156.3 Definition: circuit

A circuit is a path (not a walk) from a node to itself, and a cycle is a circuit in which no nodes are repeated except that the beginning and end are the same.

156.3.1 Fact It is easy to see (eliminate circuits) that if there is a walk between two nodes then there is a simple path between them.

156.4 Definition: connected

A graph is connected if there is a path (hence a simple path) between any two nodes. If $p$ is a node in a graph, let $C(p)$ denote the set consisting of $p$ and of all nodes $q$ for which there is a path between $p$ and $q$. The sets $C(p)$ are called the connected components of the graph $G$.

156.4.1 Fact Part (a) of the theorem below implies that two nodes in a graph are joined by a path if and only if they are in the same connected component. A graph is therefore connected if and only if it has just one connected component.

156.5 Theorem

Let $G$ be a graph.

a) Let $p$ be a node in $G$. For any two nodes $q$ and $r$ in $C(p)$ there is a path from $q$ to $r$.

b) If $q\in C(p)$ then $C(p)=C(q)$.

c) The set $\{C(p)\mid p\in G_{0}\}$ is a partition of $G$.

Proof For (a), if $p=q$ or $p=r$ there is a path from $q$ to $r$ by definition of $C(p)$. Otherwise, just connect the path from $p$ to $q$ to the path from $p$ to $r$. The result might only be a walk, but by eliminating circuits, you get a path. That proves (a).

If $q\in C(p)$, (a) implies there is a path from $p$ to $r$ if and only if there is a path from $q$ to $r$, so (b) follows. Finally, any node $p$ is an element of $C(p)$; this and (b) implies that every node is in exactly one set $C(p)$, so the sets $C(p)$ form a partition of the nodes. That proves (c).

156.6 Definition: distance

The distance between two nodes $p$ and $q$ in a connected graph is the length of the shortest simple path between $p$ and $q$.

156.6.1 Example In the right graph of Figure (152.1), the distance between nodes $d$ and $f$ is 3. There are of course simple paths of length 4 and 5 between nodes $d$ and $f$, but the shortest one has length 3.

156.7 Definition: diameter

The diameter of a connected graph is the maximum distance between any two nodes in the graph.

156.7.1 Example The diameter of the graph just mentioned is 3.

Pages 236–237 of the book (PDF).