From 597f32cd698d97f19f2b04189c35fe8e1cd173b1 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 20 Mar 2024 19:38:35 -0700 Subject: [PATCH] Added initial De Bruijn sections --- Advanced/De Bruijn/main.tex | 27 +++ Advanced/De Bruijn/parts/0 intro.tex | 55 +++++ Advanced/De Bruijn/parts/1 words.tex | 206 ++++++++++++++++++ Advanced/De Bruijn/parts/2 bruijn.tex | 287 ++++++++++++++++++++++++++ Advanced/De Bruijn/parts/3 line.tex | 101 +++++++++ Advanced/De Bruijn/tikzset.tex | 65 ++++++ 6 files changed, 741 insertions(+) create mode 100755 Advanced/De Bruijn/main.tex create mode 100644 Advanced/De Bruijn/parts/0 intro.tex create mode 100644 Advanced/De Bruijn/parts/1 words.tex create mode 100644 Advanced/De Bruijn/parts/2 bruijn.tex create mode 100644 Advanced/De Bruijn/parts/3 line.tex create mode 100644 Advanced/De Bruijn/tikzset.tex diff --git a/Advanced/De Bruijn/main.tex b/Advanced/De Bruijn/main.tex new file mode 100755 index 0000000..0c8d430 --- /dev/null +++ b/Advanced/De Bruijn/main.tex @@ -0,0 +1,27 @@ +% use [nosolutions] flag to hide solutions. +% use [solutions] flag to show solutions. +\documentclass[ + solutions, + singlenumbering, + shortwarning +]{../../resources/ormc_handout} +\usepackage{../../resources/macros} + +\input{tikzset.tex} + +\uptitlel{Advanced 2} +\uptitler{Spring 2024} +\title{De Bruijn Sequences} +\subtitle{Prepared by \githref{Mark} on \today{}} + + +\begin{document} + + \maketitle + + \input{parts/0 intro} + \input{parts/1 words} + \input{parts/2 bruijn} + \input{parts/3 line} + +\end{document} \ No newline at end of file diff --git a/Advanced/De Bruijn/parts/0 intro.tex b/Advanced/De Bruijn/parts/0 intro.tex new file mode 100644 index 0000000..1166dca --- /dev/null +++ b/Advanced/De Bruijn/parts/0 intro.tex @@ -0,0 +1,55 @@ +\section{Introduction} + +\example{} +A certain electronic lock has two buttons: \texttt{0} and \texttt{1}. +It opens as soon as the correct two-digit code is entered, completely ignoring +previous inputs.\hspace{-0.5ex}\footnotemark{} For example, if the correct code is \text{10}, the lock will open +once the sequence \texttt{010} is entered. + +\vspace{2mm} + +Naturally, there are $2^2 = 4$ possible combinations that open this lock. \par +If don't know the lock's combination, we could try to guess it by trying all four combinations. \par +This would require eight key presses: \texttt{0001101100}. + +\problem{} +There is, of course, a better way. \par +Unlock this lock with only 5 keypresses. + +\begin{solution} + The sequence \texttt{00110} is guaranteed to unlock this lock. +\end{solution} + + +\problem{} +Consider the same lock, now set with a three-digit binary code. +\begin{itemize} + \item How many codes are possible? + \item What is the shortest sequence that is guaranteed to unlock the lock? \par + \hint{You'll need 10 digits.} +\end{itemize} + +\begin{solution} + \begin{itemize} + \item $2^3 = 8$ + \item \texttt{0001110100} will do. + \end{itemize} +\end{solution} + + +\problem{} +How about a four-digit code? How many digits do we need? \par + +\begin{instructornote} + Don't spend too long on this problem. + Provide a solution at the board once everyone has had a few + minutes to think about this. +\end{instructornote} + +\begin{solution} + Interestingly enough, we can only save one digit. \par + Any optimal sequence has 15 digits, for example \texttt{0000111101100101000} +\end{solution} + +\vfill +\pagebreak \ No newline at end of file diff --git a/Advanced/De Bruijn/parts/1 words.tex b/Advanced/De Bruijn/parts/1 words.tex new file mode 100644 index 0000000..0ee1ea8 --- /dev/null +++ b/Advanced/De Bruijn/parts/1 words.tex @@ -0,0 +1,206 @@ +\section{Words} + +\definition{} +An \textit{alphabet} is a set of symbols. \par +For example, $\{\texttt{0}, \texttt{1}\}$ is an alphabet of two symbols, \par +and $\{\texttt{a}, \texttt{b}, \texttt{c}\}$ is an alphabet of three. + +\definition{} +A \textit{word} over an alphabet $A$ is a sequence of symbols in that alphabet. \par +For example, $\texttt{00110}$ is a word over the alphabet $\{\texttt{0}, \texttt{1}\}$. \par +We'll let $\varnothing$ denote the empty word, which exists over every alphabet. + +\definition{} +Let $v$ and $w$ be words over the same alphabet. \par +We say $v$ is a \textit{subword} of $w$ if $v$ is contained in $w$. \par +For example, \texttt{11} is a subword of \texttt{011}, but \texttt{00} is not. + +\definition{} +Recall \ref{lockproblem}. From now on, we'll call this the \textit{$n$-subword problem}: \par +Given an alphabet $A$ and a positive integer $n$, we want a \par +word over $A$ that contains all possible length-$n$ subwords. \par +The shortest word that solves a given $n$-subword problem is called the \textit{optimal solution}. + + + +\problem{} +List all subwords of \texttt{110}. \par +\hint{There are six.} + +\begin{solution} + They are $\varnothing$, \texttt{0}, \texttt{1}, \texttt{10}, \texttt{11}, and \texttt{110}. +\end{solution} + +\vfill + + +\definition{} +Let $\mathcal{S}_n(w)$ be the number of subwords of length $n$ in a word $w$. + +\problem{} +Find the following: +\begin{itemize} + \item $\mathcal{S}_n(\texttt{101001})$ for $n \in \{0, 1, ..., 6\}$ + \item $\mathcal{S}_n(\texttt{abccac})$ for $n \in \{0, 1, ..., 6\}$ +\end{itemize} + +\begin{solution} + In order from $\mathcal{S}_0$ to $\mathcal{S}_6$: + \begin{itemize} + \item 1, 2, 3, 3, 3, 2, 1 + \item 1, 3, 5, 4, 3, 2, 1 + \end{itemize} +\end{solution} + +\vfill +\pagebreak + +\problem{} +Let $w$ be a word over an alphabet of size $k$. \par +Prove the following: +\begin{itemize} + \item $\mathcal{S}_n(w) \leq k^n$ + \item $\mathcal{S}_n(w) \geq \mathcal{S}_{n-1}(w) - 1$ + \item $\mathcal{S}_n(w) \leq k \times \mathcal{S}_{n-1}(w)$ +\end{itemize} + +\begin{solution} + \begin{itemize} + \item There are $k$ choices for each of $n$ letters in the subword. + So, there are $k^n$ possible words of length $n$, and $\mathcal{S}_n(w) \leq k^n$. + + \item For almost every distinct subword counted by $\mathcal{S}_{n-1}$, + concatenating the next letter creates a distinct length $n$ subword. + The only exception is the last subword with length $n-1$, so + $\mathcal{S}_n(w) \geq \mathcal{S}_{n-1}(w) - 1$ + + \item For each subword counted by $\mathcal{S}_{n-1}$, there are $k$ possibilities + for the letter that follows in $w$. Each element in the count $\mathcal{S}_n$ comes from + one of $k$ different length $n$ words starting with an element counted by $\mathcal{S}_{n-1}$. + Thus, $\mathcal{S}_n(w) \leq k \times \mathcal{S}_{n-1}(w)$ + \end{itemize} +\end{solution} + + +\vfill +\pagebreak + + + +\definition{} +Let $v$ and $w$ be words over the same alphabet. \par +The word $vw$ is the word formed by writing $v$ after $w$. \par +For example, if $v = \texttt{1001}$ and $w = \texttt{10}$, $vw$ is $\texttt{100110}$. + +\problem{} +Let $F_k$ denote the word over the alphabet $\{\texttt{0}, \texttt{1}\}$ obtained from the following relation: +\begin{equation*} + F_0 = \texttt{0}; ~~ F_1 = \texttt{1}; ~~ F_k = F_{k-1}F_{k-2} +\end{equation*} +We'll call this the \textit{Fibonacci word} of order $k$. +\begin{itemize} + \item What are $F_3$, $F_4$, and $F_5$? + \item Compute $\mathcal{S}_0$ through $\mathcal{S}_5$ for $F_5$. + \item Show that the length of $F_k$ is the $(k + 2)^\text{th}$ Fibonacci number. \par + \hint{Induction.} +\end{itemize} + +\begin{solution} + \begin{itemize} + \item $F_3 = \texttt{101}$ + \item $F_4 = \texttt{10110}$ + \item $F_5 = \texttt{10110101}$ + \end{itemize} + + \linehack{} + + \begin{itemize} + \item $\mathcal{S}_0 = 1$ + \item $\mathcal{S}_1 = 2$ + \item $\mathcal{S}_2 = 3$ + \item $\mathcal{S}_3 = 4$ + \item $\mathcal{S}_4 = 5$ + \item $\mathcal{S}_5 = 4$ + \end{itemize} + + \linehack + + As stated, use induction. The base case is trivial. \par + Let $N_k$ represent the Fibonacci numbers, with $N_0 = 0$, $N_1 = 1$, and $N_{k} = N_{k-1} + N_{k-2}$ + + \vspace{2mm} + + Assume that $F_k$ has length $N_{k+2}$ for all $k \leq n$. + We want to show that $F_{k+1}$ has length $N_{k+3}$. \par + Since $F_{k} = F_{k-1}F_{k-2}$, it has the length $|F_{k-1}| + |F_{k-2}|$. \par + By our assumption, $|F_{k-1}| = N_{k+1}$ and $|F_{k-2}| = N_{k}$. \par + So, $|F_{k}| = |F_{k-1}| + |F_{k-2}| = N_{k+1} + N_{k} = N_{k + 2}$. + +\end{solution} + +\vfill +\pagebreak + + + + + +% C_k is called the "Champernowne word" of order k. +\problem{} +Let $C_k$ denote the word over the alphabet $\{\texttt{0}, \texttt{1}\}$ obtained by \par +concatenating the binary representations of the integers $0,~...,~2^k -1$.\par +For example, $C_1 = \texttt{0}$, $C_2 = \texttt{011011}$, and $C_3 = \texttt{011011100101110111}$. +\begin{itemize} + \item How many symbols does the word $C_k$ contain? + \item Compute $\mathcal{S}_0$, $\mathcal{S}_1$, $\mathcal{S}_2$, and $\mathcal{S}_3$ for $C_3$. + \item Show that $\mathcal{S}_k(C_k) = 2^k - 1$. + \item Show that $\mathcal{S}_n(C_k) = 2^n$ for $n < k$. +\end{itemize} +\hint{ + If $v$ is a subword of $w$ and $w$ is a subword of $u$, $v$ must be a subword of $u$. \par + In other words, the \say{subword} relation is transitive. +} + +\begin{solution} + $\mathcal{S}_0 = 1$, $\mathcal{S}_1 = 2$, $\mathcal{S}_2 = 4$, and $\mathcal{S}_3 = 7$. + + \linehack{} + + First, we show that $\mathcal{S}_k(C_k) = 2^k - 1$. \par + Consider an arbitrary word $w$ of length $k$. We'll consider three cases: + + \begin{itemize} + \item If $w$ consists only of zeros, $w$ does not appear in $C_k$. + + \item If $w$ starts with a \texttt{1}, $w$ must appear in $C_k$ by construction. + + \item If $w$ does starts with a \texttt{0} and contains a \texttt{1}, $w$ has the form + $\texttt{0}^x\texttt{1}[..\texttt{y}..]$ \par + \note{ + That is, $x$ copies of \texttt{0} followed by a \texttt{1}, followed by \par + an arbitrary sequence $\texttt{y}$ with length $(k-x-1)$. + } \par + Now consider the word $\texttt{1}[..\texttt{y}..]\texttt{0}^x\texttt{1}[..\texttt{y}..]\texttt{0}^{(x-1)}\texttt{1}$. \par + This is the concatenation of two consecutive binary numbers with $k$ digits, and thus appears in $C_k$. + $w$ is a subword of this word, and therefore also appears in $C_k$. + \end{itemize} + + \linehack{} + + We can use the above result to conclude that $\mathcal{S}_n(C_k) = 2^n$ for $n < k$: \par + If we take any word of length $n < k$ and repeatedly append \texttt{1} to create a word of length $k$, \par + we end up with a subword of $C_k$ by the reasoning above. \par + Thus, any word of length $n$ is a subword of $w$, of which there are $2^n$. +\end{solution} + + +\vfill + +\problem{} +Convince yourself that $C_{n+1}$ provides a solution to the $n$-subword problem over $\{\texttt{0}, \texttt{1}\}$. \par +\note[Note]{$C_{n+1}$ may or may not be an \textit{optimal} solution---but it is a \textit{valid} solution} \par +Which part of \ref{cword} shows that this is true? + +\pagebreak + + diff --git a/Advanced/De Bruijn/parts/2 bruijn.tex b/Advanced/De Bruijn/parts/2 bruijn.tex new file mode 100644 index 0000000..5057faf --- /dev/null +++ b/Advanced/De Bruijn/parts/2 bruijn.tex @@ -0,0 +1,287 @@ +\section{De Bruijn Words} + +Before we continue, we'll need to review some basic +graph theory. + +\definition{} +A \textit{directed graph} consists of nodes and directed edges. \par +An example is shown below. It consists of three vertices (labeled $a, b, c$), \par +and five edges (labeled $0, ... , 4$). + +\begin{center} + \begin{tikzpicture} + \begin{scope}[layer = nodes] + \node[main] (a) at (0, 0) {$a$}; + \node[main] (b) at (2, 0) {$b$}; + \node[main] (c) at (4, 0) {$c$}; + \end{scope} + + \draw[->] + (a) edge node[label] {$0$} (b) + (a) edge[loop above] node[label] {$1$} (a) + (b) edge[bend left] node[label] {$2$} (c) + (b) edge[loop above] node[label] {$3$} (b) + (c) edge[bend left] node[label] {$4$} (b) + ; + \end{tikzpicture} +\end{center} + +\definition{} +A \textit{path} in a graph is a sequence of adjacent edges. \par +In a directed graph, adjacent edges are those that start and end at the same node. \par +\vspace{2mm} +For example, consider the graph above. \par +The edges $0$ and $1$ are not adjacent, because $0$ and $1$ both \textit{end} at $b$. \par +$0$ and $2$, however, are: $0$ ends at $b$, and $2$ starts at $b$. +$[0, 3, 2]$ is a path in the graph above, drawn below. \par + + +\definition{} +An \textit{Eulerian path} is a path that visits each edge of a graph exactly once. \par +An \textit{Eulerian cycle} is an Eulerian path that starts and ends on the same node. + +\problem{} +Find the single unique Eulerian cycle in the graph below. +\begin{center} + \begin{tikzpicture} + \begin{scope}[layer = nodes] + \node[main] (a) at (0, 0) {$a$}; + \node[main] (b) at (2, 0) {$b$}; + \node[main] (c) at (4, 0) {$c$}; + \end{scope} + + \draw[->] + (a) edge[bend left] node[label] {$0$} (b) + (b) edge[bend left] node[label] {$1$} (a) + (b) edge[bend left] node[label] {$2$} (c) + (c) edge[bend left] node[label] {$3$} (b) + (c) edge[loop right] node[label] {$4$} (c) + ; + \end{tikzpicture} +\end{center} + +\begin{solution} + $24310$ is one way to write this cycle. \par + There are other options, but they're all the same. +\end{solution} + +\vfill +\pagebreak + + + +\definition{} +Now, consider the $n$-subword problem over $\{\texttt{0}, \texttt{1}\}$. \par +We'll call the optimal solution to this problem a \textit{De Bruijn\footnotemark{} word} of order $n$. \par + +\footnotetext{Dutch. Rhymes with \say{De Grown.}} + + +\problem{} +Let $\mathcal{B}_n$ be the length of an order-$n$ De Bruijn word. \par +Show that the following bounds always hold: +\begin{itemize} + \item $\mathcal{B}_n \leq n2^n$ + \item $\mathcal{B}_n \geq 2^n + n - 1$ +\end{itemize} + +\begin{solution} + \begin{itemize} + \item There are $2^n$ binary words with length $n$. \par + Concatenate these to get a word with length $n2^n$. + \item A word must have at least $2^n + n - 1$ letters to have $2^n$ subwords with length $n$. + \end{itemize} +\end{solution} + + +\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. + +\definition{} +Consider a $n$-length word $w$. \par +The \textit{prefix} of $w$ is the word formed by the first $n-1$ letters of $w$. \par +The \textit{suffix} of $w$ is the word formed by the last $n-1$ letters of $w$. \par +For example, the prefix of the word \texttt{1101} is \texttt{110}, and its suffix is \texttt{101}. +The prefix and suffix of any one-letter word are both $\varnothing$. + +\definition{} +A \textit{De Bruijn graph} of order $n$, denoted $G_n$, is constructed as follows: +\begin{itemize} + \item Nodes are created for each word of length $n - 1$. + \item A directed edge is drawn from $a$ to $b$ if the suffix of + $a$ matches the prefix of $b$. \par + Note that a node may have an edge to itself. + \item We label each edge with the last letter of $b$. +\end{itemize} +$G_2$ and $G_3$ are shown below. + +\null\hfill +\begin{minipage}{0.48\textwidth} + \begin{center} + $G_2$ + + \begin{tikzpicture} + \begin{scope}[layer = nodes] + \node[main] (0) at (0, 0) {\texttt{0}}; + \node[main] (1) at (2, 0) {\texttt{1}}; + \end{scope} + + \draw[->] + (0) edge[loop left] node[label] {$0$} (0) + (1) edge[loop right] node[label] {$1$} (1) + (1) edge[bend left] node[label] {$0$} (0) + (0) edge[bend left] node[label] {$1$} (1) + ; + \end{tikzpicture} + \end{center} +\end{minipage} +\hfill +\begin{minipage}{0.48\textwidth} + \begin{center} + $G_3$ + + \begin{tikzpicture}[scale = 0.9] + \begin{scope}[layer = nodes] + \node[main] (00) at (0, 0) {\texttt{00}}; + \node[main] (01) at (2, 1) {\texttt{01}}; + \node[main] (10) at (2, -1) {\texttt{10}}; + \node[main] (11) at (4, 0) {\texttt{11}}; + \end{scope} + + \draw[->] + (00) edge[loop left] node[label] {$0$} (00) + (11) edge[loop right] node[label] {$1$} (11) + (00) edge[bend left] node[label] {$1$} (01) + (01) edge[bend left] node[label] {$0$} (10) + (10) edge[bend left] node[label] {$1$} (01) + (10) edge[bend left] node[label] {$0$} (00) + (01) edge[bend left] node[label] {$1$} (11) + (11) edge[bend left] node[label] {$0$} (10) + ; + \end{tikzpicture} + \end{center} +\end{minipage} +\hfill\null + +\vfill +\pagebreak + +\problem{} +Draw $G_4$. + +\begin{solution} + \begin{center} + \begin{tikzpicture} + \begin{scope}[layer = nodes] + \node[main] (7) at (0, 0) {\texttt{111}}; + \node[main] (3) at (0, -2) {\texttt{011}}; + \node[main] (6) at (2, -2) {\texttt{110}}; + \node[main] (4) at (4, -2) {\texttt{100}}; + \node[main] (1) at (-4, -4) {\texttt{001}}; + \node[main] (5) at (0, -4) {\texttt{101}}; + \node[main] (2) at (-2, -4) {\texttt{010}}; + \node[main] (0) at (-2, -6) {\texttt{000}}; + \end{scope} + + \draw[->] + (0) edge[loop left, looseness = 7] node[label] {\texttt{0}} (0) + (7) edge[loop above, looseness = 7] node[label] {\texttt{1}} (7) + + (0) edge[out=90,in=-90] node[label] {\texttt{1}} (1) + (1) edge node[label] {\texttt{0}} (2) + (1) edge[out=45,in=-135] node[label] {\texttt{1}} (3) + (2) edge[bend left] node[label] {\texttt{1}} (5) + (3) edge node[label] {\texttt{0}} (6) + (3) edge node[label] {\texttt{1}} (7) + (5) edge[bend left] node[label] {\texttt{0}} (2) + (5) edge node[label] {\texttt{1}} (3) + (6) edge[bend left] node[label] {\texttt{0}} (4) + (6) edge[out=-90,in=0] node[label] {\texttt{1}} (5) + (7) edge[out=0,in=90] node[label] {\texttt{0}} (6) + ; + + \draw[->, rounded corners = 10mm] + (4) to (4, 2) to node[label] {\texttt{1}} (-4, 2) to (1) + ; + + \draw[->, rounded corners = 10mm] + (4) to (4, -6) to node[label] {\texttt{0}} (0) + ; + + \draw[->, rounded corners = 5mm] + (2) to (-2, -5) to node[label] {\texttt{0}} (3, -5) to (3, -2) to (4) + ; + \end{tikzpicture} + \end{center} + + \begin{instructornote} + This graph also appears as a solution to a different + problem in the DFA handout. + \end{instructornote} +\end{solution} + +\vfill + + +\problem{} +\begin{itemize} + \item Show that $G_n$ has $2^{n-1}$ nodes and $2^n$ edges; + \item that each node has two outgoing edges; + \item and that there are as many edges labeled $0$ as are labeled $1$. +\end{itemize} + +\begin{solution} + \begin{itemize} + \item There $2^{n-1}$ binary words of length $n-1$. + \item The suffix of a given word is the prefix of two other words, \par + so there are two edges leaving each node. + \item One of those words will end with one, and the other will end with zero. + \item Our $2^{n-1}$ nodes each have $2$ outgoing edges---we thus have $2^n$ edges in total. + \end{itemize} +\end{solution} + +\vfill +\pagebreak + + +\theorem{} +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, + then appending the label of every edge we travel. +\end{itemize} + +\problem{} +Find De Bruijn words of orders $2$, $3$, and $4$. + +\begin{solution} + \begin{itemize} + \item + One Eulerian cycle in $G_2$ starts at node \texttt{0}, and takes the edges labeled $[1, 1, 0, 0]$. \par + We thus have the word \texttt{01100}. + + \item + In $G_3$, we have an Eulerian cycle that visits nodes in the following order: \par + $ + \texttt{00} + \rightarrow \texttt{01} + \rightarrow \texttt{11} + \rightarrow \texttt{11} + \rightarrow \texttt{10} + \rightarrow \texttt{01} + \rightarrow \texttt{10} + \rightarrow \texttt{00} + \rightarrow \texttt{00} + $\par + This gives us the word \texttt{0011101000} + + \item Similarly, we $G_4$ gives us the word \texttt{0001 0011 0101 1110 000}. \par + \note{Spaces have been added for convenience.} + \end{itemize} +\end{solution} + +\vfill +\pagebreak \ No newline at end of file diff --git a/Advanced/De Bruijn/parts/3 line.tex b/Advanced/De Bruijn/parts/3 line.tex new file mode 100644 index 0000000..5d8c758 --- /dev/null +++ b/Advanced/De Bruijn/parts/3 line.tex @@ -0,0 +1,101 @@ +\section{Line Graphs} + +\problem{} +Given a graph $G$, we can construct its \textit{line graph} (denoted $\mathcal{L}(G)$) by doing the following: \par +\begin{itemize} + \item Creating a node in $\mathcal{L}(G)$ for each edge in $G$ + \item Drawing a directed edge between every pair of nodes $a, b$ in $\mathcal{L}(G)$ \par + if the corresponding edges in $G$ are adjacent. \par + \note{That is, if edge $b$ in $G$ starts at the node at which $a$ ends.} +\end{itemize} + +\problem{} +Draw the line graph for the graph below. \par +Have an instructor check your solution. + +\begin{center} + \begin{tikzpicture} + \begin{scope}[layer = nodes] + \node[main] (a) at (0, 0) {$a$}; + \node[main] (b) at (2, 0) {$b$}; + \node[main] (c) at (4, 0) {$c$}; + \end{scope} + + \draw[->] + (a) edge[bend left] node[label] {$0$} (b) + (b) edge[bend left] node[label] {$1$} (a) + (b) edge[bend left] node[label] {$2$} (c) + (c) edge[bend left] node[label] {$3$} (b) + (c) edge[loop right] node[label] {$4$} (c) + ; + \end{tikzpicture} +\end{center} + +\begin{solution} + \begin{center} + \begin{tikzpicture} + \begin{scope}[layer = nodes] + \node[main] (0) at (0, 0) {$0$}; + \node[main] (1) at (2, -4) {$1$}; + \node[main] (2) at (0, -2) {$2$}; + \node[main] (3) at (2, -2) {$3$}; + \node[main] (4) at (2, 0) {$4$}; + \end{scope} + + \draw[->] + (0) edge[bend left] (2) + (2) edge[bend left] (0) + (0) edge (4) + (4) edge[bend left] (2) + (2) edge (1) + (1) edge[bend left] (3) + (3) edge[bend left] (1) + (3) edge (0) + ; + \end{tikzpicture} + \end{center} +\end{solution} + + +\vfill + +\definition{} +We say a graph $G$ is \textit{connected} if there is a path +between any two vertices of $G$. + +\problem{} +Show that if $G$ is connected, $\mathcal{L}(G)$ is connected. + +\begin{solution} + Let $a, b$ and $x, y$ be nodes in a connected graph $G$ so that an edges $a \rightarrow b$ and + and $x \rightarrow y$ exist. Since $G$ is connected, we can find a path from $b$ to $x$. + The path $a$ to $y$ corresponds to a path in $\mathcal{L}(G)$ between $a \rightarrow b$ and $x \rightarrow y$. +\end{solution} + +\vfill +\pagebreak + + +\definition{} +Consider $\mathcal{L}(G_n)$, where $G_n$ is the $n^\text{th}$ order De Bruijn graph. \par + +\vspace{2mm} + +We'll need to label the vertices of $\mathcal{L}(G_n)$. To do this, do the following: +\begin{itemize} + \item Let $a$ and $b$ be nodes in $G_n$ + \item Let \texttt{x} be the first letter of $a$ + \item Let \texttt{y}, the last letter of $b$ + \item Let $\overline{\texttt{p}}$ be the prefix/suffix that $a$ and $b$ share. \par + Note that $a = \texttt{x}\overline{\texttt{p}}$ and $b = \overline{\texttt{p}}\texttt{y}$, +\end{itemize} +Now, relabel the edge from $a$ to $b$ as $\texttt{x}\overline{\texttt{p}}\texttt{y}$. \par +Use these new labels to name nodes in $\mathcal{L}(G_n)$. + +\problem{} +Construct $\mathcal{L}(G_2)$ and $\mathcal{L}(G_3)$. What do you notice? + +\begin{solution} + After fixing edge labels, we find that + $\mathcal{L}(G_2) \cong G_3$, and $\mathcal{L}(G_3) \cong G_4$ +\end{solution} \ No newline at end of file diff --git a/Advanced/De Bruijn/tikzset.tex b/Advanced/De Bruijn/tikzset.tex new file mode 100644 index 0000000..d83fa32 --- /dev/null +++ b/Advanced/De Bruijn/tikzset.tex @@ -0,0 +1,65 @@ +\usetikzlibrary{arrows.meta} +\usetikzlibrary{shapes.geometric} +\usetikzlibrary{patterns} + +% We put nodes in a separate layer, so we can +% slightly overlap with paths for a perfect fit +\pgfdeclarelayer{nodes} +\pgfdeclarelayer{path} +\pgfsetlayers{main,nodes} + +% Layer settings +\tikzset{ + % Layer hack, lets us write + % later = * in scopes. + layer/.style = { + execute at begin scope={\pgfonlayer{#1}}, + execute at end scope={\endpgfonlayer} + }, + % + % Arrowhead tweak + >={Latex[ width=2mm, length=2mm ]}, + % + % Labels inside edges + label/.style = { + rectangle, + % For automatic red background in solutions + fill = \ORMCbgcolor, + draw = none, + rounded corners = 0mm + }, + % + % Nodes + main/.style = { + draw, + circle, + fill = white, + line width = 0.35mm + }, + % + % Loop tweaks + loop above/.style = { + min distance = 2mm, + looseness = 8, + out = 45, + in = 135 + }, + loop below/.style = { + min distance = 5mm, + looseness = 10, + out = 315, + in = 225 + }, + loop right/.style = { + min distance = 5mm, + looseness = 10, + out = 45, + in = 315 + }, + loop left/.style = { + min distance = 5mm, + looseness = 10, + out = 135, + in = 215 + } +} \ No newline at end of file