% use [nosolutions] flag to hide solutions.
% use [solutions] flag to show solutions.
\documentclass[
	solutions
]{../../resources/ormc_handout}


\usepackage{tkz-graph}


\begin{document}

	\maketitle
		<Intermediate 2>
		<ORMC Summer Sessions>
		{Graph Theory and Instant Insanity}
		{
			Prepared by Mark on \today \\
			Based on a handout by Oleg Gleizer
		}


		\section{Instant Insanity}

		The puzzle you have in front of you is called {\it Instant Insanity}.

		It consists of four cubes, with faces colored with four colors:
		red, blue, green, and white. The objective is to put the cubes in a row
		so that each side, front, back, upper, and lower,
		of the row shows each of the four colors. \\

	\begin{center}
	\includegraphics[width=2.2in]
	{II.jpg}
	\end{center}

	There are 41,472 different arrangements
	of the cubes. Only one is a solution.
	Finding it by trial and error is quite difficult,
	but we have witnessed a few students
	do just that.

	However, that rarely happens.
	We'd like to solve this puzzle today, and
	to do that, we'll need a few tools.

	\section{Cubic Nets}

	A {\it cubic net} is a 2D picture
	simultaneously showing all the six sides
	(a.k.a.~faces) of a 3D cube,
	please take a look at the examples below. \\

	\begin{center}
	\begin{tikzpicture} [scale = .3]
	\draw [line width = 1.5pt] (0,0) -- (12,0) --
	(12,3) -- (0,3) -- (0,0);
	\draw [line width = 1.5pt] (6,-3) --
	(9,-3) -- (9,6) -- (6,6) -- (6,-3);
	\draw [line width = 1.5pt] (3,0) -- (3,3);

	\draw [line width = 1.5pt] (21,0) -- (33,0) --
	(33,3) -- (21,3) -- (21,0);
	\draw [line width = 1.5pt] (24,0) --
	(24,6) -- (27,6) -- (27,0);
	\draw [line width = 1.5pt] (27,0) --
	(27,-3) -- (30,-3) -- (30,3);
	\end{tikzpicture}
	\end{center}

	\problem{}
	Draw a cubic net different from the two above.

	\vfill
	\pagebreak


	\problem{}
	An ant wants to crawl from point $A$ of a cubic room
	to the opposite point $B$, as in the picture below.

	\begin{center} \begin{small}
	\begin{tikzpicture}
	\draw (1,1) -- (4,1) -- (4,4) -- (1,4) -- (1,1);
	\draw (0,0) -- (3,0) -- (3,3) -- (0,3) -- (0,0);
	\draw (0,0) -- (1,1);
	\draw (3,0) -- (4,1);
	\draw (0,3) -- (1,4);
	\draw (3,3) -- (4,4);
	\filldraw (0,0) circle (3pt);
	\filldraw (4,4) circle (3pt);
	\coordinate [label=below left:{A}] (a) at (0,0);
	\coordinate [label=above right:{B}] (b) at (4,4);
	\end{tikzpicture}
	\end{small} \end{center}

	The insect can crawl on any surface,
	a floor, ceiling, or wall, but cannot fly through the air.
	Find at least two different shortest paths for the ant
	(there is more than one).

	Let's look at the nets of the puzzle's cubes. \\

	\begin{center} \begin{small}
	\begin{tikzpicture} [scale = .3] \label{pic:ii_cubes}
		\filldraw [red] (0,0) -- (9,0) -- (9,3) -- (0,3) -- (0,0);
		\filldraw [blue] (9,0) -- (12,0) -- (12,3) -- (9,3) -- (9,0);
		\filldraw [green] (6,3) -- (9,3) -- (9,6) -- (6,6) -- (6,3);
		\draw [line width = 1.5pt] (0,0) -- (12,0) --
		(12,3) -- (0,3) -- (0,0);
		\draw [line width = 1.5pt] (6,-3) --
		(9,-3) -- (9,6) -- (6,6) -- (6,-3);
		\draw [line width = 1.5pt] (3,0) -- (3,3);
		\coordinate [label=below:{Cube 1}] (c1) at (7.6,-3.5);

		\node[text = white] at (0 + 1.5,  0 + 1.5) {\textbf{Red}};
		\node[text = white] at (0 + 4.5,  0 + 1.5) {\textbf{Red}};
		\node[text = white] at (0 + 7.5,  0 + 1.5) {\textbf{Red}};
		\node[text = white] at (0 + 10.5, 0 + 1.5) {\textbf{Blue}};
		\node[text = black] at (0 + 7.5,  0 + 4.5) {\textbf{Grn}};
		\node[text = black] at (0 + 7.5,  0 - 1.5) {\textbf{Wht}};

		\filldraw [red] (21,0) -- (27,0) -- (27,3) --
		(21,3) -- (21,0);
		\filldraw [green] (27,3) -- (27,0) -- (30,0) --
		(30,3) -- (27,3);
		\filldraw [blue] (27,0) -- (27,-3) -- (30,-3) --
		(30,0) -- (27,0);
		\draw [line width = 1.5pt] (21,0) -- (33,0) --
		(33,3) -- (21,3) -- (21,0);
		\draw [line width = 1.5pt] (27,-3) --
		(30,-3) -- (30,6) -- (27,6) -- (27,-3);
		\draw [line width = 1.5pt] (24,0) -- (24,3);
		\coordinate [label=below:{Cube 2}] (c2) at (28.6,-3.5);

		\node[text = white] at (21 + 1.5,  0 + 1.5) {\textbf{Red}};
		\node[text = white] at (21 + 4.5,  0 + 1.5) {\textbf{Red}};
		\node[text = black] at (21 + 7.5,  0 + 1.5) {\textbf{Grn}};
		\node[text = black] at (21 + 10.5, 0 + 1.5) {\textbf{Wht}};
		\node[text = black] at (21 + 7.5,  0 + 4.5) {\textbf{Wht}};
		\node[text = white] at (21 + 7.5,  0 - 1.5) {\textbf{Blue}};

		\filldraw [red] (0,-15) -- (3,-15) -- (3,-12)
		-- (0,-12) -- (0,-15);
		\filldraw [green] (3,-15) -- (6,-15) -- (6,-12)
		-- (3,-12) -- (3,-15);
		\filldraw [blue] (6,-18) -- (9,-18) -- (9,-12)
		-- (6,-12) -- (6,-15);
		\draw [line width = 1.5pt] (0,-15) -- (12,-15) --
		(12,-12) -- (0,-12) -- (0,-15);
		\draw [line width = 1.5pt] (6,-18) --
		(9,-18) -- (9,-9) -- (6,-9) -- (6,-18);
		\draw [line width = 1.5pt] (3,-15) -- (3,-12);
		\coordinate [label=below:{Cube 3}] (c3) at (7.6,-18.5);

		\node[text = white] at (0 + 1.5,  -15 + 1.5) {\textbf{Red}};
		\node[text = black] at (0 + 4.5,  -15 + 1.5) {\textbf{Grn}};
		\node[text = white] at (0 + 7.5,  -15 + 1.5) {\textbf{Blue}};
		\node[text = black] at (0 + 10.5, -15 + 1.5) {\textbf{Wht}};
		\node[text = black] at (0 + 7.5,  -15 + 4.5) {\textbf{Wht}};
		\node[text = white] at (0 + 7.5,  -15 - 1.5) {\textbf{Blue}};

		\filldraw [red] (21,-15) -- (24,-15) --
		(24,-12) -- (21,-12) -- (21,-15);
		\filldraw [blue] (24,-15) -- (27,-15) --
		(27,-12) -- (24,-12) -- (24,-15);
		\filldraw [green] (27,-18) -- (30,-18) --
		(30,-12) -- (27,-12) -- (27,-18);
		\filldraw [blue] (30,-15) -- (33,-15) --
		(33,-12) -- (30,-12) -- (30,-15);
		\draw [line width = 1.5pt] (21,-15) -- (33,-15) --
		(33,-12) -- (21,-12) -- (21,-15);
		\draw [line width = 1.5pt] (27,-18) --
		(30,-18) -- (30,-9) -- (27,-9) -- (27,-18);
		\draw [line width = 1.5pt] (24,-15) -- (24,-12);
		\coordinate [label=below:{Cube 4}] (c4) at (28.6,-18.5);

		\node[text = white] at (21 + 1.5,  -15 + 1.5) {\textbf{Red}};
		\node[text = white] at (21 + 4.5,  -15 + 1.5) {\textbf{Blue}};
		\node[text = black] at (21 + 7.5,  -15 + 1.5) {\textbf{Grn}};
		\node[text = white] at (21 + 10.5, -15 + 1.5) {\textbf{Blue}};
		\node[text = black] at (21 + 7.5,  -15 + 4.5) {\textbf{Wht}};
		\node[text = black] at (21 + 7.5,  -15 - 1.5) {\textbf{Grn}};

	\end{tikzpicture}
	\end{small} \end{center}
	\medskip

	Note that each cube is different.

	\vfill
	\pagebreak

	\section{Graphs}

	\begin{tcolorbox}[
		colback=white,
		colframe=gray!75!black,
		title={Last week's lesson}
	]
		A \textit{graph} is a collection of nodes (vertices) and connections between them (edges). If an edge $e$ connects the vertices $v_i$ and $v_j$, then we write $e = {v_i, v_j}$. An example is below.

		\begin{center}
		\begin{tikzpicture} [scale = .6] \label{pic:1}
			\SetGraphUnit{5}
			\Vertex{B}
			\WE(B){A}
			\EA(B){C}
			\Edge(B)(A)
			\Edge(C)(B)
			\tikzset{EdgeStyle/.append style = {bend left = 50}}
			\Edge(A)(C)
			\Edge(C)(A)
			\coordinate [label=above:{$e_1$}] (e1) at (-2.1,.0);
			\coordinate [label=above:{$e_2$}] (e2) at (0,2.45);
			\coordinate [label=below:{$e_3$}] (e3) at (0,-2.5);
			\coordinate [label=above:{$e_4$}] (e4) at (2.1,.0);
		\end{tikzpicture}
		\end{center}

		More formally, a graph is defined by a set of vertices $\{v_1, v_2, ...\}$, and a set of edges $\{\ \{v_1, v_2\}, \{v_1, v_3\}, ...\ \}$.

		\medskip

		If the order of the vertices in an edge does not matter,
		a graph is called {\it undirected}. A graph is called
		a {\it directed graph} if the order of the vertices does matter.
		For example, the (undirected) graph above
		has three vertices, $A$, $B$, and $C$, and four edges,
		$e_1 =\{A,B\}$, $e_2 = \{A,C\}$, $e_3 = \{A,C\}$,
		and $e_4 = \{B,C\}$.

	\end{tcolorbox}


	Let's represent Cube 1 by a graph. \\
	The vertices will be the face colors: Blue, Green, Red, and White, so $V = \{B,G,R,W\}$. \\
	Two vertices are be connected by an edge if and only if the corresponding faces are opposing each other on the cube. \\
	Cube 1 has the following edges: $e_1 = \{B,R\}$, $e_2 = \{G,W\}$, and the loop $e_3 = \{R,R\}$. To emphasize that all the three edges represent the first cube, let us mark them with the number $1$. \\

	\begin{center} \begin{small}
	\begin{tikzpicture}
	  \filldraw [blue] (0,5) -- (1,5) -- (1,6) --
		(0,6) -- (0,5);
	  \draw [line width = 1.5pt] (0,5) --
		(1,5) -- (1,6) -- (0,6) -- (0,5);
	  \filldraw [green] (5,5) -- (6,5) -- (6,6) --
		(5,6) -- (5,5);
	  \draw [line width = 1.5pt] (5,5) --
		(6,5) -- (6,6) -- (5,6) -- (5,5);
	  \filldraw [red] (0,0) -- (1,0) -- (1,1) --
		(0,1) -- (0,0);
	  \draw [line width = 1.5pt] (0,0) --
		(1,0) -- (1,1) -- (0,1) -- (0,0);
	  \draw [line width = 1.5pt] (5,0) --
		(6,0) -- (6,1) -- (5,1) -- (5,0);
	  \draw (-.5,-.5) circle (.3) node {1};
	  \draw [line width = 1.5pt] (0,.5) ..
		controls (-	.9,.4)  and (-.65,-.2) .. (-.7,-.3);
	  \draw [line width = 1.5pt] (.5,0) ..
		controls (.4,-.9)  and (-.2,-.65) .. (-.3,-.7);
	  \draw (.5,2) circle (.3) node {1};
	  \draw [line width = 1.5pt] (.5,1) -- (.5,1.7);
	  \draw [line width = 1.5pt] (.5,2.3) -- (.5,5);
	  \draw (5.5,4) circle (.3) node {1};
	  \draw [line width = 1.5pt] (5.5,5) -- (5.5,4.3);
	  \draw [line width = 1.5pt] (5.5,3.7) -- (5.5,1);

	  \node[text = white] at (0.5, 5.5) {\textbf{Blue}};
	  \node[text = white] at (0.5, 0.5) {\textbf{Red}};
	  \node[text = black] at (5.5, 0.5) {\textbf{Wht}};
	  \node[text = black] at (5.5, 5.5) {\textbf{Grn}};

	\end{tikzpicture}
	\end{small} \end{center}
	\bigskip

		Cube 2 has the following pairs
	of opposing faces, $\{B,W\}$, $\{G,R\}$,
	and $\{R,W\}$. Let us add them to the graph
	as the edges $e_4$, $e_5$, and $e_6$. \\

	\begin{center} \begin{small}
	\begin{tikzpicture}
		\filldraw [blue] (0,5) -- (1,5) -- (1,6) --
		(0,6) -- (0,5);
		\draw [line width = 1.5pt] (0,5) --
		(1,5) -- (1,6) -- (0,6) -- (0,5);
		\filldraw [green] (5,5) -- (6,5) -- (6,6) --
		(5,6) -- (5,5);
		\draw [line width = 1.5pt] (5,5) --
		(6,5) -- (6,6) -- (5,6) -- (5,5);
		\filldraw [red] (0,0) -- (1,0) -- (1,1) --
		(0,1) -- (0,0);
		\draw [line width = 1.5pt] (0,0) --
		(1,0) -- (1,1) -- (0,1) -- (0,0);
		\draw [line width = 1.5pt] (5,0) --
		(6,0) -- (6,1) -- (5,1) -- (5,0);
		\draw (-.5,-.5) circle (.3) node {1};
		\draw [line width = 1.5pt] (0,.5) ..
		controls (-.9,.4)  and (-.65,-.2) .. (-.7,-.3);
		\draw [line width = 1.5pt] (.5,0) ..
		controls (.4,-.9)  and (-.2,-.65) .. (-.3,-.7);
		\draw (.5,2) circle (.3) node {1};
		\draw [line width = 1.5pt] (.5,1) -- (.5,1.7);
		\draw [line width = 1.5pt] (.5,2.3) -- (.5,5);
		\draw (5.5,4) circle (.3) node {1};
		\draw [line width = 1.5pt] (5.5,5) -- (5.5,4.3);
		\draw [line width = 1.5pt] (5.5,3.7) -- (5.5,1);
		\draw (2,4) circle (.3) node {2};
		\draw [line width = 1.5pt] (1,5) -- (1.8,4.2);
		\draw [line width = 1.5pt] (5,1) -- (2.2,3.8);
		\draw (4,4) circle (.3) node {2};
		\draw [line width = 1.5pt] (5,5) -- (4.2,4.2);
		\draw [line width = 1.5pt] (1,1) -- (3.8,3.8);
		\draw (4,.5) circle (.3) node {2};
		\draw [line width = 1.5pt] (1,.5) -- (3.7,.5);
		\draw [line width = 1.5pt] (5,.5) -- (4.3,.5);

		\node[text = white] at (0.5, 5.5) {\textbf{Blue}};
		\node[text = white] at (0.5, 0.5) {\textbf{Red}};
		\node[text = black] at (5.5, 0.5) {\textbf{Wht}};
		\node[text = black] at (5.5, 5.5) {\textbf{Grn}};
	\end{tikzpicture}
	\end{small} \end{center}
	\bigskip

		Let us now make the graph
	representing all four cubes. \\

	\begin{center} \begin{small}
	\begin{tikzpicture} \label{pic:II_comfiguration}
		\filldraw [blue] (0,5) -- (1,5) -- (1,6) --
		(0,6) -- (0,5);
		\draw [line width = 1.5pt] (0,5) --
		(1,5) -- (1,6) -- (0,6) -- (0,5);
		\filldraw [green] (5,5) -- (6,5) -- (6,6) --
		(5,6) -- (5,5);
		\draw [line width = 1.5pt] (5,5) --
		(6,5) -- (6,6) -- (5,6) -- (5,5);
		\filldraw [red] (0,0) -- (1,0) -- (1,1) --
		(0,1) -- (0,0);
		\draw [line width = 1.5pt] (0,0) --
		(1,0) -- (1,1) -- (0,1) -- (0,0);
		\draw [line width = 1.5pt] (5,0) --
		(6,0) -- (6,1) -- (5,1) -- (5,0);
		\draw (-.5,-.5) circle (.3) node {1};
		\draw [line width = 1.5pt] (0,.5) ..
		controls (-.9,.4)  and (-.65,-.2) .. (-.7,-.3);
		\draw [line width = 1.5pt] (.5,0) ..
		controls (.4,-.9)  and (-.2,-.65) .. (-.3,-.7);
		\draw (.5,2) circle (.3) node {1};
		\draw [line width = 1.5pt] (.5,1) -- (.5,1.7);
		\draw [line width = 1.5pt] (.5,2.3) -- (.5,5);
		\draw (5.5,4) circle (.3) node {1};
		\draw [line width = 1.5pt] (5.5,5) -- (5.5,4.3);
		\draw [line width = 1.5pt] (5.5,3.7) -- (5.5,1);
		\draw (1.5,3.5) circle (.3) node {2};
		\draw [line width = 1.5pt] (.8,5) ..
		controls (.8,4.6) and (1,4.2) .. (1.3,3.7);
		\draw [line width = 1.5pt] (5,.8) ..
		controls (2.5,1.5) and (2.1,2.5) .. (1.6,3.22);
		\draw (4,4) circle (.3) node {2};
		\draw [line width = 1.5pt] (5,5) -- (4.2,4.2);
		\draw [line width = 1.5pt] (1,1) -- (3.8,3.8);
		\draw (4,.5) circle (.3) node {2};
		\draw [line width = 1.5pt] (1,.5) -- (3.7,.5);
		\draw [line width = 1.5pt] (5,.5) -- (4.3,.5);
		\draw (-1,3) circle (.3) node {3};
		\draw [line width = 1.5pt] (0,5) ..
		controls (-.7,4.3) and (-.9,3.6) .. (-1,3.3);
		\draw [line width = 1.5pt] (0,1) ..
		controls (-.7,1.7) and (-.9,2.3) .. (-1,2.7);
		\draw (2.5,4) circle (.3) node {3};
		\draw [line width = 1.5pt] (1,5.2) ..
		controls (1.4,5.2) and (2,4.5) .. (2.3,4.2);
		\draw [line width = 1.5pt] (5.2,1) ..
		controls (4.7,1.8) and (3.5,3) .. (2.7,3.8);
		\draw (7,3) circle (.3) node {3};
		\draw [line width = 1.5pt] (6,5) ..
		controls (6.7,4.3) and (6.9,3.6) .. (7,3.3);
		\draw [line width = 1.5pt] (6,1) ..
		controls (6.7,1.7) and (6.9,2.3) .. (7,2.7);
		\draw (-.5,6.5) circle (.3) node {4};
		\draw [line width = 1.5pt] (0,5.5) ..
		controls (-.9,5.4)  and (-.65,6.2) .. (-.7,6.26);
		\draw [line width = 1.5pt] (-.24,6.65) ..
		controls (.1,6.7)  and (.45,6.7) .. (.5,6);
		\draw (8.5,3) circle (.3) node {4};
		\draw [line width = 1.5pt] (6,5.5) ..
		controls (7.3,5) and (8.2,4) .. (8.5,3.3);
		\draw [line width = 1.5pt] (6,.8) ..
		controls (7.3,1) and (8.2,2) .. (8.5,2.7);
		\draw (2.3,1.2) circle (.3) node {4};
		\draw [line width = 1.5pt] (1,.8) -- (2.04,1.1);
		\draw [line width = 1.5pt] (2.6,1.3) ..
		controls (4,2) and (5,4) .. (5.2,5);

		\node[text = white] at (0.5, 5.5) {\textbf{Blue}};
		\node[text = white] at (0.5, 0.5) {\textbf{Red}};
		\node[text = black] at (5.5, 0.5) {\textbf{Wht}};
		\node[text = black] at (5.5, 5.5) {\textbf{Grn}};
	\end{tikzpicture}
	\end{small} \end{center}

	\problem{}
	Check if the above representation
	is correct for Cubes 3 and 4.
	\vfill
	\pagebreak

	With the help of the above graph,
	solving the puzzle becomes as easy
	as a walk in the park, literally.
	Imagine that the vertices of the above graph
	are the clearings and the edges are the paths.
	An edge marked by the number $i$ represents
	two opposing faces of the $i$-th cube.
	Let us try to find a closed walk, a.k.a.~a cycle,
	in the graph that visits each clearing once
	and uses the paths marked by the different numbers,
	$i=1,2,3,4$. If we order the front and rear sides
	of the cubes accordingly,
	then the front and rear of the stack
	will show all the four different colors
	in the order prescribed by our walk. \\

		For example, here is such an (oriented) cycle,
	represented by the magenta arrows
	on the picture below. \\

	\begin{center} \begin{small}
	\begin{tikzpicture}
	  \draw [line width = 3pt, color = magenta, <-]
		(.5,1) -- (.5,1.7);
	  \draw [line width = 3pt, color = magenta, <-]
		(.5,2.3) -- (.5,5);
	  \draw [line width = 3pt, color = magenta, <-]
		(5,5) -- (4.2,4.2);
	  \draw [line width = 3pt, color = magenta, ->]
		(1,1) -- (3.8,3.8);
	  \draw [line width = 3pt, color = magenta, ->]
		(6,5.5) .. controls (7.3,5) and (8.2,4) .. (8.5,3.3);
	  \draw [line width = 3pt, color = magenta, <-]
		(6,.8) .. controls (7.3,1) and (8.2,2) .. (8.5,2.7);
	  \draw [line width = 3pt, color = magenta, <-]
		(1,5.2) .. controls (1.4,5.2) and (2,4.5) .. (2.3,4.2);
	  \draw [line width = 3pt, color = magenta, ->]
		(5.2,1) .. controls (4.7,1.8) and (3.5,3) .. (2.7,3.8);


	  \filldraw [blue] (0,5) -- (1,5) -- (1,6) --
		(0,6) -- (0,5);
	  \draw [line width = 1.5pt] (0,5) --
		(1,5) -- (1,6) -- (0,6) -- (0,5);
	  \filldraw [green] (5,5) -- (6,5) -- (6,6) --
		(5,6) -- (5,5);
	  \draw [line width = 1.5pt] (5,5) --
		(6,5) -- (6,6) -- (5,6) -- (5,5);
	  \filldraw [red] (0,0) -- (1,0) -- (1,1) --
		(0,1) -- (0,0);
	  \draw [line width = 1.5pt] (0,0) --
		(1,0) -- (1,1) -- (0,1) -- (0,0);
	  \draw [line width = 1.5pt] (5,0) --
		(6,0) -- (6,1) -- (5,1) -- (5,0);
	  \draw (-.5,-.5) circle (.3) node {1};
	  \draw [line width = 1.5pt] (0,.5) ..
		controls (-.9,.4)  and (-.65,-.2) .. (-.7,-.3);
	  \draw [line width = 1.5pt] (.5,0) ..
		controls (.4,-.9)  and (-.2,-.65) .. (-.3,-.7);
	  \draw (.5,2) circle (.3) node {1};
	  \draw (5.5,4) circle (.3) node {1};
	  \draw [line width = 1.5pt] (5.5,5) -- (5.5,4.3);
	  \draw [line width = 1.5pt] (5.5,3.7) -- (5.5,1);
	  \draw (1.5,3.5) circle (.3) node {2};
	  \draw [line width = 1.5pt] (.8,5) ..
		controls (.8,4.6) and (1,4.2) .. (1.3,3.7);
	  \draw [line width = 1.5pt] (5,.8) ..
		controls (2.5,1.5) and (2.1,2.5) .. (1.6,3.22);
	  \draw (4,4) circle (.3) node {2};
	  \draw (4,.5) circle (.3) node {2};
	  \draw [line width = 1.5pt] (1,.5) -- (3.7,.5);
	  \draw [line width = 1.5pt] (5,.5) -- (4.3,.5);
	  \draw (-1,3) circle (.3) node {3};
	  \draw [line width = 1.5pt] (0,5) ..
		controls (-.7,4.3) and (-.9,3.6) .. (-1,3.3);
	  \draw [line width = 1.5pt] (0,1) ..
		controls (-.7,1.7) and (-.9,2.3) .. (-1,2.7);
	  \draw (2.5,4) circle (.3) node {3};
	  \draw (7,3) circle (.3) node {3};
	  \draw [line width = 1.5pt] (6,5) ..
		controls (6.7,4.3) and (6.9,3.6) .. (7,3.3);
	  \draw [line width = 1.5pt] (6,1) ..
		controls (6.7,1.7) and (6.9,2.3) .. (7,2.7);
	  \draw (-.5,6.5) circle (.3) node {4};
	  \draw [line width = 1.5pt] (0,5.5) ..
		controls (-.9,5.4)  and (-.65,6.2) .. (-.7,6.26);
	  \draw [line width = 1.5pt] (-.24,6.65) ..
		controls (.1,6.7)  and (.45,6.7) .. (.5,6);
	  \draw (8.5,3) circle (.3) node {4};
	  \draw (2.3,1.2) circle (.3) node {4};
	  \draw [line width = 1.5pt] (1,.8) -- (2.04,1.1);
	  \draw [line width = 1.5pt] (2.6,1.3) ..
		controls (4,2) and (5,4) .. (5.2,5);


		\node[text = white] at (0.5, 5.5) {\textbf{Blue}};
		\node[text = white] at (0.5, 0.5) {\textbf{Red}};
		\node[text = black] at (5.5, 0.5) {\textbf{Wht}};
		\node[text = black] at (5.5, 5.5) {\textbf{Grn}};
	\end{tikzpicture}
	\end{small} \end{center}
	\bigskip

		The first leg of the walk tells us
	to take Cube 1 and to make sure
	that its blue side is facing forward.
	Then the red side, opposite to the blue one,
	will face the rear.

	\begin{center}
	\begin{tikzpicture}
	  \coordinate [label=center:{Front:}] (f) at (0,.5);
	  \filldraw [blue] (1,0) -- (2,0) -- (2,1) -- (1,1) -- (1,0);
	  \draw [line width = 1.5pt] (1,0) -- (2,0) --
		(2,1) -- (1,1) -- (1,0);

	  \coordinate [label=center:{Rear:}] (f) at (0,-1);
	  \filldraw [red] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);
	  \draw [line width = 1.5pt] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);

		\node[text = white] at (1.5, 0.5) {\textbf{Blue}};
		\node[text = white] at (1.5, -1) {\textbf{Red}};
	\end{tikzpicture}
	\end{center}
	\bigskip

		The next leg of the walk tells us
	to take Cube 2 and to place it in such a way
	that its red side faces
	us while the opposing green side faces the rear.
	Since we go in a cycle that visits all the colors
	one-by-one, neither color repeats the ones
	already used on their sides of the stack. \\

	\begin{center}
	\begin{tikzpicture}
	  \coordinate [label=center:{Front:}] (f) at (0,.5);
	  \filldraw [blue] (1,0) -- (2,0) -- (2,1) -- (1,1) -- (1,0);
	  \filldraw [red] (2,0) -- (3,0) -- (3,1) -- (2,1) -- (2,0);
	  \draw [line width = 1.5pt] (1,0) -- (2,0) --
		(2,1) -- (1,1) -- (1,0);
	  \draw [line width = 1.5pt] (2,0) -- (3,0) --
		(3,1) -- (2,1);

	  \coordinate [label=center:{Rear:}] (f) at (0,-1);
	  \filldraw [red] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);
	  \filldraw [green] (2,-1.5) -- (3,-1.5) -- (3,-.5) --
		(2,-.5) -- (2,-1.5);
	  \draw [line width = 1.5pt] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);
	  \draw [line width = 1.5pt] (2,-1.5) -- (3,-1.5) --
		(3,-.5) -- (2,-.5);

		\node[text = white] at (1.5, 0.5) {\textbf{Blue}};
		\node[text = black] at (2.5, 0.5) {\textbf{Red}};
		\node[text = white] at (1.5, -1) {\textbf{Red}};
		\node[text = black] at (2.5, -1) {\textbf{Grn}};

	\end{tikzpicture}
	\end{center}
	\bigskip

		The third leg of the walk tells us
	to take Cube 4, not Cube 3, and to place it
	green side forward, white side facing the rear. \\

	\begin{center}
	\begin{tikzpicture}
	  \coordinate [label=center:{Front:}] (f) at (0,.5);
	  \filldraw [blue] (1,0) -- (2,0) -- (2,1) -- (1,1) -- (1,0);
	  \filldraw [red] (2,0) -- (3,0) -- (3,1) -- (2,1) -- (2,0);
	  \filldraw [green] (4,0) -- (5,0) -- (5,1) -- (4,1) -- (4,0);
	  \draw [line width = 1.5pt] (1,0) -- (2,0) --
		(2,1) -- (1,1) -- (1,0);
	  \draw [line width = 1.5pt] (2,0) -- (3,0) --
		(3,1) -- (2,1);
	  \draw [line width = 1.5pt] (4,0) -- (5,0) --
		(5,1) -- (4,1) -- (4,0);

	  \coordinate [label=center:{Rear:}] (f) at (0,-1);
	  \filldraw [red] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);
	  \filldraw [green] (2,-1.5) -- (3,-1.5) -- (3,-.5) --
		(2,-.5) -- (2,-1.5);
	  \draw [line width = 1.5pt] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);
	  \draw [line width = 1.5pt] (2,-1.5) -- (3,-1.5) --
		(3,-.5) -- (2,-.5);
	  \draw [line width = 1.5pt] (4,-1.5) -- (5,-1.5) --
		(5,-.5) -- (4,-.5) -- (4,-1.5);

		\node[text = white] at (1.5, 0.5) {\textbf{Blue}};
		\node[text = black] at (2.5, 0.5) {\textbf{Red}};
		\node[text = white] at (1.5, -1) {\textbf{Red}};
		\node[text = black] at (2.5, -1) {\textbf{Grn}};

		\node[text = black] at (4.5, 0.5) {\textbf{Grn}};
		\node[text = black] at (4.5, -1) {\textbf{Wht}};

	\end{tikzpicture}
	\end{center}
	\bigskip

		Finally, the last leg of the walk
	tells us to take Cube 3 and to place it
	the white side facing forward,
	the opposite blue side facing the rear. \\

	\begin{center}
	\begin{tikzpicture}
	  \coordinate [label=center:{Front:}] (f) at (0,.5);
	  \filldraw [blue] (1,0) -- (2,0) -- (2,1) -- (1,1) -- (1,0);
	  \filldraw [red] (2,0) -- (3,0) -- (3,1) -- (2,1) -- (2,0);
	  \filldraw [green] (4,0) -- (5,0) -- (5,1) -- (4,1) -- (4,0);
	  \draw [line width = 1.5pt] (1,0) -- (2,0) --
		(2,1) -- (1,1) -- (1,0);
	  \draw [line width = 1.5pt] (2,0) -- (3,0) --
		(3,1) -- (2,1);
	  \draw [line width = 1.5pt] (4,0) -- (5,0) --
		(5,1) -- (4,1) -- (4,0);
	  \draw [line width = 1.5pt] (3,0) -- (4,0);
	  \draw [line width = 1.5pt] (3,1) -- (4,1);

	  \coordinate [label=center:{Rear:}] (f) at (0,-1);
	  \filldraw [red] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);
	  \filldraw [green] (2,-1.5) -- (3,-1.5) -- (3,-.5) --
		(2,-.5) -- (2,-1.5);
	  \filldraw [blue] (3,-1.5) -- (4,-1.5) -- (4,-.5) --
		(3,-.5) -- (3,-1.5);
	  \draw [line width = 1.5pt] (1,-1.5) -- (2,-1.5) -- (2,-.5) --
		(1,-.5) -- (1,-1.5);
	  \draw [line width = 1.5pt] (2,-1.5) -- (3,-1.5) --
		(3,-.5) -- (2,-.5);
	  \draw [line width = 1.5pt] (4,-1.5) -- (5,-1.5) --
		(5,-.5) -- (4,-.5) -- (4,-1.5);
	  \draw [line width = 1.5pt] (3,-1.5) -- (4,-1.5);
	  \draw [line width = 1.5pt] (3,-.5) -- (4,-.5);

	  \node[text = white] at (1.5, 0.5) {\textbf{Blue}};
	  \node[text = black] at (2.5, 0.5) {\textbf{Red}};
	  \node[text = white] at (1.5, -1) {\textbf{Red}};
	  \node[text = black] at (2.5, -1) {\textbf{Grn}};
	  \node[text = black] at (3.5, 0.5) {\textbf{Wht}};
	  \node[text = white] at (3.5, -1) {\textbf{Blue}};
	  \node[text = black] at (4.5, 0.5) {\textbf{Grn}};
	  \node[text = black] at (4.5, -1) {\textbf{Wht}};
	\end{tikzpicture}
	\end{center}
	\bigskip

		Now the front and rear of the stack are done.
	If we manage to find a second oriented cycle
	in the original graph that has all the properties
	of the first cycle, but uses none of its edges,
	we would be able to do the upper and lower sides
	of the stack and to complete the puzzle.
	Using the edges we have already traversed
	during our first walk will mess up
	the front-rear configuration, but there are still
	a plenty of the edges left!

	\problem{}
	Complete the puzzle.

	\vfill
	\pagebreak


	\section{Traveling salesman problem}

	\problem{} \label{pr:tsp}
	A salesman with the home office
	in Albuquerque has to fly to Boston,
	Chicago, and Denver, visiting each city once,
	and then to come back to the home office.
	The airfare prices, shown on the graph below,
	do not depend on the direction of the travel.
	Find the cheapest way. \\
	\note{This was on last week's handout, but not everyone had the chance to solve it.}

	\begin{center}
	\begin{normalsize}
	\begin{tikzpicture}
	\tikzset{EdgeStyle/.append style = {-}}
	\SetGraphUnit{3}
	\Vertex{A}
	\SOWE(A){B}
	\SOEA(A){C}
	\SO(A){D}
	\Edge(A)(B)
	\Edge(A)(C)
	\Edge(A)(D)
	\Edge(B)(D)
	\Edge(C)(D)
	\tikzset{EdgeStyle/.append style = {bend right = 70}}
	\Edge(B)(C)
	\coordinate [label=left:{\$1400}] (ab) at (-1.8,-1.75);
	\coordinate [label=right:{\$1000}] (ac) at (1.8,-1.75);
	\coordinate [label=right:{\$400}] (ad) at (-.1,-1.75);
	\coordinate [label=below:{\$800}] (bc) at (0,-4.8);
	\coordinate [label=below:{\$1200}] (bd) at (-1.5,-3);
	\coordinate [label=below:{\$900}] (cd) at (1.5,-3);
	\end{tikzpicture}
	\end{normalsize}
	\end{center}

	\vfill
	\pagebreak

	\section{Planar graphs}
	\label{sec:PG}

		A graph is called {\it planar},
	if it can be drawn in the plane in such a way
	that no edges cross one another.
	\problem{}
	Show that the following graph is planar.

	\begin{center}
	\tikzset{EdgeStyle/.append style = {-}}
	\begin{tikzpicture} [scale = .8]
	\SetGraphUnit{3.5}
	\draw [color = white] (0,0) -- (0,-5);
	\Vertex{A}
	\EA(A){B}
	\SO(B){C}
	\SO(A){D}
	\Edge(A)(B)
	\Edge(A)(C)
	\Edge(A)(D)
	\Edge(B)(C)
	\Edge(B)(D)
	\Edge(C)(D)
	\end{tikzpicture}
	\end{center}
	\vfill

	\problem{}
	Is it possible to connect three houses,
	A, B, and C, to three utility sources,
	water (W), gas (G), and electricity (E),
	without using the third dimension,
	either on the plane or sphere,
	so that the utility lines do not intersect? \\

	\begin{center}
	\begin{tikzpicture} [scale = .8]
	\draw (0,0) circle (.5);
	\coordinate [label=center:{W}] (w) at (-.05,-.03);
	\draw (4,0) circle (.5);
	\coordinate [label=center:{G}] (g) at (3.95,-.03);
	\draw (8,0) circle (.5);
	\coordinate [label=center:{E}] (e) at (7.95,-.03);
	\draw (0,3) circle (.5);
	\coordinate [label=center:{A}] (a) at (-.05,2.97);
	\draw (4,3) circle (.5);
	\coordinate [label=center:{B}] (b) at (3.95,2.97);
	\draw (8,3) circle (.5);
	\coordinate [label=center:{C}] (c) at (7.95,2.97);
	\end{tikzpicture}
	\end{center}

	\vfill
	\pagebreak

	A {\it subdivision} of a graph $G$
	is a graph resulting from the subdivision
	of the edges of $G$. The subdivision
	of an edge $e = (v_1,v_2)$ is a graph
	containing one new vertex $v_3$,
	with the edges $e_1 = (v_1,v_3)$ and
	$e_2 = (v_3,v_2)$ replacing the edge $e$. \\

	\begin{center}
	\begin{tikzpicture} [scale = .8]
	\draw (0,0) circle (.5);
	\coordinate [label=center:{$v_1$}] (v12) at (0,-.03);
	\draw (4,0) circle (.5);
	\coordinate [label=center:{$v_3$}] (v3) at (4,-.03);
	\draw (8,0) circle (.5);
	\draw (.5,0) -- (3.5,0);
	\draw (4.5,0) -- (7.5,0);
	\draw (.5,3) -- (7.5,3);
	\coordinate [label=center:{$v_2$}] (v22) at (8,-.03);
	\draw (0,3) circle (.5);
	\coordinate [label=center:{$v_1$}] (v11) at (0,2.97);
	\draw (8,3) circle (.5);
	\coordinate [label=center:{$v_2$}] (v21) at (8,2.97);
	\coordinate [label=above:{$e$}] (e) at (4,3);
	\coordinate [label=above:{$e_1$}] (e1) at (2,0);
	\coordinate [label=above:{$e_2$}] (e2) at (6,0);
	\end{tikzpicture}
	\end{center}

	\problem{}
	What is the degree of a subdivision vertex?

	\vfill

		A graph $H$ is called a {\it subgraph}
	of a graph $G$ if the sets of vertices
	and edges of $H$ are subsets of the sets
	of vertices and edges of $G$. \\

		The following graphs are known as $K_{3,3}$
	and $K_5$. \\

	\begin{center}
	\begin{tikzpicture} %[scale = .8]
	\filldraw (0,0) circle (3pt);
	\filldraw (2,0) circle (3pt);
	\filldraw (4,0) circle (3pt);
	\filldraw (0,2) circle (3pt);
	\filldraw (2,2) circle (3pt);
	\filldraw (4,2) circle (3pt);
	\draw (0,0) -- (0,2);
	\draw (0,0) -- (2,2);
	\draw (0,0) -- (4,2);
	\draw (2,0) -- (0,2);
	\draw (2,0) -- (2,2);
	\draw (2,0) -- (4,2);
	\draw (4,0) -- (0,2);
	\draw (4,0) -- (2,2);
	\draw (4,0) -- (4,2);
	\coordinate [label=below:{$K_{3,3}$}] (l) at (2,-.2);
	\end{tikzpicture} \hspace{60pt}
	\begin{tikzpicture} %[scale = .8]
	\filldraw (90:2) circle (3pt);
	\filldraw (162:2) circle (3pt);
	\filldraw (234:2) circle (3pt);
	\filldraw (306:2) circle (3pt);
	\filldraw (18:2) circle (3pt);
	\draw (90:2) -- (162:2);
	\draw (90:2) -- (234:2);
	\draw (90:2) -- (306:2);
	\draw (90:2) -- (18:2);
	\draw (162:2) -- (234:2);
	\draw (162:2) -- (306:2);
	\draw (162:2) -- (18:2);
	\draw (234:2) -- (306:2);
	\draw (234:2) -- (18:2);
	\draw (306:2) -- (18:2);
	\coordinate [label=below:{$K_5$}] (l) at (0,-1.7);
	\end{tikzpicture}
	\end{center}
	\vspace{15pt}

		Let $H$ be a graph that is a subdivision
	of either $K_{3,3}$ or $K_5$. If $H$ is
	a subgraph of a graph $G$, then $H$ is called
	a {\it Kuratowski subgraph},
	after a famous Polish mathematician
	Kazimierz Kuratowski (1896-1980). \\

	\pagebreak

	\theorem{}
	A graph is planar if and only if
	it has no Kuratowski subgraph.

	\problem{}
	Is the following graph planar?
	Why or why not? \\

	\begin{center}
	\begin{tikzpicture} [scale = .8]
	\filldraw (90:2) circle (3pt);
	\filldraw (150:2) circle (3pt);
	\filldraw (210:2) circle (3pt);
	\filldraw (270:2) circle (3pt);
	\filldraw (330:2) circle (3pt);
	\filldraw (30:2) circle (3pt);
	\draw (90:2) -- (150:2);
	\draw (90:2) -- (210:2);
	\draw (90:2) -- (270:2);
	\draw (90:2) -- (330:2);
	\draw (90:2) -- (30:2);
	\draw (150:2) -- (210:2);
	\draw (150:2) -- (270:2);
	\draw (150:2) -- (330:2);
	\draw (150:2) -- (30:2);
	\draw (210:2) -- (270:2);
	\draw (210:2) -- (330:2);
	\draw (210:2) -- (330:2);
	\draw (210:2) -- (30:2);
	\draw (270:2) -- (330:2);
	\draw (270:2) -- (30:2);
	\draw (330:2) -- (30:2);
	\end{tikzpicture}
	\end{center}

	\vfill

	\problem{}
	Is the following graph planar?
	Why or why not?

	\begin{center}
	\includegraphics[width=2.2in]{4Dcube2.jpg}
	\end{center}

	\vfill
	\pagebreak


	\section{Euler characteristic}

		Let $G$ be a planar graph,
	drawn with no edge intersections.
	The edges of $G$ divide the plane into regions,
	called {\it faces}. The regions
	enclosed by the graph are called
	the {\it interior faces}.
	The region surrounding the graph is called
	the {\it exterior (or infinite) face}.
	The faces of $G$ include both the interior faces
	and the exterior one. For example,
	the following graph has two interior faces,
	$F_1$, bounded by the edges $e_1$, $e_2$, $e_4$;
	and $F_2$, bounded by the edges $e_1$, $e_3$, $e_4$.
	Its exterior face, $F_3$, is bounded by the edges
	$e_2$, $e_3$.

	\begin{center} \label{pic:nsgrap}
	\begin{tikzpicture} [scale = .6]
	\SetGraphUnit{5}
	\Vertex{B}
	\WE(B){A}
	\EA(B){C}
	\Edge(B)(A)
	\Edge(C)(B)
	\tikzset{EdgeStyle/.append style = {bend left = 50}}
	\Edge(A)(C)
	\Edge(C)(A)
	\coordinate [label=above:{$e_1$}] (e1) at (-2.1,.0);
	\coordinate [label=above:{$e_2$}] (e2) at (0,2.45);
	\coordinate [label=below:{$e_3$}] (e3) at (0,-2.5);
	\coordinate [label=above:{$e_4$}] (e4) at (2.1,.0);
	\end{tikzpicture}
	\end{center}

		The {\it Euler characteristic} of a graph
	is the number of the graph's vertices minus
	the number of the edges plus the number of the faces.
	\begin{equation}
	\chi = V - E + F
	\end{equation}

	\problem{}
	Compute the Euler characteristic
	of the graph above.
	\vfill

	\problem{}
	Compute the Euler characteristic
	of the following graph.


	\begin{center}
	\begin{tikzpicture} [scale = .8]
	\draw (.5,3) -- (7.5,3);
	\draw (0,3) circle (.5);
	\coordinate [label=center:{$v_1$}] (v11) at (0,2.97);
	\draw (8,3) circle (.5);
	\coordinate [label=center:{$v_2$}] (v21) at (8,2.97);
	\coordinate [label=above:{$e$}] (e) at (4,3);
	\end{tikzpicture}
	\end{center}

	\vfill
	\pagebreak

	\problem{}<3Dcube>
	Is the following graph planar?
	If you think it is, please re-draw
	the graph so that it has no intersecting edges.
	If you think the graph is not planar,
	please explain why. \\

	\begin{center}
	\begin{tikzpicture}
	\draw (1,1) -- (4,1) -- (4,4) -- (1,4) -- (1,1);
	\draw (0,0) -- (3,0) -- (3,3) -- (0,3) -- (0,0);
	\draw (0,0) -- (1,1);
	\draw (3,0) -- (4,1);
	\draw (0,3) -- (1,4);
	\draw (3,3) -- (4,4);
	\filldraw (0,0) circle (3pt);
	\filldraw (3,0) circle (3pt);
	\filldraw (0,3) circle (3pt);
	\filldraw (3,3) circle (3pt);
	\filldraw (4,1) circle (3pt);
	\filldraw (1,1) circle (3pt);
	\filldraw (1,4) circle (3pt);
	\filldraw (4,4) circle (3pt);
	\end{tikzpicture}
	\end{center}

	\vfill

	\problem{}
	Compute the Euler characteristic of the graph
	from Problem \ref{3Dcube}.

	\vfill
	\pagebreak

		Let us consider the below picture
	of a {\it regular dodecahedron} as a graph,
	the vertices representing those of the graph,
	and the edges, both solid and dashed,
	representing the edges of the graph.

	\problem{}<dodec>
	Is the graph planar?
	If you think it is planar,
	please re-draw the graph so that it has
	no intersecting edges. If you think the graph
	is not planar, please explain why. \\

	\begin{center}
	\includegraphics[width=2.5in]
	{dodecahedron.jpg}
	\end{center}

	\vfill

	\problem{}
	Compute the Euler characteristic of the graph
	from Problem \ref{dodec}.
	Can you conjecture what the Euler characteristic
	of every planar graph is equal to?

	\vfill
	\pagebreak

		A graph is called a {\it tree}
	if it is connected and has no cycles.
	Here is an example. \\

	\begin{center}
	\begin{tikzpicture} [scale = .6]
	\SetGraphUnit{5}
	\Vertex{A}
	\SOWE(A){B}
	\SO(A){C}
	\SOEA(A){D}
	\SOWE(B){E}
	\SO(B){F}
	\SOEA(D){G}
	\Edge(A)(B)
	\Edge(A)(C)
	\Edge(A)(D)
	\Edge(B)(E)
	\Edge(B)(F)
	\Edge(D)(G)
	%\tikzset{EdgeStyle/.append style = {bend left = 50}}
	\end{tikzpicture}
	\end{center}
	\bigskip

		A path is called {\it simple}
	if it does not include any of its edges
	more than once.

	\problem{}
	Prove that a graph in which any two vertices are connected by one
	and only one simple path is a tree.

	\problem{}
	What is the Euler characteristic
	of a finite tree?

	\theorem{}<eu_char>
	Let a finite connected planar graph have
	$V$ vertices, $E$ edges, and $F$ faces.
	Then $V - E + F = 2$.

	\problem{}
	Prove Theorem \ref{eu_char}.
	Hint: removing an edge from a cycle
	does not change the number of vertices
	and reduces the number of edges and faces
	by one.

	\problem{}
	There are three ponds in a botanical garden,
	connected by ten non-intersecting brooks
	so that the ducks can sweem from any pond to any other.
	How many islands are there in the garden?

	\problem{}
	All the vertices of a finite graph
	have degree three.
	Prove that the graph has a cycle.

	\problem{}
	Draw an infinite tree with every vertex
	of degree three.

	\problem{}
	Prove that a connected finite graph is a tree
	if and only if $V = E + 1$.

	\problem{}
	Give an example of a finite graph
	that is not a tree,
	but satisfies the relation $V = E + 1$.

\end{document}