-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhw2s.tex
executable file
·2397 lines (2211 loc) · 107 KB
/
hw2s.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[numbers=enddot,12pt,final,onecolumn,notitlepage]{scrartcl}%
\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}
\usepackage[all,cmtip]{xy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{framed}
\usepackage{comment}
\usepackage{color}
\usepackage{hyperref}
\usepackage{ifthen}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{needspace}
\usepackage{tabls}
%TCIDATA{OutputFilter=latex2.dll}
%TCIDATA{Version=5.50.0.2960}
%TCIDATA{LastRevised=Friday, September 16, 2016 20:39:00}
%TCIDATA{SuppressPackageManagement}
%TCIDATA{<META NAME="GraphicsSave" CONTENT="32">}
%TCIDATA{<META NAME="SaveForMode" CONTENT="1">}
%TCIDATA{BibliographyScheme=Manual}
%TCIDATA{Language=American English}
%BeginMSIPreambleData
\providecommand{\U}[1]{\protect\rule{.1in}{.1in}}
%EndMSIPreambleData
\newcounter{exer}
\theoremstyle{definition}
\newtheorem{theo}{Theorem}[section]
\newenvironment{theorem}[1][]
{\begin{theo}[#1]\begin{leftbar}}
{\end{leftbar}\end{theo}}
\newtheorem{lem}[theo]{Lemma}
\newenvironment{lemma}[1][]
{\begin{lem}[#1]\begin{leftbar}}
{\end{leftbar}\end{lem}}
\newtheorem{prop}[theo]{Proposition}
\newenvironment{proposition}[1][]
{\begin{prop}[#1]\begin{leftbar}}
{\end{leftbar}\end{prop}}
\newtheorem{defi}[theo]{Definition}
\newenvironment{definition}[1][]
{\begin{defi}[#1]\begin{leftbar}}
{\end{leftbar}\end{defi}}
\newtheorem{remk}[theo]{Remark}
\newenvironment{remark}[1][]
{\begin{remk}[#1]\begin{leftbar}}
{\end{leftbar}\end{remk}}
\newtheorem{coro}[theo]{Corollary}
\newenvironment{corollary}[1][]
{\begin{coro}[#1]\begin{leftbar}}
{\end{leftbar}\end{coro}}
\newtheorem{conv}[theo]{Convention}
\newenvironment{condition}[1][]
{\begin{conv}[#1]\begin{leftbar}}
{\end{leftbar}\end{conv}}
\newtheorem{quest}[theo]{Question}
\newenvironment{algorithm}[1][]
{\begin{quest}[#1]\begin{leftbar}}
{\end{leftbar}\end{quest}}
\newtheorem{warn}[theo]{Warning}
\newenvironment{conclusion}[1][]
{\begin{warn}[#1]\begin{leftbar}}
{\end{leftbar}\end{warn}}
\newtheorem{conj}[theo]{Conjecture}
\newenvironment{conjecture}[1][]
{\begin{conj}[#1]\begin{leftbar}}
{\end{leftbar}\end{conj}}
\newtheorem{exam}[theo]{Example}
\newenvironment{example}[1][]
{\begin{exam}[#1]\begin{leftbar}}
{\end{leftbar}\end{exam}}
\newtheorem{exmp}[exer]{Exercise}
\newenvironment{exercise}[1][]
{\begin{exmp}[#1]\begin{leftbar}}
{\end{leftbar}\end{exmp}}
\newenvironment{statement}{\begin{quote}}{\end{quote}}
\iffalse
\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\fi
\let\sumnonlimits\sum
\let\prodnonlimits\prod
\let\cupnonlimits\bigcup
\let\capnonlimits\bigcap
\renewcommand{\sum}{\sumnonlimits\limits}
\renewcommand{\prod}{\prodnonlimits\limits}
\renewcommand{\bigcup}{\cupnonlimits\limits}
\renewcommand{\bigcap}{\capnonlimits\limits}
\setlength\tablinesep{3pt}
\setlength\arraylinesep{3pt}
\setlength\extrarulesep{3pt}
\voffset=0cm
\hoffset=-0.7cm
\setlength\textheight{22.5cm}
\setlength\textwidth{15.5cm}
\newenvironment{verlong}{}{}
\newenvironment{vershort}{}{}
\newenvironment{noncompile}{}{}
\excludecomment{verlong}
\includecomment{vershort}
\excludecomment{noncompile}
\newcommand{\id}{\operatorname{id}}
\newcommand{\rev}{\operatorname{rev}}
\newcommand{\conncomp}{\operatorname{conncomp}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\powset}[2][]{\ifthenelse{\equal{#2}{}}{\mathcal{P}\left(#1\right)}{\mathcal{P}_{#1}\left(#2\right)}}
% $\powset[k]{S}$ stands for the set of all $k$-element subsets of
% $S$. The argument $k$ is optional, and if not provided, the result
% is the whole powerset of $S$.
\newcommand{\set}[1]{\left\{ #1 \right\}}
% $\set{...}$ yields $\left\{ ... \right\}$.
\newcommand{\abs}[1]{\left| #1 \right|}
% $\abs{...}$ yields $\left| ... \right|$.
\newcommand{\tup}[1]{\left( #1 \right)}
% $\tup{...}$ yields $\left( ... \right)$.
\newcommand{\ive}[1]{\left[ #1 \right]}
% $\ive{...}$ yields $\left[ ... \right]$.
\newcommand{\verts}[1]{\operatorname{V}\left( #1 \right)}
% $\verts{...}$ yields $\operatorname{V}\left( ... \right)$.
\newcommand{\edges}[1]{\operatorname{E}\left( #1 \right)}
% $\edges{...}$ yields $\operatorname{E}\left( ... \right)$.
\newcommand{\arcs}[1]{\operatorname{A}\left( #1 \right)}
% $\arcs{...}$ yields $\operatorname{A}\left( ... \right)$.
\newcommand{\underbrack}[2]{\underbrace{#1}_{\substack{#2}}}
% $\underbrack{...1}{...2}$ yields
% $\underbrace{...1}_{\substack{...2}}$. This is useful for doing
% local rewriting transformations on mathematical expressions with
% justifications.
\ihead{Math 5707 Spring 2017 (Darij Grinberg): homework set 2}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\begin{center}
\textbf{Math 5707 Spring 2017 (Darij Grinberg): homework set 2}
\textbf{Solution sketches.}
\end{center}
\tableofcontents
\subsection{Notations and conventions}
See the
\href{http://www.cip.ifi.lmu.de/~grinberg/t/17s/nogra.pdf}{lecture notes}
and also the
\href{http://www.cip.ifi.lmu.de/~grinberg/t/17s/}{handwritten notes}
for relevant material.
If you reference results from the lecture notes, please \textbf{mention the date and time} of the version of the notes you are using (as the numbering changes during updates).
Let me recall a few notations:
\begin{itemize}
\item A \textit{simple graph} is a pair $\tup{V, E}$, where $V$ is a
finite set and where $E$ is a subset of $\powset[2]{V}$.
The set $V$ is called the \textit{vertex set} of the simple
graph (and the elements of $V$ are called the \textit{vertices}
of the simple graph),
whereas the set $E$ is called the \textit{edge set} of the
simple graph (and the elements of $E$ are called the
\textit{edges} of the simple graph).
\item A \textit{multigraph} is a triple $\tup{V, E, \phi}$, where $V$
and $E$ are finite sets and where $\phi$ is a map from $E$ to
$\powset[2]{V}$. The set $V$ is called the \textit{vertex set}
of the multigraph (and the elements of $V$ are called the
\textit{vertices} of the multigraph); the set $E$ is called the
\textit{edge set} of the multigraph (and the elements of $E$ are
called the \textit{edges} of the multigraph); the map $\phi$ is
called the \textit{endpoint map} of the multigraph. If $e$ is an
edge of the multigraph, then the two elements of $\phi\tup{e}$
are called the \textit{endpoints} of $e$.
\item A \textit{digraph} is a pair $\tup{V, A}$, where $V$ is a
finite set and where $A$ is a subset of $V \times V$. The set
$V$ is called the \textit{vertex set} of the digraph (and the
elements of $V$ are called the \textit{vertices} of the
digraph); the set $A$ is called the \textit{arc set} of the
digraph (and the elements of $A$ are called the \textit{arcs}
of the digraph). If $\tup{v, w}$ is an arc of the digraph, then
$v$ is called the \textit{source} of this arc, and $w$ is called
the \textit{target} of this arc. If the source of an arc equals
its target, then this arc is said to be a \textit{loop}.
\item A \textit{multidigraph} is a triple $\tup{V, A, \phi}$, where
$V$ and $A$ are finite sets and where $\phi$ is a map from $A$
to $V \times V$. The set $V$ is called the \textit{vertex set}
of the multidigraph (and the elements of $V$ are called the
\textit{vertices} of the multidigraph); the set $A$ is called
the \textit{arc set} of the multidigraph (and the elements of
$A$ are called the \textit{arcs} of the multidigraph). If $a$
is an arc of the multidigraph, and if
$\tup{v, w} = \phi\tup{a}$, then $v$ is called the
\textit{source} of this arc, and $w$ is called the
\textit{target} of this arc.
\item If $u$ and $v$ are two vertices of a simple graph $G$, then we
use the shorthand notation $uv$ for the set $\set{u, v}$ (even
if this set is not an arc of $G$, and even if it is not a
two-element set). If $u$ and $v$ are two vertices of a digraph
$G$, then we use the shorthand notation $uv$ for the pair
$\tup{u, v}$. We hope the two notations will not be confused.
\item A \textit{walk} in a simple graph $G$ (or in a digraph $G$) is
defined to be a list of the form $\tup{v_0, v_1, \ldots, v_k}$,
where $v_0, v_1, \ldots, v_k$ are vertices of $G$, and where
$v_i v_{i+1}$ is an edge of $G$ (or an arc of $G$, respectively)
for each $i \in \set{0, 1, \ldots, k-1}$. Here, the meaning of
$v_i v_{i+1}$ depends on whether $G$ is a simple graph or a
digraph (namely, it means a set in the former case,
and a pair in the latter). \\
A \textit{walk} in a multigraph $G$ is defined to be a list of
the form
$\tup{v_0, e_1, v_1, e_2, v_2, \ldots, e_k, v_k}$, where
$v_0, v_1, \ldots, v_k$ are vertices of $G$, and where $e_i$ is
an edge of $G$ having endpoints $v_{i-1}$ and $v_i$ for each
$i \in \set{1, 2, \ldots, k}$. \\
A \textit{walk} in a multidigraph $G$ is defined to be a list of
the form $\tup{v_0, a_1, v_1, a_2, v_2, \ldots, a_k, v_k}$,
where $v_0, v_1, \ldots, v_k$ are vertices of $G$, and where
$a_i$ is an arc of $G$ having source $v_{i-1}$ and target $v_i$
for each $i \in \set{1, 2, \ldots, k}$. \\
In each of these cases, the \textit{vertices} of the walk are
defined to be $v_0, v_1, \ldots, v_k$. Moreover, $v_0$ is called
the \textit{starting point} of the walk, and $v_k$ is called the
\textit{ending point} of the walk. The \textit{edges} of the
walk are defined to be $v_0 v_1, v_1 v_2, \ldots, v_{k-1} v_k$
(if $G$ is a simple graph) or
$e_1, e_2, \ldots, e_k$ (if $G$ is a multigraph). The
\textit{arcs} of the walk are defined to be
$v_0 v_1, v_1 v_2, \ldots, v_{k-1} v_k$
(if $G$ is a digraph) or
$a_1, a_2, \ldots, a_k$ (if $G$ is a multidigraph).
\item A \textit{path} in a simple graph $G$ (or in a digraph $G$, or
in a multigraph $G$, or in a multidigraph $G$) means a walk in
$G$ such that the vertices of the walk are distinct.
\item A \textit{circuit} in a simple graph $G$ (or in a digraph $G$,
or in a multigraph $G$, or in a multidigraph $G$) means a walk
in $G$ such that the starting point of the walk equals the
ending point of the walk. \\
If $v_0, v_1, \ldots, v_k$ are the vertices of a circuit
$\mathbf{c}$, then $v_0, v_1, \ldots, v_{k-1}$ are called the
\textit{non-ultimate vertices} of $\mathbf{c}$.
\item A \textit{cycle} in a simple graph $G$ means a circuit
$\tup{v_0, v_1, \ldots, v_k}$ in $G$ such that the vertices
$v_0, v_1, \ldots, v_{k-1}$ are distinct and such that
$k \geq 3$. \\
A \textit{cycle} in a digraph $G$ means a circuit
$\tup{v_0, v_1, \ldots, v_k}$ in $G$ such that the vertices
$v_0, v_1, \ldots, v_{k-1}$ are distinct and such that
$k \geq 1$. (In particular, each loop $\tup{v, v}$ gives rise to
a cycle.) \\
A \textit{cycle} in a multigraph $G$ means a circuit
$\tup{v_0, e_1, v_1, e_2, v_2, \ldots, e_k, v_k}$ such that the
vertices $v_0, v_1, \ldots, v_{k-1}$ are distinct, the edges
$e_1, e_2, \ldots, e_k$ are also distinct, and such that
$k \geq 2$. \\
A \textit{cycle} in a multidigraph $G$ means a circuit
$\tup{v_0, a_1, v_1, a_2, v_2, \ldots, a_k, v_k}$ in $G$ such
that the vertices $v_0, v_1, \ldots, v_{k-1}$ are distinct and
such that $k \geq 1$.
\item A simple graph $G$ (or multigraph $G$, or digraph $G$, or
multidigraph $G$) is said to be \textit{strongly connected} if
its vertex set is nonempty\footnote{Do not forget this
requirement!} and it has the property that for any two vertices
$u$ and $v$ of $G$, there exists at least one walk from $u$ to
$v$ in $G$. (Note that if there exists a walk from $u$ to $v$ in
$G$, then there also exists a path from $u$ to $v$ in $G$.)
\par
When $G$ is a simple graph or a multigraph, we usually say
``$G$ is connected'' instead of ``$G$ is strongly connected''.
\item A \textit{Hamiltonian path} in a simple graph $G$ (or multigraph
$G$, or digraph $G$, or multidigraph $G$) means a path
$\mathbf{p}$ in $G$ such that each vertex of $G$ appears
exactly once among the vertices of $\mathbf{p}$.
\item A \textit{Hamiltonian cycle} in a simple graph $G$ (or
multigraph $G$, or digraph $G$, or multidigraph $G$) means a
cycle $\mathbf{c}$ of $G$ such that each vertex of $G$ appears
exactly once among the non-ultimate vertices of $\mathbf{c}$.
\item A walk $\mathbf{w}$ in a simple graph $G$ (or multigraph $G$) is
said to be \textit{Eulerian} if each edge of $G$ appears exactly
once among the edges of $\mathbf{w}$. \\
A walk $\mathbf{w}$ in a digraph $G$ (or multidigraph $G$) is
said to be \textit{Eulerian} if each arc of $G$ appears exactly
once among the arcs of $\mathbf{w}$. \\
Notice that this automatically defines the notion of an Eulerian
circuit (namely, an Eulerian circuit is just a circuit that is
Eulerian).
\end{itemize}
\subsection{Exercise \ref{exe.hw2.hamilGxH}: Hamiltonian paths in
Cartesian product graphs}
\begin{exercise} \label{exe.hw2.hamilGxH}
Let $G$ and $H$ be two simple graphs. The \textit{Cartesian product} of $G$
and $H$ is a new simple graph, denoted $G \times H$, which is defined as
follows:
\begin{itemize}
\item The vertex set $\verts{G \times H}$ of $G \times H$ is the
Cartesian product $\verts{G} \times \verts{H}$.
\item A vertex $\tup{g, h}$ of $G \times H$ is adjacent to a vertex
$\tup{g', h'}$ of $G \times H$ if and only if we have
\begin{itemize}
\item \textbf{either} $g = g'$ and $hh' \in \edges{H}$,
\item \textbf{or} $h = h'$ and $gg' \in \edges{G}$.
\end{itemize}
(In particular, exactly one of the two equalities $g = g'$ and $h = h'$
has to hold when $\tup{g, h}$ is adjacent to $\tup{g', h'}$.)
\end{itemize}
\textbf{(a)} Recall the $n$-dimensional cube graph $Q_n$ defined for
each $n \in \NN$. (Its vertices are $n$-tuples $\tup{a_1, a_2, \ldots,
a_n} \in \set{0, 1}^n$, and two such vertices are adjacent if and only
if they differ in exactly one entry.) Prove that $Q_n \cong
Q_{n-1} \times Q_1$ for each positive integer $n$. (Thus, $Q_n$ can
be obtained from $Q_1$ by repeatedly forming Cartesian products; i.e.,
it is a ``Cartesian power'' of $Q_1$.)
\textbf{(b)} Assume that each of the graphs $G$ and $H$ has a
Hamiltonian path. Prove that $G \times H$ has a Hamiltonian path.
\textbf{(c)} Assume that both numbers $\abs{\verts{G}}$ and
$\abs{\verts{H}}$ are $> 1$, and that at least one of them is even.
Assume again that each of the graphs $G$ and $H$ has a Hamiltonian
path. Prove that $G \times H$ has a Hamiltonian cycle.
\end{exercise}
\begin{proof}[Solution sketch to Exercise~\ref{exe.hw2.hamilGxH}.]
\textbf{(a)} It suffices to check that the map
\[
\set{0, 1}^n \to \set{0, 1}^{n-1} \times \set{0, 1}, \qquad
\tup{a_1, a_2, \ldots, a_n}
\mapsto \tup{ \tup{a_1, a_2, \ldots, a_{n-1}}, a_n}
\]
is a graph isomorphism from $Q_n$ to $Q_{n-1} \times Q_1$. The proof
of this is straightforward; the main step is to check that two
$n$-tuples
$\tup{a_1, a_2, \ldots, a_n}$ and $\tup{b_1, b_2, \ldots, b_n}$ in
$\set{0, 1}^n$ differ in exactly one entry (i.e., are adjacent as
vertices of $Q_n$) if and only if
\begin{itemize}
\item \textbf{either} we have
$\tup{a_1, a_2, \ldots, a_{n-1}} = \tup{b_1, b_2, \ldots, b_{n-1}}$
and $a_n \neq b_n$,
\item \textbf{or} the $\tup{n-1}$-tuples
$\tup{a_1, a_2, \ldots, a_{n-1}}$ and
$\tup{b_1, b_2, \ldots, b_{n-1}}$
differ in exactly one entry (i.e., are adjacent as vertices of
$Q_{n-1}$) and we have $a_n = b_n$.
\end{itemize}
This is obvious.
\textbf{(b)} By assumption, there exists a Hamiltonian path
$\tup{g_1, g_2, \ldots, g_n}$ of $G$, and there exists a Hamiltonian
path $\tup{h_1, h_2, \ldots, h_m}$ of $H$. Use these two paths to
construct the Hamiltonian path
\begin{align}
& \left(
\tup{g_1, h_1}, \tup{g_1, h_2}, \ldots, \tup{g_1, h_m}, \right. \nonumber \\
& \left. \ \tup{g_2, h_m}, \tup{g_2, h_{m-1}}, \ldots, \tup{g_2, h_1}, \right. \nonumber \\
& \left. \ \tup{g_3, h_1}, \tup{g_3, h_2}, \ldots, \tup{g_3, h_m}, \right. \nonumber \\
& \left. \ \tup{g_4, h_m}, \tup{g_4, h_{m-1}}, \ldots, \tup{g_4, h_1}, \right. \nonumber \\
& \left. \ \cdots \right)
\label{sol.hw2.hamilGxH.1}
\end{align}
in $G \times H$. (This Hamiltonian path first traverses all vertices
of the form $\tup{g_1, h_i}$ in the order of increasing $i$, then
traverses all vertices of the form $\tup{g_2, h_i}$ in the order of
decreasing $i$, then traverses all vertices of the form
$\tup{g_3, h_i}$ in the order of increasing $i$, and so on, always
alternating between increasing and decreasing $i$. It ends at the
vertex $\tup{g_n, h_m}$ if $n$ is odd, and at the vertex
$\tup{g_n, h_1}$ if $n$ is even. Here is how it looks like:
\[
\xymatrix{
\tup{g_1, h_1} \ar[r] & \tup{g_1, h_2} \ar[r] & \cdots \ar[r] & \tup{g_1, h_m} \ar[d] \\
\tup{g_2, h_1} \ar[d] & \tup{g_2, h_2} \ar[l] & \cdots \ar[l] & \tup{g_2, h_m} \ar[l] \\
\tup{g_3, h_1} \ar[r] & \tup{g_3, h_2} \ar[r] & \cdots \ar[r] & \tup{g_3, h_m} \ar[d] \\
\tup{g_4, h_1} \ar[d] & \tup{g_4, h_2} \ar[l] & \cdots \ar[l] & \tup{g_4, h_m} \ar[l] \\
\vdots
}
\]
where the arrows merely signify the order in which the vertices are
traversed by the path (the edges are still undirected).)
\textbf{(c)} At least one of the integers $\abs{\verts{G}}$ and
$\abs{\verts{H}}$ is even.
Since
$G \times H \cong H \times G$ (in fact, there is a graph isomorphism
$G \times H \to H \times G$ sending each vertex $\tup{v, w}$ of
$G \times H$ to $\tup{w, v}$), we can WLOG assume that
$\abs{\verts{G}}$ is even (because otherwise we can simply switch
$G$ with $H$).
Assume this, and recall furthermore that $\abs{\verts{H}} > 1$.
By assumption, there exists a Hamiltonian path
$\tup{g_1, g_2, \ldots, g_n}$ of $G$, and there exists a Hamiltonian
path $\tup{h_0, h_1, \ldots, h_m}$ of $H$. (Note that I am indexing
the vertices of the former path from $1$, but indexing the vertices
of the latter path from $0$.) Thus, $n = \abs{\verts{G}}$ is even.
Also, $n = \abs{\verts{G}} > 1$.
Also, $m + 1 = \abs{\verts{H}} > 1$, so that $m > 0$.
Now, consider the path \eqref{sol.hw2.hamilGxH.1}. It is not a
Hamiltonian path, since it misses the vertices of the form
$\tup{g_i, h_0}$. But it is a path from $\tup{g_1, h_1}$ to
$\tup{g_n, h_1}$ (since $n$ is even) that uses each vertex
\textbf{not} of this form exactly once; thus, we can extend it to
a Hamiltonian cycle of $G \times H$ by appending the following
vertices at its end:
\[
\tup{g_n, h_0}, \tup{g_{n-1}, h_0}, \ldots, \tup{g_1, h_0},
\tup{g_1, h_1}.
\]
(In other words, we close the path by going back to its starting
point along the missing vertices $\tup{g_i, h_0}$.) Hence, we have
found a Hamiltonian cycle of $G \times H$.
(Here is how this Hamiltonian cycle looks like:
\[
\xymatrix{
\tup{g_1, h_0} \ar[r] & \tup{g_1, h_1} \ar[r] & \tup{g_1, h_2} \ar[r] & \cdots \ar[r] & \tup{g_1, h_m} \ar[d] \\
\tup{g_2, h_0} \ar[u] & \tup{g_2, h_1} \ar[d] & \tup{g_2, h_2} \ar[l] & \cdots \ar[l] & \tup{g_2, h_m} \ar[l] \\
\tup{g_3, h_0} \ar[u] & \tup{g_3, h_1} \ar[r] & \tup{g_3, h_2} \ar[r] & \cdots \ar[r] & \tup{g_3, h_m} \ar[d] \\
\tup{g_4, h_0} \ar[u] & \tup{g_4, h_1} \ar[d] & \tup{g_4, h_2} \ar[l] & \cdots \ar[l] & \tup{g_4, h_m} \ar[l] \\
\vdots \ar[u] & \vdots \ar[d] \\
\tup{g_{n-1}, h_0} \ar[u] & \tup{g_{n-1}, h_1} \ar[r] & \tup{g_{n-1}, h_2} \ar[r] & \cdots \ar[r] & \tup{g_{n-1}, h_m} \ar[d] \\
\tup{g_n, h_0} \ar[u] & \tup{g_n, h_1} \ar[l] & \tup{g_n, h_2} \ar[l] & \cdots \ar[l] & \tup{g_n, h_m} \ar[l]
}
\]
where the arrows merely signify the order in which the vertices are
traversed by the cycle (the edges are still undirected).)
\end{proof}
\subsection{Exercise~\ref{exe.eulertrails.Kn}: Eulerian circuits in
$K_3$, $K_5$ and $K_7$}
\begin{exercise} \label{exe.eulertrails.Kn}
Let $n$ be a positive integer. Recall that $K_n$ denotes the complete
graph on $n$ vertices. This is the graph with vertex set $V =
\set{1, 2, \ldots, n}$ and edge set $\mathcal{P}_2\tup{V}$ (so each two
distinct vertices are connected).
Find Eulerian circuits for the graphs $K_3$, $K_5$, and $K_7$.
\end{exercise}
\begin{proof}[Solution sketch to Exercise~\ref{exe.eulertrails.Kn}.]
An Eulerian circuit of $K_3$ is $\tup{1, 2, 3, 1}$.
An Eulerian circuit of $K_5$ is
$\tup{1, 2, 3, 4, 5, 1, 3, 5, 2, 4, 1}$.
An Eulerian circuit of $K_7$ is
$\tup{1, 2, 3, 4, 5, 6, 7,
1, 3, 5, 7, 2, 4, 6,
1, 4, 7, 3, 6, 2, 5,
1}$.
[\textit{Remark:} Of course, other choices are possible. For each
odd positive integer $n$, the complete graph $K_n$ has an Eulerian
circuit (because it is connected, and each of its vertices has even
degree $n-1$), and so it has at least one Eulerian circuit; but in
truth, there are many. (How many? See
\href{http://oeis.org/A007082}{OEIS entry A007082}. There doesn't seem
to be an explicit formula.)
When $n$ is an odd prime\footnote{Everyone gets confused by the notion
of an ``odd prime'' at least once in their life. But it means exactly
what it says: a prime that is odd. In other words, a prime that is
distinct from $2$.}, there is actually a simple way to construct
an Eulerian circuit in $K_n$: For each $k \in \set{1, 2, \ldots,
\tup{n-1}/2}$, let $c_k$ be the cycle $\tup{a_0, a_1, \ldots, a_n}$,
where $a_i$ denotes the unique element of $\tup{1, 2, \ldots, n}$ that
is congruent to $ki + 1$ modulo $n$. Then, the cycles $c_1, c_2,
\ldots, c_{\tup{n-1}/2}$ can be combined to a single Eulerian circuit.
Finding Eulerian circuits on $K_n$ for non-prime $n$ is harder, but
of course the algorithm done in class still works.]
\end{proof}
\subsection{Exercise~\ref{exe.debruijn.1}: de Bruijn sequences exist}
\begin{exercise} \label{exe.debruijn.1}
Let $n$ be a positive integer, and $K$ be a nonempty finite set.
Let $k = \abs{K}$.
A \textit{de Bruijn sequence} of order $n$ on $K$ means a list
$\tup{c_0, c_1, \ldots, c_{k^n-1}}$ of $k^n$ elements of $K$
such that
\begin{enumerate}
\item[(1)] for each
$n$-tuple $\tup{a_1, a_2, \ldots, a_n} \in K^n$ of elements of $K$,
there exists a \textbf{unique} $r \in \set{0, 1, \ldots, k^n-1}$ such
that
$\tup{a_1, a_2, \ldots, a_n} = \tup{c_r, c_{r+1}, \ldots, c_{r+n-1}}$.
\end{enumerate}
Here, the indices are understood to be cyclic modulo $k^n$; that is,
$c_q$ (for $q \geq k^n$) is defined to be $c_{q \% k^n}$, where
$q \% k^n$ denotes the remainder of $q$ modulo $k^n$.
(Note that the condition (1) can be restated as follows: If we
write the elements $c_0, c_1, \ldots, c_{k^n-1}$ on a circular
necklace (in this order), so that the last element $c_{k^n-1}$ is
followed by the first one, then each $n$-tuple of elements of $K$
appears as a string of $n$ consecutive elements on the necklace, and
the position at which it appears on the necklace is unique.)
For example, $\tup{c_0, c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8}
= \tup{1, 1, 2, 2, 3, 3, 1, 3, 2}$ is a de Bruijn sequence
of order $2$ on the set $\set{1, 2, 3}$, because for each $2$-tuple
$\tup{a_1, a_2} \in \set{1, 2, 3}^2$, there exists a unique $r \in \set{0, 1,
\ldots, 8}$ such that $\tup{a_1, a_2} = \tup{c_r, c_{r+1}}$. Namely:
\begin{align*}
\tup{1, 1} = \tup{c_0, c_1}; \qquad
\tup{1, 2} = \tup{c_1, c_2}; \qquad
\tup{1, 3} = \tup{c_6, c_7}; \\
\tup{2, 1} = \tup{c_8, c_9}; \qquad
\tup{2, 2} = \tup{c_2, c_3}; \qquad
\tup{2, 3} = \tup{c_3, c_4}; \\
\tup{3, 1} = \tup{c_5, c_6}; \qquad
\tup{3, 2} = \tup{c_7, c_8}; \qquad
\tup{3, 3} = \tup{c_4, c_5}.
\end{align*}
Prove that there exists a de Bruijn sequence of order $n$ on $K$
(no matter what $n$ and $K$ are).
\textbf{Hint:} Let $D$ be the digraph with vertex set $K^{n-1}$ and
an arc from $\tup{a_1, a_2, \ldots, a_{n-1}}$ to
$\tup{a_2, a_3, \ldots, a_n}$ for each
$\tup{a_1, a_2, \ldots, a_n} \in K^n$ (and no other arcs). Prove that
$D$ has an Eulerian circuit.
\end{exercise}
\begin{proof}[Solution sketch to Exercise \ref{exe.debruijn.1}.]
The hint suggests defining a digraph. I shall use a multidigraph
instead, as this is slightly simpler and cleaner.
Recall that a \textit{multidigraph} means a triple
$\tup{V, A, \phi}$, where $V$ and $A$ are two finite sets and where
$\phi$ is a map from $A$ to $V \times V$. We define a multidigraph
$D$ to be $\tup{K^{n-1}, K^n, f}$, where the map
$f : K^n \to K^{n-1} \times K^{n-1}$ is given by the formula
\[
f\tup{a_1, a_2, \ldots, a_n}
= \tup{ \tup{a_1, a_2, \ldots, a_{n-1}},
\tup{a_2, a_3, \ldots, a_n} }.
\]
(As usual, we write $f\tup{a_1, a_2, \ldots, a_n}$ for
$f\tup{\tup{a_1, a_2, \ldots, a_n}}$, since the extra parentheses do
not add any clarity.) Thus, in the multidigraph $D$, there is an arc
from $\tup{a_1, a_2, \ldots, a_{n-1}}$ to
$\tup{a_2, a_3, \ldots, a_n}$ for each
$\tup{a_1, a_2, \ldots, a_n} \in K^n$. (Note that if $n = 1$, then
there is only one vertex, namely the empty $0$-tuple $\tup{}$, but
there are $\abs{K}$ many arcs from it to itself. This is why we are
using a multidigraph instead of a digraph. Of course, you are free to
throw the $n = 1$ case aside, seeing how easy it is to handle
separately.)
Recall that the \textit{indegree} of a vertex $v$ of a multidigraph
$\tup{V, A, \phi}$ is defined to be the number of all arcs $a \in A$
whose target is $v$ (that is, which satisfy $\phi\tup{a} = \tup{x, v}$
for some $x \in V$). This indegree is denoted by $\deg^- v$.
Also, the \textit{outdegree} of a vertex $v$ of a multidigraph
$\tup{V, A, \phi}$ is defined to be the number of all arcs $a \in A$
whose source is $v$ (that is, which satisfy $\phi\tup{a} = \tup{v, x}$
for some $x \in V$). This outdegree is denoted by $\deg^+ v$.
Recall that a multidigraph $\tup{V, A, \phi}$ is said to be
\textit{strongly connected} if $V \neq \varnothing$ and if, for any
$u \in V$ and $v \in V$, there is at least one walk from $u$ to $v$
in the multidigraph.
The multidigraph $D$ is strongly connected\footnote{\textit{Proof.}
Let $u \in K^{n-1}$ and $v \in K^{n-1}$. We must prove that there is
at least one walk from $u$ to $v$ in $D$. Write the $\tup{n-1}$-tuples
$u$ and $v$ as $u = \tup{u_1, u_2, \ldots, u_{n-1}}$ and
$v = \tup{v_1, v_2, \ldots, v_{n-1}}$, respectively.
Then, the walk
\begin{align*}
& \left( \tup{u_1, u_2, u_3, u_4, \ldots, u_{n-1}} , \tup{u_1, u_2, u_3, u_4, \ldots, u_{n-1}, v_1} , \right. \\
& \left. \phantom{u_1, } \tup{u_2, u_3, u_4, \ldots, u_{n-1}, v_1} , \tup{u_2, u_3, u_4, \ldots, u_{n-1}, v_1, v_2} , \right. \\
& \left. \phantom{u_1, u_2, } \tup{u_3, u_4, \ldots, u_{n-1}, v_1, v_2} , \tup{u_3, u_4, \ldots, u_{n-1}, v_1, v_2, v_3} , \right. \\
& \left. \phantom{u_1, u_2, u_3, } \cdots , \right. \\
& \left. \phantom{u_1, u_2, u_3, u_4, \ldots, } \tup{u_{n-1}, v_1, v_2, \ldots, v_{n-2}} , \tup{u_{n-1}, v_1, v_2, \ldots, v_{n-2}, v_{n-1}} , \right. \\
& \left. \phantom{u_1, u_2, u_3, u_4, \ldots, u_{n-1}, } \tup{v_1, v_2, \ldots, v_{n-2}, v_{n-1}} \right)
\end{align*}
is a walk from $u$ to $v$ in $D$. Hence, such a walk exists.}.
Moreover, each vertex $v \in K^{n-1}$ satisfies
$\deg^- v = \deg^+ v$ (where both indegree and outdegree are taken
respective to the multidigraph $D$)\ \ \ \ \footnote{\textit{Proof.}
Let $v \in K^{n-1}$. Write the $\tup{n-1}$-tuple $v$ in the form
$v = \tup{v_1, v_2, \ldots, v_{n-1}}$.
Now, $\deg^- v$ is the number of arcs of $D$
with target $v$. But these arcs are exactly the $n$-tuples of the
form $\tup{k, v_1, v_2, \ldots, v_{n-1}} \in K^n$ with $k \in K$
(by the definition of the multidigraph $D$). Hence, there are
exactly $\abs{K}$ of them. Therefore, $\deg^- v = \abs{K}$ (since
$\deg^- v$ is the number of these arcs). Similarly,
$\deg^+ v = \abs{K}$. Thus, $\deg^- v = \abs{K} = \deg^+ v$.}.
Recall that a multidigraph has an Eulerian circuit if and only if it
is strongly connected and each vertex $v$ satisfies
$\deg^- v = \deg^+ v$. Hence, the multidigraph $D$ has an Eulerian
circuit (since it is strongly connected and each vertex $v$ satisfies
$\deg^- v = \deg^+ v$). Consider such an Eulerian circuit
$\mathbf{c}$. It contains
each arc of $D$ exactly once, and thus has $k^n$ arcs (since
the number of arcs of $D$ is $\abs{K^n} = \abs{K}^n = k^n$).
Let $p_0, p_1, \ldots, p_{k^n-1}$ be these arcs (listed in the order
in which they appear on the Eulerian circuit). We extend the
indexing of these arcs modulo $k^n$; in other words, we set
$p_i = p_{i \% k^n}$ for each $i \in \ZZ$. (This, of course, does not
conflict with the already introduced notations
$p_0, p_1, \ldots, p_{k^n-1}$, since each
$i \in \set{0, 1, \ldots, k^n-1}$ satisfies $i \% k^n = i$.)
Let me now explain what I intend to do before I go into the
technical details. We want to construct a de Bruijn sequence
$\tup{c_0, c_1, \ldots, c_{k^n-1}}$. I claim that the sequence
of the first entries of the $n$-tuples $p_0, p_1, \ldots, p_{k^n-1}$
is such a de Bruijn sequence. Once this is proven, the exercise
will clearly be solved.
For each $n$-tuple $h$ and each $j \in \set{1, 2, \ldots, n}$,
we will denote the $j$-th entry of $h$ by $h\ive{j}$. So each
$n$-tuple $h$ has the form
$h = \tup{h\ive{1}, h\ive{2}, \ldots, h\ive{n}}$.
Now, I claim that
\begin{equation}
p_i\ive{j+1} = p_{i+1}\ive{j}
\qquad \text{ for each } i \in \ZZ
\text{ and } j \in \set{1, 2, \ldots, n-1}
\label{pf.debruijn.1.rec.one-step}
\end{equation}
\footnote{\textit{Proof of \eqref{pf.debruijn.1.rec.one-step}.}
Let $i \in \ZZ$. The arc $p_{i+1}$ immediately follows the arc
$p_i$ on the Eulerian circuit $\mathbf{c}$. Hence, the target of
the arc $p_i$ is the source of the arc $p_{i+1}$. But by the
definition of the multidigraph $D$, the former target is
$\tup{p_i\ive{2}, p_i\ive{3}, \ldots, p_i\ive{n}}$, whereas the
latter source is
$\tup{p_{i+1}\ive{1}, p_{i+1}\ive{2}, \ldots, p_{i+1}\ive{n-1}}$.
Hence, we have shown that
$\tup{p_i\ive{2}, p_i\ive{3}, \ldots, p_i\ive{n}}
= \tup{p_{i+1}\ive{1}, p_{i+1}\ive{2}, \ldots, p_{i+1}\ive{n-1}}$.
In other words, $p_i\ive{j+1} = p_{i+1}\ive{j}$ for each
$j \in \set{1, 2, \ldots, n-1}$. This proves
\eqref{pf.debruijn.1.rec.one-step}.}. Hence,
\begin{equation}
p_i\ive{j+g} = p_{i+g}\ive{j}
\qquad \text{ for each } i \in \ZZ \text{ and } g \in \NN
\text{ and } j \in \set{1, 2, \ldots, n-g}
\label{pf.debruijn.1.rec.g-steps}
\end{equation}
\footnote{Indeed, \eqref{pf.debruijn.1.rec.g-steps} can easily
be proven by induction on $g$, using
\eqref{pf.debruijn.1.rec.one-step} in the induction step.}.
From this, we can easily obtain
\begin{equation}
\tup{p_i\ive{1}, p_{i+1}\ive{1}, \ldots, p_{i+n-1}\ive{1}}
= p_i
\qquad \text{ for each } i \in \ZZ
\label{pf.debruijn.1.=pi}
\end{equation}
\footnote{\textit{Proof.} Let $i \in \ZZ$. Then,
\eqref{pf.debruijn.1.rec.g-steps} (applied to $j=1$) shows that
$p_i\ive{1+g} = p_{i+g}\ive{1}$ for each
$g \in \set{0,1,\ldots,n-1}$. In other words,
$\tup{p_i\ive{1}, p_i\ive{2}, \ldots, p_i\ive{n}}
= \tup{p_i\ive{1}, p_{i+1}\ive{1}, \ldots, p_{i+n-1}\ive{1}}$.
Therefore,
$\tup{p_i\ive{1}, p_{i+1}\ive{1}, \ldots, p_{i+n-1}\ive{1}}
= \tup{p_i\ive{1}, p_i\ive{2}, \ldots, p_i\ive{n}}
= p_i$.}.
Now, recall that $p_0, p_1, \ldots, p_{k^n-1}$ are the arcs
of an Eulerian circuit of $D$. Hence, each arc of $D$ appears
exactly once in the list $\tup{p_0, p_1, \ldots, p_{k^n-1}}$.
In other words, for each arc $a$ of $D$, there exists a unique
$r \in \set{0, 1, \ldots, k^n-1}$ such that $a = p_i$.
Since the arcs of $D$ are the $n$-tuples in $K^n$, we can
rewrite this as follows: For each $n$-tuple $a \in K^n$,
there exists a unique
$r \in \set{0, 1, \ldots, k^n-1}$ such that $a = p_r$. Since
each $r \in \ZZ$ satisfies
$\tup{p_r\ive{1}, p_{r+1}\ive{1}, \ldots, p_{r+n-1}\ive{1}}
= p_r$ (by \eqref{pf.debruijn.1.=pi}, applied to $i=r$),
this further rewrites as follows:
For each $n$-tuple $a \in K^n$,
there exists a unique $r \in \set{0, 1, \ldots, k^n-1}$
such that
$a = \tup{p_r\ive{1}, p_{r+1}\ive{1}, \ldots, p_{r+n-1}\ive{1}}$.
Renaming $a$ as $\tup{a_1, a_2, \ldots, a_n}$ in this result,
we obtain the following:
For each
$n$-tuple $\tup{a_1, a_2, \ldots, a_n} \in K^n$ of elements of $K$,
there exists a unique $r \in \set{0, 1, \ldots, k^n-1}$ such
that
$\tup{a_1, a_2, \ldots, a_n}
= \tup{p_r\ive{1}, p_{r+1}\ive{1}, \ldots, p_{r+n-1}\ive{1}}$.
In other words, the list
$\tup{p_0\ive{1}, p_1\ive{1}, \ldots, p_{k^n-1}\ive{1}}$ is a
de Bruijn sequence of order $n$ on $K$ (because the indices are
cyclic modulo $k^n$, so the result in the previous sentence is
precisely what is required in the definition of a de Bruijn
sequence). Therefore, there exists a de Bruijn sequence of order
$n$ on $K$.
[\textit{Remark:} The underlying philosophy of this solution was
to reduce the question of the existence of a de Bruijn sequence
to the existence of an Eulerian circuit in a multidigraph. At a
first glance, this appears unexpected, since it seems more natural
to model a de Bruijn sequence by a Hamiltonian cycle (in a different
multidigraph) instead. However, there are few good criteria for the
existence of a Hamiltonian cycle, whereas the existence of an
Eulerian circuit is easy to check. This is why modelling
de Bruijn sequences by Eulerian circuits proves to be the more
useful approach.
This exercise is merely the starting point of a theory. For example,
it is generalized by the following theorem:
\begin{theorem} \label{sol.debruijn.1.gen}
Let $d$ and $m$ be two positive integers such that $d \mid m$ and
$d > 1$. Then, there exists a permutation
$\tup{x_1, x_2, \ldots, x_m}$ of the list $\tup{0, 1, \ldots, m-1}$
with the following property:
For each $i \in \set{1, 2, \ldots, m}$, we have
$x_{i+1} \equiv d x_i + r_i \mod m$ for some
$r_i \in \set{0, 1, \ldots, d-1}$. (Here, $x_{m+1}$ should be
understood as $x_1$.)
\end{theorem}
Why does Theorem~\ref{sol.debruijn.1.gen} generalize
Exercise~\ref{exe.debruijn.1}? Well, if $m = d^n$ is a power of $d$,
then we can identify
the integers $0, 1, \ldots, d-1$ with $n$-tuples of elements of
$\set{0, 1, \ldots, d-1}$ (by representing them in base $d$, including
just enough leading zeroes to ensure that they all have $n$ digits).
Thus, Theorem~\ref{sol.debruijn.1.gen} turns into
Exercise~\ref{exe.debruijn.1} in this
case. With some work, the solution of Exercise~\ref{exe.debruijn.1}
can be extended to a proof of Theorem~\ref{sol.debruijn.1.gen}.
(Some work is required to prove that the digraph is still strongly
connected.) Note that
\href{https://anhngq.files.wordpress.com/2010/07/imo-2002-shortlist.pdf}{IMO Shortlist 2002}
problem C6 is equivalent to the $d = 2$ particular case of
Theorem~\ref{sol.debruijn.1.gen}.
For more variations on the notion of a de Bruijn sequence, see
\cite{ChDiGr92}. There are several
questions left open in that paper, some of which are apparently still
unsolved.
On the other hand, we can also ask ourselves: How many de Bruijn
sequences of order $n$ exist for a given $n$ and $K$ ?
Interestingly, the answer is very explicit: The number of all
de Bruijn sequences of order $n$ is
\[
k!^{k^{n-1}} ,
\qquad \text{ where } k = \abs{K} .
\]
\footnote{Some authors treat two de Bruijn sequences as equal
if one of them is obtained from the other by cyclic rotation.
With that convention, the number has to be divided by $k^n$.}
This is proven in the case of $K = \set{0, 1}$ in
\cite[Corollary 10.11]{Stanley13}. The general case can be proven
along the same lines.]
\end{proof}
\subsection{Exercise~\ref{exe.digraph.indeg=outdeg}: Indegrees and
outdegrees in digraphs}
Recall that the \textit{indegree} of a vertex $v$ of a digraph
$D = \tup{V, A}$ is defined to be the number of all arcs $a \in A$
whose target is $v$. This indegree is denoted by
$\deg^-\tup{v}$ or by $\deg^-_D\tup{v}$ (whenever the graph $D$ is not
clear from the context).
Likewise, the \textit{outdegree} of a vertex $v$ of a digraph
$D = \tup{V, A}$ is defined to be the number of all arcs $a \in A$
whose source is $v$. This outdegree is denoted by
$\deg^+\tup{v}$ or by $\deg^+_D\tup{v}$ (whenever the graph $D$ is not
clear from the context).
\begin{exercise} \label{exe.digraph.indeg=outdeg}
Let $D$ be a digraph. Show that
$\sum_{v \in \verts{D}} \deg^-\tup{v}
= \sum_{v \in \verts{D}} \deg^+\tup{v}$.
\end{exercise}
\begin{proof}[Solution to Exercise~\ref{exe.digraph.indeg=outdeg}.]
Let us actually prove a somewhat more general fact:
\begin{statement}
\textit{Fact 1.} Let $\tup{V, A, \phi}$ be a
multidigraph.
%\footnote{See the solution to
%Exercise~\ref{exe.debruijn.1} above for the definition of
%a multidigraph, and for the definitions of indegrees and
%outdegrees of vertices of a multidigraph.}.
Then,
$\sum_{v \in V} \deg^- v = \sum_{v \in V} \deg^+ v$.
\end{statement}
Fact 1 generalizes Exercise~\ref{exe.digraph.indeg=outdeg},
because each digraph $D = \tup{V, A}$ gives rise to a
multidigraph $\tup{V, A, \id_A}$, and the indegrees and
the outdegrees of the vertices of the former digraph are
exactly the same as in the latter multidigraph. Hence,
proving Fact 1 will suffice.
\begin{proof}[Proof of Fact 1.] For each arc $a \in A$, let
$s \tup{a}$ denote the source of $a$, and let $t \tup{a}$ denote the
target of $a$. (Thus, each $a \in A$ satisfies
$\phi \tup{a} = \tup{ s \tup{a}, t \tup{a} }$.)
Now, let us count the number of arcs $a \in A$ of our multidigraph in
two different ways:
\begin{itemize}
\item Each arc $a \in A$ has a unique source $s \tup{a}$. Thus, we can
obtain the number $\abs{A}$ of all arcs $a \in A$ by computing,
for each $v \in V$, the number of all arcs $a \in A$ satisfying
$s \tup{a} = v$, and then adding up these
numbers over all $v \in V$. Thus, we obtain
\begin{equation}
\abs{A}
= \sum_{v \in V}
\underbrace{\left(\text{the number of all } a \in A
\text{ satisfying } s \tup{a} = v \right)}_{
\substack{= \deg^+ v \\
\text{(by the definition of the outdegree } \deg^+ v
\text{ of } v \text{})}}
= \sum_{v \in V} \deg^+ v .
\label{sol.digraph.indeg=outdeg.2}
\end{equation}
\item Each arc $a \in A$ has a unique target $t \tup{a}$. Thus, we can
obtain the number $\abs{A}$ of all arcs $a \in A$ by computing,
for each $v \in V$, the number of all arcs $a \in A$ satisfying
$t \tup{a} = v$, and then adding up these
numbers over all $v \in V$. Thus, we obtain
\begin{equation}
\abs{A}
= \sum_{v \in V}
\underbrace{\left(\text{the number of all } a \in A
\text{ satisfying } t \tup{a} = v \right)}_{
\substack{= \deg^- v \\
\text{(by the definition of the indegree } \deg^- v
\text{ of } v \text{})}}
= \sum_{v \in V} \deg^- v .
\label{sol.digraph.indeg=outdeg.1}
\end{equation}
\end{itemize}
Comparing \eqref{sol.digraph.indeg=outdeg.1} with
\eqref{sol.digraph.indeg=outdeg.2}, we obtain
$\sum_{v \in V} \deg^- v = \sum_{v \in V} \deg^+ v$.
This proves Fact 1.
\end{proof}
\end{proof}
\subsection{Exercise~\ref{exe.tourn.num3cycs}: Counting $3$-cycles in
tournaments}
The next few exercises are about \textit{tournaments}. A
\textit{tournament} is a loopless\footnote{A digraph $\tup{V, A}$ is
said to be \textit{loopless} if it has no loops. (A \textit{loop}
means an arc of the form $\tup{v, v}$ for some $v \in V$.)} digraph
$D = \tup{V, A}$ with the following
property: For any two distinct vertices $u \in V$ and $v \in V$,
\textbf{precisely} one of the two pairs $\tup{u, v}$ and $\tup{v, u}$
belongs to $A$. (In other words, any two distinct vertices are
connected by an arc in one direction, but not in both.)
A \textit{$3$-cycle}\footnote{Note that our
notions of $3$-cycles and of cycles are somewhat different in nature:
A $3$-cycle is a triple of distinct vertices, whereas a cycle of
length $k$ is a $\tup{k+1}$-tuple of vertices with its first and its
last entry being the same vertex. Thus, a $3$-cycle $\tup{u, v, w}$ is
not in itself a cycle, but rather corresponds to the cycle
$\tup{u, v, w, u}$. But, of course, the $3$-cycles are in bijection
with the cycles of length $3$; thus, the difference between these two
notions is merely notational.} in a tournament $D = \tup{V, A}$ means
a triple $\tup{u, v, w}$ of vertices in $V$ such that all three pairs
$\tup{u, v}$, $\tup{v, w}$ and $\tup{w, u}$ belong to $A$.
\begin{exercise} \label{exe.tourn.num3cycs}
Let $D = \tup{V, A}$ be a tournament.
Set $n = \abs{V}$ and $m = \sum_{v \in V} \dbinom{\deg^-\tup{v}}{2}$.
\textbf{(a)} Show that $m = \sum_{v \in V} \dbinom{\deg^+\tup{v}}{2}$.
\textbf{(b)} Show that the number of $3$-cycles in $D$ is
$3\tup{\dbinom{n}{3} - m}$.
\end{exercise}
\begin{proof}[Solution sketch to Exercise~\ref{exe.tourn.num3cycs}.]
Let us introduce some convenient notations for this exercise:
\begin{itemize}
\item A \textit{3-set} shall mean a $3$-element subset of $V$.
Clearly, the number of all 3-sets is $\dbinom{n}{3}$ (since
$\abs{V} = n$).
\item A 3-set $\set{u, v, w}$ is said to be \textit{cyclic} if its
elements in \textbf{some} order form a $3$-cycle (i.e., if one of the
triples $\tup{u, v, w}$, $\tup{u, w, v}$, $\tup{v, u, w}$,
$\tup{v, w, u}$, $\tup{w, u, v}$ and $\tup{w, v, u}$ is a $3$-cycle).
\item A 3-set $\set{u, v, w}$ is said to be \textit{acyclic} if it is
not cyclic.
\item We say that a 3-set $S$ is \textit{sourced} at a vertex
$u \in V$ if this vertex $u$ belongs to $S$ and if the arcs $uv$ and
$uw$ are in $A$, where $v$ and $w$ are the two vertices of $S$
distinct from $u$.
\item We say that a 3-set $S$ is \textit{targeted} at a vertex
$u \in V$ if this vertex $u$ belongs to $S$ and if the arcs $vu$ and
$wu$ are in $A$, where $v$ and $w$ are the two vertices of $S$
distinct from $u$.
\end{itemize}
\textbf{(a)} Let us count the number of all acyclic 3-sets in two
different ways.
First, we make a few observations:
\begin{statement}
\textit{Observation 1:} Let $u$, $v$ and $w$ be three distinct
vertices in $V$ such that the arcs $uv$ and $uw$ are in $A$.
Then, $\set{u, v, w}$ is an acyclic 3-set sourced at $u$.
\end{statement}
\begin{proof}[Proof of Observation 1.]
Trivial.
\end{proof}
\begin{statement}
\textit{Observation 2:} Let $u \in V$ be a vertex. Then, the number
of all acyclic 3-sets sourced at $u$ is $\dbinom{\deg^+ u}{2}$.
\end{statement}
\begin{proof}[Proof of Observation 2.]
First of all, we introduce one more notion:
An \textit{out-neighbor} of $u$ shall mean a vertex $x \in V$
such that the arc $ux$ is in $A$.
Clearly, the out-neighbors of $u$ are in bijection with the arcs of
$D$ whose source is $u$\ \ \ \ \footnote{\textit{Proof.} The two maps
\begin{align*}
\tup{\text{the set of all out-neighbors of } u}
&\to
\tup{\text{the set of all arcs of } D \text{ whose source is } u}, \\
x &\mapsto ux
\end{align*}
and
\begin{align*}
\tup{\text{the set of all arcs of } D \text{ whose source is } u}
&\to
\tup{\text{the set of all out-neighbors of } u}, \\
a &\mapsto \tup{\text{the target of } a}
\end{align*}
are mutually inverse (this can be checked in a straightforward
manner). Note that we are here relying on the fact that $D$ is a
digraph, not a multidigraph!}. Hence, the number of the former
out-neighbors equals the number of the latter arcs.
Since the number of the latter arcs
is $\deg^+ u$ (indeed, this is how $\deg^+ u$ was defined), we can
thus conclude that the number of the former out-neighbors is
$\deg^+ u$. In other words, the number of all out-neighbors of $u$
is $\deg^+ u$.
Observation 2 now easily follows: A 3-set is an acyclic 3-set sourced
at $u$ if and only if it consists of $u$ and two distinct
out-neighbors of $u$. Hence, choosing an acyclic 3-set sourced at $u$
is tantamount to choosing two distinct out-neighbors of $u$ (without
specifying the order\footnote{See the next footnote for a more
rigorous way to write up this argument.}).
But the latter can be done in exactly $\dbinom{\deg^+ u}{2}$
ways (since the number of all out-neighbors of $u$ is $\deg^+ u$).
Hence, the number of all acyclic 3-sets sourced at $u$ is
$\dbinom{\deg^+ u}{2}$.\ \ \ \ \footnote{Here is a more rigorous way
to present this argument:
Let $U$ be the set of all out-neighbors of $u$. Let $G$ be the set of
all acyclic 3-sets sourced at $u$. Then, the maps
\begin{align*}
G \to \powset[2]{U},
\qquad S \mapsto S \setminus \set{u}
\end{align*}
and
\begin{align*}
\powset[2]{U} \to G,
\qquad T \mapsto T \cup \set{u}
\end{align*}
are well-defined (this is easy to check: e.g., you have to apply
Observation 1, and you have to argue that
if $S$ is a 3-set sourced at $u$, then the two elements of
$S \setminus \set{u}$ are two distinct out-neighbors of $u$) and
mutually inverse (this is essentially obvious). Hence, they provide
bijections between $G$ and $\powset[2]{U}$. Thus,
$\abs{G} = \abs{\powset[2]{U}} = \dbinom{\abs{U}}{2}$ (since every
finite set $Q$ and each $k \in \NN$ satisfy
$\abs{\powset[k]{Q}} = \dbinom{\abs{Q}}{k}$). But $U$ is the set of
all out-neighbors of $u$, and thus has size $\abs{U} = \deg^+ u$
(since the number of all out-neighbors of $u$ is $\deg^+ u$). Hence,
$\abs{G} = \dbinom{\abs{U}}{2}$ rewrites as