|
|
|
@ -66,6 +66,24 @@ Find the single unique Eulerian cycle in the graph below.
|
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
\theorem{}<eulerexists>
|
|
|
|
|
A directed graph contains an Eulerian cycle iff...
|
|
|
|
|
\begin{itemize}
|
|
|
|
|
\item There is a path between every pair of nodes, and
|
|
|
|
|
\item every node has as many \say{in} edges as it has \say{out} edges.
|
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
|
|
If the a graph contains an Eulerian cycle, it must contain an Eulerian path. \note{(why?)} \par
|
|
|
|
|
Some graphs contain an Eulerian path, but not a cycle. In this case, both conditions above must
|
|
|
|
|
still hold, but the following exceptions are allowed:
|
|
|
|
|
\begin{itemize}
|
|
|
|
|
\item There may be at most one node where $(\text{number in} - \text{number out}) = 1$
|
|
|
|
|
\item There may be at most one node where $(\text{number in} - \text{number out}) = -1$
|
|
|
|
|
\end{itemize}
|
|
|
|
|
We won't provide a proof of this theorem today. However, you should convince yourself that it is true:
|
|
|
|
|
if any of these conditions are violated, why do we know that an Eulerian cycle (or path) cannot exist?
|
|
|
|
|
|
|
|
|
|
\pagebreak
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -77,7 +95,7 @@ We'll call the optimal solution to this problem a \textit{De Bruijn\footnotemark
|
|
|
|
|
\footnotetext{Dutch. Rhymes with \say{De Grown.}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
|
\problem{}<dbbounds>
|
|
|
|
|
Let $\mathcal{B}_n$ be the length of an order-$n$ De Bruijn word. \par
|
|
|
|
|
Show that the following bounds always hold:
|
|
|
|
|
\begin{itemize}
|
|
|
|
@ -96,7 +114,11 @@ Show that the following bounds always hold:
|
|
|
|
|
|
|
|
|
|
\remark{}
|
|
|
|
|
Now, we'd like to show that $\mathcal{B}_n = 2^n + n - 1$... \par
|
|
|
|
|
That is, that the optimal solution to the subword problem always has $2^n + n - 1$ letters.
|
|
|
|
|
That is, that the optimal solution to the subword problem always has $2^n + n - 1$ letters. \par
|
|
|
|
|
We'll do this by construction: for a given $n$, we want to build a word with length $2^n + n - 1$
|
|
|
|
|
that solves the binary $n$-subword problem.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\definition{}
|
|
|
|
|
Consider a $n$-length word $w$. \par
|
|
|
|
@ -241,16 +263,20 @@ Draw $G_4$.
|
|
|
|
|
\end{itemize}
|
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
|
|
\problem{}<dbpath>
|
|
|
|
|
Show that $G_4$ always contains an Eulerian path. \par
|
|
|
|
|
\hint{\ref{eulerexists}}
|
|
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
\pagebreak
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\theorem{}
|
|
|
|
|
\theorem{}<dbeuler>
|
|
|
|
|
We can now easily construct De Bruijn words for a given $n$: \par
|
|
|
|
|
\begin{itemize}
|
|
|
|
|
\item Construct $G_n$,
|
|
|
|
|
\item then an Eulerian cycle in $G_n$.
|
|
|
|
|
\item Finally, construct a De Bruijn by writing the label of our starting vertex,
|
|
|
|
|
\item find an Eulerian cycle in $G_n$,
|
|
|
|
|
\item then, construct a De Bruijn word by writing the label of our starting vertex,
|
|
|
|
|
then appending the label of every edge we travel.
|
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
|
@ -284,4 +310,48 @@ Find De Bruijn words of orders $2$, $3$, and $4$.
|
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
Let's quickly show that the process described in \ref{dbeuler}
|
|
|
|
|
indeed produces a valid De Bruijn word.
|
|
|
|
|
|
|
|
|
|
\problem{}<dblength>
|
|
|
|
|
How long will a word generated by the above process be?
|
|
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
|
A De Bruijn graph has $2^n$ edges, each of which is traversed exactly once.
|
|
|
|
|
The starting node consists of $n - 1$ letters.
|
|
|
|
|
|
|
|
|
|
\vspace{2mm}
|
|
|
|
|
|
|
|
|
|
Thus, the resulting word contains $2^n + n - 1$ symbols.
|
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
\problem{}<dbsubset>
|
|
|
|
|
Show that a word generated by the process in \ref{dbeuler}
|
|
|
|
|
contains every possible length-$n$ subword. \par
|
|
|
|
|
In other words, show that $\mathcal{S}_n(w) = 2^n$ for a generated word $w$.
|
|
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
|
TODO
|
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
\remark{}
|
|
|
|
|
\begin{itemize}
|
|
|
|
|
\item We found that \ref{dbeuler} generates a word with length $2^n + n - 1$ in \ref{dblength}, \par
|
|
|
|
|
\item and we showed that this word always solves the $n$-subword problem in \ref{dbsubset}.
|
|
|
|
|
|
|
|
|
|
\item From \ref{dbbounds}, we know that any solution to the binary $n$-subword problem \par
|
|
|
|
|
must have at least $2^n + n - 1$ letters.
|
|
|
|
|
|
|
|
|
|
\item Finally, \ref{dbpath} guarantees that it is possible to generate such a word in any $G_n$.
|
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
|
|
Thus, we have shown that the process in \ref{dbeuler} generates ideal solutions
|
|
|
|
|
to the $n$-subword problem, and that such solutions always exist.
|
|
|
|
|
We can now conclude that for any $n$, the binary $n$-subword problem may be solved with a word of length $2^n + n - 1$.
|
|
|
|
|
|
|
|
|
|
\pagebreak
|