Reading: MCS 10.1

We reviewed RSA; see last lecture's notes

- Basic terminology
- directed graph, undirected graph, vertex, edge, in-degree, out-degree, degree

sum of degrees is \(2|E|\)

handshaking theorem

set up bridges of Königsberg

**Review exercises:**Our definition of "directed graph" is the same as "relation". Are self-loops allowed? What about multiple edges between vertices?

A labelled graph is one that has labels taken from some set \(X\) on each edge. Give a reasonable formal definition.

**Note:** Many references use slightly different definitions for many of these terms. Some allow multiple edges between two vertices, while others don't; some allow self loops, others don't. When reading about graphs, check the author's definitions for details before making assumptions.

A **directed graph** is a binary relation on a set \(V\). Equivalently, it is a pair of sets \(V,E\) where \(E \subseteq V \times V\). The elements of \(V\) are called **vertices**; the elements of \(E\) are called **edges**. We typically draw graphs with a point for each vertex and a line connecting \(u\) and \(v\) if \((u,v) \in E\).

Most of the time, we will restrict our attention to **finite** graphs: those where \(V\) is finite.

In an **undirected graph**, the edges don't have directions. You can think of them as unordered pairs of vertices. Another way to define them is that they are equivalence classes of edges under the relation \((u,v) \sim (v,u)\). We won't rely on this viewpoint, but I mention it to reinforce the idea that equivalence classes are a good way of ignoring information (direction, in this case).

Given a vertex \(v\) in a directed graph, the **in-degree** of \(v\) is the number of edges leading into \(v\). The **out-degree** of \(v\) is the number of edges leading out of \(v\). The **degree** of \(v\) is the sum of the two. Note that this means that self-loops are counted twice.

For an **undirected** graph, in-degree and out-degree have no meaning; the **degree** of \(v\) is simply the number of edge-ends that touch \(v\) (in particular, a self-loop contributes two to the degree).

We write \(deg(v)\) to refer to the degree of \(v\).

**Claim:** In a graph \(G = (V,E)\), \[2|E| = \sum_{v \in V} deg(v)\]

**Proof:** Every edge has two ends; each end contributes one to the degree of some vertex.

Note: we could have been more careful and proved this inductively (I would probably use induction on the number of edges), but doing so would obscure, rather than elucidate. This proof is simple and elegant.

**Claim (Handshaking theorem):** Let's call a person "odd" if they shake hands with an odd number of people, and "normal" otherwise. Then at any party, there are an even number of odd people.

**Proof:** We represent people as vertices and handshakes as edges. We have

\[2|E| = \sum_v deg(v) = \sum_{\text{odd }v} deg(v) + \sum_{\text{normal }v} deg(v)\]

Since we are interested in evenness, we reduce mod 2; \(a\) is even if \([a]_2 = [0]\) and odd if \([a]_2 = [1]\). Note that by definition, \([deg(v)]_2 = [1]\) if and only if \(v\) is "odd", and \([0]\) if \(v\) is normal. We have

\[ \begin{aligned} [0] &= [0][|E|] = [2|E|] && \text{since $[2] = [0]$} \\ &= \left[\sum_{\text{odd v}} deg(v) + \sum_{\text{normal v}} deg(v)\right] && \text{by above} \\ &= \sum_{\text{odd v}} [deg(v)] + \sum_{\text{normal v}} [deg(v)] && \text{definition of +} \\ &= \sum_{\text{odd v}} [1] + [0] && \text{by definition of "even" and "normal"} \\ &= \left[\sum_{\text{odd v}} 1\right] = \left[\text{the number of odd $v$}\right] \end{aligned} \]

Therefore the number of odd people is 0 mod 2, or in other words, even.