Improved graph theory handout

This commit is contained in:
2023-06-29 14:51:58 -07:00
parent 864e34436a
commit 6e2766ec02
7 changed files with 412 additions and 689 deletions

View File

@ -0,0 +1,127 @@
\section{Graphs}
\definition{}
A \textit{set} is an unordered collection of objects. \par
This means that the sets $\{1, 2, 3\}$ and $\{3, 2, 1\}$ are identical.
\definition{}
A \textit{graph} $G = (N, E)$ consists of two sets: a set of \textit{vertices} $V$, and a set of \textit{edges} $E$. \par
Verticies are simply named \say{points,} and edges are connections between pairs of vertices. \par
In the graph below, $V = \{a, b, c, d\}$ and $E = \{~ (a,b),~ (a,c),~ (a,d),~ (c,d) ~\}$.
\begin{center}
\begin{tikzpicture}
\begin{scope}[layer = nodes]
\node[main] (a) at (0, 0) {$a$};
\node[main] (b) at (0, -1) {$b$};
\node[main] (c) at (2, -1) {$c$};
\node[main] (d) at (4, 0) {$d$};
\end{scope}
\draw[-]
(a) edge (b)
(a) edge (c)
(a) edge (d)
(c) edge (d)
;
\end{tikzpicture}
\end{center}
Vertices are also sometimes called \textit{nodes}. You'll see both terms in this handout. \par
\problem{}
Draw the graph defined by the following vertex and edge sets: \par
$V = \{A,B,C,D,E\}$ \par
$E = \{~ (A,B),~ (A,C),~ (A,D),~ (A,E),~ (B,C),~ (C,D),~ (D,E) ~\}$\par
\vfill
We can use graphs to solve many different kinds of problems. \par
Most situations that involve some kind of \say{relation} between elements can be represented by a graph.
\pagebreak
Graphs are fully defined by their vertices and edges. The exact position of each vertex and edge doesn't matter---only which nodes are connected to each other. The same graph can be drawn in many different ways.
\problem{}
Show that the graphs below are equivalent by comparing the sets of their vertices and edges.
\begin{center}
\adjustbox{valign=c}{
\begin{tikzpicture}
\begin{scope}[layer = nodes]
\node[main] (a) at (0, 0) {$a$};
\node[main] (b) at (2, 0) {$b$};
\node[main] (c) at (2, -2) {$c$};
\node[main] (d) at (0, -2) {$d$};
\end{scope}
\draw[-]
(a) edge (b)
(b) edge (c)
(c) edge (d)
(d) edge (a)
(a) edge (c)
(b) edge (d)
;
\end{tikzpicture}
}
\hspace{20mm}
\adjustbox{valign=c}{
\begin{tikzpicture}
\begin{scope}[layer = nodes]
\node[main] (a) at (0, 0) {$a$};
\node[main] (b) at (-2, -2) {$b$};
\node[main] (c) at (0, -2) {$c$};
\node[main] (d) at (2, -2) {$d$};
\end{scope}
\draw[-]
(a) edge (b)
(b) edge (c)
(c) edge (d)
(d) edge (a)
(a) edge (c)
(b) edge[out=270, in=270, looseness=1] (d)
;
\end{tikzpicture}
}
\end{center}
\vfill
\pagebreak
\definition{}
The degree $D(v)$ of a vertex $v$ of a graph
is the number of the edges of the graph
connected to that vertex.
\theorem{Handshake Lemma}<handshake>
In any graph, the sum of the degrees of its vertices equals twice the number of the edges.
\problem{}
Prove \ref{handshake}.
\vfill
\problem{}
Show that all graphs have an even number number of vertices with odd degree.
\vfill
\problem{}
One girl tells another, \say{There are 25 kids
in my class. Isn't it funny that each of them
has 5 friends in the class?} \say{This cannot be true,} immediately replies the other girl.
How did she know?
\vfill
\pagebreak

View File

