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
|
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 620
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass book
\begin_preamble
\input defs
\end_preamble
\use_default_options true
\maintain_unincluded_children no
\language english
\language_package default
\inputencoding utf8
\fontencoding auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_roman_osf false
\font_sans_osf false
\font_typewriter_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\float_placement class
\float_alignment class
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\use_formatted_ref 0
\use_minted 0
\use_lineno 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tablestyle default
\tracking_changes false
\output_changes false
\change_bars false
\postpone_fragile_content false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\docbook_table_output 0
\docbook_mathml_prefix 1
\end_header
\begin_body
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
rexerc4[M20]
\end_layout
\end_inset
The concept of
\emph on
topological sorting
\emph default
can be defined for any finite directed graph
\begin_inset Formula $G$
\end_inset
as a linear arrangement of the vertices
\begin_inset Formula $V_{1}V_{2}\dots V_{n}$
\end_inset
such that
\begin_inset Formula $\text{init}(e)$
\end_inset
precedes
\begin_inset Formula $\text{fin}(e)$
\end_inset
in the ordering for all arcs
\begin_inset Formula $e$
\end_inset
of
\begin_inset Formula $G$
\end_inset
.
(See Section 2.2.3,
Figs.
6 and 7.) Not all finite directed graphs can be topologically sorted;
which ones can be?
(Use the terminology of this section to give the answer.)
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
answer
\end_layout
\end_inset
Only the ones with no directed cycles,
except possibly for cycles of length 1.
If
\begin_inset Formula $G$
\end_inset
has a cycle (of length 2 or more),
the nodes in the cycle cannot be topologically ordered;
otherwise the transitive closure of the edges of the graph is a partial ordering between the vertices,
so they can be topologically ordered.
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
rexerc7[M22]
\end_layout
\end_inset
True or false:
A directed graph satisfying properties (a) and (b) of the definition of oriented tree,
and having no oriented cycles,
is an oriented tree.
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
answer
\end_layout
\end_inset
True for finite graphs.
If there were cycles,
they would be oriented because no vertex is the initial vertex of two arcs,
and a graph with no cycles and exactly one edge less than the number of vertices is a free tree.
Then the way to orient the edges such that (a) and (b) follow is unique,
which can be proved by induction on the distance of a node to the root,
and we know that this way follows (c).
\end_layout
\begin_layout Standard
False for infinite graphs.
A graph whose vertices are
\begin_inset Formula $R,V_{1},V_{2},\dots,V_{n},\dots$
\end_inset
and whose edges are
\begin_inset Formula $V_{1}\to V_{2}\to V_{3}\to\dots$
\end_inset
follows (a) and (b) and has no cycles but it doesn't follow (c).
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
rexerc13[M24]
\end_layout
\end_inset
Prove that if
\begin_inset Formula $R$
\end_inset
is a root of a (possibly infinite) directed graph
\begin_inset Formula $G$
\end_inset
,
then
\begin_inset Formula $G$
\end_inset
contains an oriented subtree with the same vertices as
\begin_inset Formula $G$
\end_inset
and with root
\begin_inset Formula $R$
\end_inset
.
(As a consequence,
it is always possible to choose the free subtree in flow charts like Fig.
32 of Section 2.3.4.1 so that it is actually an
\emph on
oriented
\emph default
subtree;
this would be the case in that diagram if we had selected
\begin_inset Formula $e''_{13}$
\end_inset
,
\begin_inset Formula $e''_{19}$
\end_inset
,
\begin_inset Formula $e_{20}$
\end_inset
,
and
\begin_inset Formula $e_{17}$
\end_inset
instead of
\begin_inset Formula $e'_{13}$
\end_inset
,
\begin_inset Formula $e'_{19}$
\end_inset
,
\begin_inset Formula $e_{23}$
\end_inset
,
and
\begin_inset Formula $e_{15}$
\end_inset
.)
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
answer
\end_layout
\end_inset
We prove by induction that there is a family of oriented subtrees
\begin_inset Formula $\{T_{n}\}_{n\geq0}$
\end_inset
of
\begin_inset Formula $G$
\end_inset
with root
\begin_inset Formula $R$
\end_inset
such that
\begin_inset Formula $T_{n}$
\end_inset
contains exactly all the vertices
\begin_inset Formula $V$
\end_inset
in
\begin_inset Formula $G$
\end_inset
such that there is an oriented path from
\begin_inset Formula $V$
\end_inset
to
\begin_inset Formula $R$
\end_inset
of length at most
\begin_inset Formula $n$
\end_inset
and,
furthermore,
\begin_inset Formula $T_{n-1}\subseteq T_{n}$
\end_inset
for every
\begin_inset Formula $n\geq1$
\end_inset
.
It is easy to check that the union of this family of trees is a tree with all the vertices in
\begin_inset Formula $G$
\end_inset
.
\end_layout
\begin_layout Standard
For
\begin_inset Formula $n=0$
\end_inset
,
we just take the trivial oriented tree,
which only contains
\begin_inset Formula $R$
\end_inset
.
For
\begin_inset Formula $n\geq1$
\end_inset
,
and for every node
\begin_inset Formula $V$
\end_inset
such that the shortest oriented path from
\begin_inset Formula $V$
\end_inset
to
\begin_inset Formula $R$
\end_inset
has length
\begin_inset Formula $n$
\end_inset
,
we choose one such path
\begin_inset Formula $VV_{1}\cdots V_{n-1}R$
\end_inset
,
which we can do for all such vertices because of the axiom of choice.
Since
\begin_inset Formula $V_{1}$
\end_inset
is in
\begin_inset Formula $T_{n-1}$
\end_inset
,
we just have to add
\begin_inset Formula $V$
\end_inset
and the arc
\begin_inset Formula $(V,V_{1})$
\end_inset
to
\begin_inset Formula $T_{n-1}$
\end_inset
,
for all such
\begin_inset Formula $V$
\end_inset
.
\end_layout
\begin_layout Standard
\begin_inset Note Note
status open
\begin_layout Plain Layout
TODO 16,
24
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
rexerc16[M24]
\end_layout
\end_inset
In a popular solitaire game called
\begin_inset Quotes eld
\end_inset
clock,
\begin_inset Quotes erd
\end_inset
the 52 cards of an ordinary deck of playing cards are dealt face down into 13 piles of four each;
12 piles are arranged in a circle like the 12 hours of a clock and the thirteenth pile goes in the center.
The solitaire game now proceeds by turning up the top card of the center pile,
and then if its face value is
\begin_inset Formula $k$
\end_inset
,
by placing it next to the
\begin_inset Formula $k$
\end_inset
th pile.
(The numbers
\begin_inset Formula $1,2,\dots,13$
\end_inset
are equivalent to
\begin_inset Formula $\text{A},2,\dots,10,\text{J},\text{Q},\text{K}$
\end_inset
.) Play continues by turning up the top card of the
\begin_inset Formula $k$
\end_inset
th pile and putting it next to
\emph on
its
\emph default
pile,
etc.,
until we reach a point where we cannot continue since there are no more cards to turn up on the designated pile.
(The player has no choice in the game,
since the rules completely specify what to do.) The game is won if all cards are face up when the play terminates.
\end_layout
\begin_layout Standard
Show that the game will be won if and only if the following directed graph is an oriented tree:
The vertices are
\begin_inset Formula $V_{1},V_{2},\dots,V_{13}$
\end_inset
;
the arcs are
\begin_inset Formula $e_{1},e_{2},\dots,e_{12}$
\end_inset
,
where
\begin_inset Formula $e_{j}$
\end_inset
goes from
\begin_inset Formula $V_{j}$
\end_inset
to
\begin_inset Formula $V_{k}$
\end_inset
if
\begin_inset Formula $k$
\end_inset
is the
\emph on
bottom
\emph default
card in pile
\begin_inset Formula $j$
\end_inset
after the deal.
\end_layout
\begin_layout Standard
(In particular,
if the bottom card of pile
\begin_inset Formula $j$
\end_inset
is a
\begin_inset Quotes eld
\end_inset
\begin_inset Formula $j$
\end_inset
\begin_inset Quotes erd
\end_inset
,
for
\begin_inset Formula $j\neq13$
\end_inset
,
it is easy to see that the game is certainly lost,
since this card could never be turned up.
The result proved in this exercise gives a much faster way to play the game!)
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
answer
\end_layout
\end_inset
First we note that this graph already follows conditions (a) and (b) of the definition of an oriented tree,
so it will be a tree if an only if
\begin_inset Formula $V_{13}$
\end_inset
is a root,
if and only if there are no cycles (see Exercise 7).
We also note that,
since there are only 4 cards of each denomination,
and we only take a card from a pile when we find its denomination except from one from
\begin_inset Formula $V_{13}$
\end_inset
at the start of the game,
the only case where we cannot continue is after finding the last card with face value K.
\end_layout
\begin_layout Itemize
\begin_inset Argument item:1
status open
\begin_layout Plain Layout
\begin_inset Formula $\implies]$
\end_inset
\end_layout
\end_inset
Assume that the game is not an oriented tree,
then there is a cycle
\begin_inset Formula $V_{k_{1}}\cdots V_{k_{m}}$
\end_inset
.
We can assume that the
\begin_inset Formula $k_{1}$
\end_inset
th pile is the first whose bottom card we turn up.
Since clearly
\begin_inset Formula $k_{1}\neq13$
\end_inset
,
this means that we had already turned up all cards with denomination
\begin_inset Formula $k_{1}$
\end_inset
,
but we had not turned up
\begin_inset Formula $k_{m}\#$
\end_inset
.
\end_layout
\begin_layout Itemize
\begin_inset Argument item:1
status open
\begin_layout Plain Layout
\begin_inset Formula $\impliedby]$
\end_inset
\end_layout
\end_inset
Assume we lost
\begin_inset CommandInset href
LatexCommand href
name "the game"
target "https://en.wikipedia.org/wiki/The_Game_(mind_game)"
literal "false"
\end_inset
,
which means that we have turned up all the cards with face value 13 and that,
furthermore,
we have turned up as many cards from the
\begin_inset Formula $k$
\end_inset
th pile as cards with face value
\begin_inset Formula $k$
\end_inset
.
This means that,
if
\begin_inset Formula
\[
U\coloneqq\{V_{j}\mid\text{the }j\text{th pile's bottom card is down}\},
\]
\end_inset
then
\begin_inset Formula $V_{13}\notin U$
\end_inset
and each vertex of
\begin_inset Formula $U$
\end_inset
has one outgoing edge that points to another vertex in
\begin_inset Formula $U$
\end_inset
,
as we have already turned up all the cards with face value
\begin_inset Formula $k$
\end_inset
for
\begin_inset Formula $V_{k}\notin U$
\end_inset
.
Thus
\begin_inset Formula $V_{13}$
\end_inset
is not a root.
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
rexerc24[M20]
\end_layout
\end_inset
Let
\begin_inset Formula $G$
\end_inset
be a connected digraph with arcs
\begin_inset Formula $e_{0},e_{1},\dots,e_{m}$
\end_inset
.
Let
\begin_inset Formula $E_{0},E_{1},\dots,E_{m}$
\end_inset
be a set of positive integers that satisfy Kirchhoff's law for
\begin_inset Formula $G$
\end_inset
;
that is,
for each vertex
\begin_inset Formula $V$
\end_inset
,
\begin_inset Formula
\[
\sum_{\text{init}(e_{j})=V}E_{j}=\sum_{\text{fin}(e_{j})=V}E_{j}.
\]
\end_inset
Assume further that
\begin_inset Formula $E_{0}=1$
\end_inset
.
Prove that there is an oriented walk in
\begin_inset Formula $G$
\end_inset
from
\begin_inset Formula $\text{init}(e_{0})$
\end_inset
such that edge
\begin_inset Formula $e_{j}$
\end_inset
appears exactly
\begin_inset Formula $E_{j}$
\end_inset
times,
for
\begin_inset Formula $1\leq j\leq m$
\end_inset
,
while edge
\begin_inset Formula $e_{0}$
\end_inset
does not appear.
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
answer
\end_layout
\end_inset
We apply Theorem G to the graph whose vertices are those of
\begin_inset Formula $G$
\end_inset
and whose edges are the
\begin_inset Formula $e_{j}$
\end_inset
repeated
\begin_inset Formula $E_{j}$
\end_inset
times.
This is valid,
since we could as well place an intermediate vertex among each edge to avoid repeating edges,
and it would give us an Eulerian cycle in that graph that goes through
\begin_inset Formula $e_{0}$
\end_inset
once.
Coalescing the repeated edges into one gives us back graph
\begin_inset Formula $G$
\end_inset
and a cycle though
\begin_inset Formula $G$
\end_inset
that goes though edge
\begin_inset Formula $e_{j}$
\end_inset
exactly
\begin_inset Formula $E_{j}$
\end_inset
times,
and we just have to remove the only appearance of
\begin_inset Formula $e_{0}$
\end_inset
.
\end_layout
\end_body
\end_document
|