\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