@ -0,0 +1,237 @@
\section{Paths and cycles}
A \textit{path} in a graph is, intuitively, a sequence of edges: $(x_1, x_2, x_4, ... )$. \par
I've highlighted one possible path in the graph below.
\begin{center}
\begin{tikzpicture}[
node distance={15mm},
thick,
main/.style = {draw, circle}
]
\node[main] (1) {$x_1$};
\node[main] (2) [above right of=1] {$x_2$};
\node[main] (3) [below right of=1] {$x_3$};
\node[main] (4) [above right of=3] {$x_4$};
\node[main] (5) [above right of=4] {$x_5$};
\node[main] (6) [below right of=4] {$x_6$};
\node[main] (7) [below right of=5] {$x_7$};
\draw[-] (1) -- (2);
\draw[-] (1) -- (3);
\draw[-] (2) -- (5);
\draw[-] (2) -- (4);
\draw[-] (3) -- (6);
\draw[-] (3) -- (4);
\draw[-] (4) -- (5);
\draw[-] (5) -- (7);
\draw[-] (6) -- (7);
\draw [
line width=2mm,
draw=black,
opacity=0.4
] (1) -- (2) -- (4) -- (3) -- (6);
\end{tikzpicture}
\end{center}
A \textit{cycle} is a path that starts and ends on the same vertex:
\begin{center}
\begin{tikzpicture}[
node distance={15mm},
thick,
main/.style = {draw, circle}
]
\node[main] (1) {$x_1$};
\node[main] (2) [above right of=1] {$x_2$};
\node[main] (3) [below right of=1] {$x_3$};
\node[main] (4) [above right of=3] {$x_4$};
\node[main] (5) [above right of=4] {$x_5$};
\node[main] (6) [below right of=4] {$x_6$};
\node[main] (7) [below right of=5] {$x_7$};
\draw[-] (1) -- (2);
\draw[-] (1) -- (3);
\draw[-] (2) -- (5);
\draw[-] (2) -- (4);
\draw[-] (3) -- (6);
\draw[-] (3) -- (4);
\draw[-] (4) -- (5);
\draw[-] (5) -- (7);
\draw[-] (6) -- (7);
\draw[
line width=2mm,
draw=black,
opacity=0.4
] (2) -- (4) -- (3) -- (6) -- (7) -- (5) -- (2);
\end{tikzpicture}
\end{center}
A \textit{Eulerian\footnotemark} path is a path that traverses each edge exactly once. \par
A Eulerian cycle is a cycle that does the same.
\footnotetext{Pronounced ``oiler-ian''. These terms are named after a Swiss mathematician, Leonhard Euler (1707-1783), who is usually considered the founder of graph theory.}
\vspace{2mm}
Similarly, a {\it Hamiltonian} path is a path in a graph that visits each vertex exactly once, \par
and a Hamiltonian cycle is a closed Hamiltonian path.
\medskip
An example of a Hamiltonian path is below.
\begin{center}
\begin{tikzpicture}[
node distance={15mm},
thick,
main/.style = {draw, circle}
]
\node[main] (1) {$x_1$};
\node[main] (2) [above right of=1] {$x_2$};
\node[main] (3) [below right of=1] {$x_3$};
\node[main] (4) [above right of=3] {$x_4$};
\node[main] (5) [above right of=4] {$x_5$};
\node[main] (6) [below right of=4] {$x_6$};
\node[main] (7) [below right of=5] {$x_7$};
\draw[-] (1) -- (2);
\draw[-] (1) -- (3);
\draw[-] (2) -- (5);
\draw[-] (2) -- (4);
\draw[-] (3) -- (6);
\draw[-] (3) -- (4);
\draw[-] (4) -- (5);
\draw[-] (5) -- (7);
\draw[-] (6) -- (7);
\draw [
line width=2mm,
draw=black,
opacity=0.4
] (1) -- (2) -- (4) -- (3) -- (6) -- (7) -- (5);
\end{tikzpicture}
\end{center}
\vfill
\pagebreak
\definition{}
We say a graph is \textit{connected} if there is a path between every pair of vertices. A graph is called \textit{disconnected} otherwise.
\problem{}
Draw a disconnected graph with four vertices. \par
Then, draw a graph with four vertices, all of degree one.
\vfill
\problem{}
Find a Hamiltonian cycle in the following graph.
\begin{center}
\begin{tikzpicture}[
node distance={20mm},
thick,
main/.style = {draw, circle}
]
\node[main] (1) {$x_1$};
\node[main] (2) [above right of=1] {$x_2$};
\node[main] (3) [below right of=1] {$x_3$};
\node[main] (4) [above right of=3] {$x_4$};
\node[main] (5) [above right of=4] {$x_5$};
\node[main] (6) [below right of=4] {$x_6$};
\node[main] (7) [below right of=5] {$x_7$};
\draw[-] (1) -- (2);
\draw[-] (1) -- (3);
\draw[-] (2) -- (5);
\draw[-] (2) -- (4);
\draw[-] (3) -- (6);
\draw[-] (3) -- (4);
\draw[-] (4) -- (5);
\draw[-] (5) -- (7);
\draw[-] (6) -- (7);
\end{tikzpicture}
\end{center}
\vfill
\pagebreak
\problem{}
Is there an Eulerian path in the following graph? \par
\begin{center}
\begin{tikzpicture}[
node distance={20mm},
thick,
main/.style = {draw, circle}
]
\node[main] (1) {$x_1$};
\node[main] (2) [above right of=1] {$x_2$};
\node[main] (3) [below right of=1] {$x_3$};
\node[main] (4) [above right of=3] {$x_4$};
\node[main] (5) [above right of=4] {$x_5$};
\node[main] (6) [below right of=4] {$x_6$};
\node[main] (7) [below right of=5] {$x_7$};
\draw[-] (1) -- (2);
\draw[-] (1) -- (3);
\draw[-] (2) -- (5);
\draw[-] (2) -- (4);
\draw[-] (3) -- (6);
\draw[-] (3) -- (4);
\draw[-] (4) -- (5);
\draw[-] (5) -- (7);
\draw[-] (6) -- (7);
\end{tikzpicture}
\end{center}
\vfill
\problem{}
Is there an Eulerian path in the following graph? \par
\begin{center}
\begin{tikzpicture}[
node distance={20mm},
thick,
main/.style = {draw, circle}
]
\node[main] (1) {$x_1$};
\node[main] (2) [above right of=1] {$x_2$};
\node[main] (3) [below right of=1] {$x_3$};
\node[main] (4) [above right of=3] {$x_4$};
\node[main] (5) [above right of=4] {$x_5$};
\node[main] (6) [below right of=4] {$x_6$};
\node[main] (7) [below right of=5] {$x_7$};
\draw[-] (1) -- (2);
\draw[-] (1) -- (3);
\draw[-] (2) -- (4);
\draw[-] (3) -- (6);
\draw[-] (3) -- (4);
\draw[-] (4) -- (5);
\draw[-] (5) -- (7);
\draw[-] (6) -- (7);
\end{tikzpicture}
\end{center}
\vfill
\problem{}
When does an Eulerian path exist? \par
\hint{Look at the degree of each node.}
\vfill
\pagebreak