Lecture 24

\( \newcommand{\set}[1]{\{#1\}} \newcommand{\comprehension}[2]{\{#1\,\vert\,#2\}} \newcommand{\size}[1]{\left\vert#1\right\vert} \newcommand{\true}{\top} \newcommand{\false}{\bot} \newcommand{\limplies}{\rightarrow} \newcommand{\divides}{\mathbin{\vert}} \newcommand{\mult}{\mathbin{\cdot}} \newcommand{\xor}{\oplus} \newcommand{\union}{\cup} \newcommand{\intersect}{\cap} \newcommand{\complement}[1]{\overline#1} \newcommand{\powerset}{\mathcal{P}} \newcommand{\ixUnion}{\bigcup} \newcommand{\ixIntersect}{\bigcap} \newcommand{\Div}{\mathrm{div}} \newcommand{\gcd}{\mathrm{gcd}} \newcommand{\divmod}{\mathop{\mathbf{divmod}}} \newcommand{\div}{\mathop{\mathbf{div}}} \newcommand{\mod}{\mathop{\mathbf{mod}}} \newcommand{\ceiling}[1]{\lceil#1\rceil} \newcommand{\floor}[1]{\lfloor#1\rfloor} \DeclareMathOperator{\Pr}{Pr} \DeclareMathOperator{\rng}{rng} \DeclareMathOperator{\lcm}{lcm} \DeclareMathOperator{\deg}{deg} \DeclareMathOperator{\E}{E} \DeclareMathOperator{\V}{V} \DeclareMathOperator{\T}{T} \DeclareMathOperator{\O}{O} \newcommand{\abs}[1]{\left\lvert#1\right\rvert} \newcommand{\indeg}{\mathop{\deg^-}} \newcommand{\outdeg}{\mathop{\deg^+}} \)

Graph Theory: Basics

The term graph is a bit overloaded. What probably comes to your mind are the familiar plots of functions from calculus:

Plot of the function f(x) = x^2(x-1).

Certainly, this is the sort of example that Google coughs up if you do an image search for “graph.“

In Computer Science and Combinatorial Mathematics, a plot is a structure like this:

A simple graph.

The relevant features here are the vertices (a.k.a., nodes) of the graph, which are simply the dark circles, and the edges (a.k.a., arcs) of the graph, each of which connects two distinct vertices, which are called the endpoints of the edge.

Let's begin with Rosen's definition of a graph:

Definition 24.1 A graph $G = (V,E)$ consists of $V$, a non-empty set of vertices (or nodes), and $E$, a set of edges. Each edge $e \in E$ has either one or two endpoints vertices associated with it, called its endpoints. An edge is said to connect its endpoints.

I find this definition to be less than fully complete, and less than fully accurate, but these are merely quibbles, and in large part, a consequence of the flexibility and adaptability of basic notion of a graph.

Let's work through a few simple notions.

You'll note that Rosen said that an edge can have one or two endpoints. The simple graph above only has edges with two endpoints. Edges with a single endpoint are known as loops, as the following diagram illustrates:

A graph with loops.

Another possibility that's intrinsic to this formalism is the possibility of multiple edges connecting the same pair of vertices, e.g.,

A graph with multiple edges.

In some applications, we want to consider directed edges, where there's a designated initial and terminal vertex associated with each edge, rather than an undifferentiated pair. Directed edges are the “one-way streets” of the graph theory world.

A directed graph.

If a graph contains only undirected edges, we'll sometimes call it an undirected graph, albeit only for emphasis as this is the default. If a graph contains only directed edges, then it is a directed graph. Note that it is possible (in the expanded sense in which we're working) for a graph to contain both directed and undirected edges, just as a city can have both one-way and two-way streets.

Definition 24.2 A simple graph is an undirected graph without loops or multiple edges.

In many theoretical contexts, graphs are taken to be simple unless otherwise specified. Be warned!

Graphs are often used to model networks, not only in the sense of POTS (plain old telephone system) or computer networks, but also social networks, in which people are modeled as vertices, and the presence of some sort of relationship between them as an edge. A good pair of examples that illustrate the possible complexities that graphs are intended to model can be considered by contrasting friends on Facebook (a symmetric relation best modeled by undirected edges) with followers on Twitter (an asymmetric relation best modeled by directed edges). Note as well that we've segued from technological/physical systems to social systems, and that graph theory finds considerable application within the social sciences. Note also that Chapter 10.1 of Rosen contains many other examples of real-world graphs.

One question that might have occurred to you (but probably not) is why we don't formalize simple graphs as finite sets together with an anti-reflexive, symmetric binary relation. Obviously we could, but doing so offers no advantage (aside from ease of formalization), and the very real disadvantage that it makes it harder to formalize various useful extensions of the theory. For example, it's common to associate a real number with edges in a graph, e.g., representing the length of an edge in the case of a transportation network, or the bandwidth of an edge in the case of a communication network. By reifying the edges, we give ourselves something to hang additional properties onto, and this makes for easier going later.

There is an enormous amount of terminology around graphs. Fortunately, most of it is based on simple analogies with real-world systems, and so the definitions can often be intuited. Much of today's lecture will be an introduction to terminology, but it's good to know that there are Glossaries of graph theory terms on the web.

Standard terminology for undirected graphs

Definition 24.3 Two vertices $u$ and $v$ of an undirected graph $G$ are adjacent (or neighbors if $u$ and $v$ are endpoints of an edge $e$ in $V$. Such an edge is said to be incident to $u$ and $v$, or to connect them.

Definition 24.4 The set of all neighbors of a a vertex $v$ in $G$, denoted by $N(v)$, is called the (open) neighborhood of $v$. The closed neighborhood of $v$ is $N(v) \union \set{v}$. If $A \subseteq V$, then $N(A) = \ixUnion_{v\in A} N(v)$.

Definition 24.5 The degree of a vertex $v$ in $G$, denoted $\deg(v)$, is the number of edges in $E$ incident to $v$, except that a loop counts twice.

Theorem 24.6 (The Handshake Theorem) Let $G = (V,E)$ be an undirected graph with $m$ edges. Then

\begin{equation*} \sum_{v \in V}\deg(v) = 2 \mult \size{E} \end{equation*}

Proof Each edge contributes $2$ to the degree sum.

$\Box$ Theorem 24.6

Example 24.7 Consider a graph $G$ with 10 vertices, all of degree $6$. What is $\size{E}$?

We just note that $\sum_{v \in V}\deg(v) = 10 \mult 6 = 60 = 2 \mult \size{E}$, so $\size{E}=30$.

Corollary 24.8 An undirected graph must have an even number of vertices of odd degree.

Standard terminology for directed graphs

Definition 24.9 In the case of an directed graph, if $e$ is an edge from $u$ to $v$, i.e., $u$ is the initial vertex of $e$, and $v$ is its terminal vertex, then we'll say $u$ is adjacent to $v$, and $v$ is adjacent from $u$.

Adapting the notion of degree from undirected graphs to directed graphs creates both the opportunity and need to distinguish adjacency to, and adjacency from.

Definition 24.10 The in-degree of a vertex $v$ is the number of edges that point to $v$, i.e., $\size{\comprehension{(u,v) \in E}{u \in V}}$. Likewise, the out-degree of a vertex $v$ is the number of edges that originate at $v$, i.e., $\size{\comprehension{(v,u) \in E}{u \in V}}$. We'll denote the in-degree and out-degree of a vertex $v$ by $\indeg(v)$ and $\outdeg(v)$ respectively. If this seems backwards to you, think of Kirchhoff's voltage law, and be enlightened.

We have the following analog to the handshaking theorem for directed graphs:

Theorem 24.11 Let $G=(V,E)$ be a directed graph. Then

\begin{equation*} \sum_{v\in V} \indeg(v) = \sum_{v\in V} \outdeg(v) = \size{E} \end{equation*}

Each edge contributes exactly one to both the in-degree and out-degree sum.

Some special classes of graphs

Example 24.12 The complete graph on $n$ vertices is the simple graph $K_n = (E,V)$ where $\size{V} = n$, and every distinct pair of vertices are neighbors

Complete graphs.

Example 24.13 The cycle graph on $n$ vertices is the simple graph $C_n=(E,V)$ where $V= \set{v_1,\ldots,v_k}$, and there's an edge between $v_i$ and $v_j$ if and only if $j = i+1 \mod k$, i.e., there's an edge from $v_1$ to $v_2$, from $v_2$ to $v_3$, $\ldots$, and from $v_k$ to $v_1$.

Cycle graphs.

Example 24.14 The wheel graph on $n$ vertices $W_n$ augments $C_n$ for $n\geq 3$ with a “center” radius $v_0$, and “spokes” from $v_0$ to each of the cycle vertices.

Wheel graphs.

Example 24.15 The $n$-cube has vertices of the form $\set{0,1}^n$, and vertices are connected iff they differ in a single coordinate.

n-cubes.

*Exercise 24.16 How many edges do $K_n$, $C_n$, $W_n$ and the $n$-cube have? Order them from asymptotically smallest to largest.

Bipartite Graphs

A common situation is that a graph encodes a relationship between disjoint sets, e.g., workers, and the tasks they're able to perform. This leads naturally to the following definition:

Definition 24.17 A graph $G=(V,E)$ is bipartite if there exist disjoint $V$ is the disjoint union of sets $V_1$ and $V_2$ such that all of the edges in $E$ connect a vertex in $V_1$ with a vertex in $V_2$, i.e., there are no edges from $V_1$ to itself, or from $V_2$ to itself. Such a $(V_1,V_2)$ is called a bipartition of the vertex set $V$ of $G$.

A useful way to think about bipartite graphs is that they are precisely the graphs that can be two-colored, i.e., we can assign two colors (let's say blue and red) to the vertices of $V$ so that no two blue, and no two red, vertices are adjacent.

A bipartite graph.

Definition 24.18 A matching in a simple graph $G=(V,E)$ is a subset $M$ of $E$ such that no two edges in $E$ share an incident vertex. The set of vertices incident to an edge in a matching are said to be matched, the other vertices are unmatched. A maximal matching is a matching that can't be properly extended, i.e., every edge in $E \setminus M$ is incident to a vertex matched in $M$. A maximum matching is a matching that contains as many edges as possible. A matching $M$ in a bipartite graph $G=(V,E)$ with bipartition $(V_1,V_2)$ is complete from $V_1$ to $V_2$ if $M$ has no unmatched vertices in $V_1$, i.e., $\size{M} = \size{V_1}$.

A matching in a bipartite graph.

*Exercise 24.19 Give an example of a graph $G=(V,E)$ and a matching $M$ which is maximal, but not maximum.

Note that a complete matching is, in fact, the graph of a function from $V_1$ to $V_2$, and so is a very interesting object.

A brief note on graph terminology. I don't usually find much opportunity to speak to culture wars here -- ours is a technical rather than a social discipline, which regretfully is sometimes all too clear -- but there's a need here. Much of the informal language of graph theory comes from familiar family relationships. Thus, we'll speak of parents or children in the context of trees (a special sort of directed graph), or sometimes even mothers and daughters. Sometimes “marriages” are used as a synonym for matchings, with the clear implication that the bipartition is by gender. This latter usage is beginning to feel a bit dated, at least to me, which hints that the other usages should be, but my antenna isn't yet tuned to pick it up. I'd chalk this language up to a certain social obliviousness that is endemic among mathematicians, but for a particular class of mathematical joke which uses graph theory to hit at homosexuality as a subject that is taboo, and therefore humorous. All I can say for someone who is offended by this is that we'll all likely be judged as socially oblivious, and even morally wanting, by the standards of those who follow. Such is the human condition.

Theorem 24.20 (Hall's Matching Theorem) The bipartite graph $G=(V,E)$ has a complete matching from $V_1$ to $V_2$ if and only if $\size{N(A)} \geq \size{A}$ for all subsets $A$ of $V_1$.

The proof is in Rosen, p. 660. I don't have anything to add to it, so I'll leave it there as is.