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
|
---
header-includes: |
\usepackage{bm}
---
## Here comes Manfred!
::: {.columns align=center}
:::: {.column width=65%}

::::
:::: {.column width=40%}
\pause
Manfred der freundliche Minotaurus aus der Nachbarschaft braucht [immernoch]{.underline} Hilfe in seinem Labyrinth!
::::
:::
## *"Ich kenne mich immer noch nicht aus!"*
::: {.columns}
:::: {.column width=30%}

::::
:::: {.column width=70%}
`\begin{center}`{=latex}
\textit{Das ist mein Zuhause!}
\vspace{0.1cm}
{height=70%}
\begin{tikzpicture}[overlay, remember picture]
\only<2>{
\node[anchor=north west, fill=magenta, opacity=0.5, minimum size=0.75cm] at (0.41, 3.98) {};
}
\end{tikzpicture}
\vspace{-0.1cm}
> Welche Zimmer grenzen nochmal an mein Atelier (Zimmer 9)?
`\end{center}`{=latex}
::::
:::
## Wiederholung: Zimmer finden
\begin{tikzpicture}
\foreach \y in {2,...,3} {
\node[anchor=south west, minimum size=1cm, draw] at (-3, \y) {};
}
\only<-3>{
\node[anchor=south west, minimum size=1cm, draw] at (-3, 0.7) {};
}
\only<4> {
\node[anchor=south west, minimum size=1cm, draw, fill=magenta!30] at (-3, 0.7) {};
}
\node[] at (-2.5, 1.85) {\large \textbf{...}};
\node[anchor=south west, minimum size=1cm, draw] at (-3, -0.6) {};
\node[] at (-2.5, 0.55) {\large \textbf{...}};
\foreach \y in {0,...,1} {
\node at (-1.75, 3.5 - \y) {\textbf \y};
}
\only<-3>{
\node at (-1.75, 1.2) {\textbf 8};
}
\node at (-1.75, -0.1) {\textbf{15}};
\begin{object}[text width=4.2cm]{p: Knoten}{-6, 4.5}
\attribute{name = "Pool"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, 3.5) {};
\draw[-Triangle, thick] (-2.5, 3.5) -- (-3.5, 4);
\begin{object}[text width=4.2cm]{b: Knoten}{-6, 3}
\attribute{name = "Badezimmer"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, 2.5) {};
\draw[-Triangle, thick] (-2.5, 2.5) -- (-3.5, 2.5);
\node at (-6, 1.6) {\large \textbf{...}};
\begin{object}[text width=4.2cm]{a: Knoten}{-6, 1.3}
\attribute{name = "Atelier"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, 1.2) {};
\draw[-Triangle, thick] (-2.5, 1.2) -- (-3.5, 0.8);
\node at (-6, -0.1) {\large \textbf{...}};
\begin{object}[text width=4.2cm]{s: Knoten}{-6, -0.4}
\attribute{name = "Schlafzimmer"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, -0.1) {};
\draw[-Triangle, thick] (-2.5, -0.1) -- (-3.5, -0.9);
%\node at (-5, -2) {\texttt{anzKnoten = 16}};
\node at (2, 4.25) {gesuchte Bezeichnung: "Atelier"};
\only<2> {
\node at (-1, 3.5){\Large \textcolor{red!70}{$\bm{\Leftarrow}$}};
}
\only<3> {
\node at (-1, 2.5){\Large \textcolor{red!70}{$\bm{\Leftarrow}$}};
}
\only<4> {
\node at (-1, 1.2){\Large \textcolor{green!70!black}{$\bm{\Leftarrow}$}};
\node[magenta] at (-1.75, 1.2) {\textbf 8};
}
\end{tikzpicture}
## Wiederholung: Knoten finden
::: {.columns align=top}
:::: {.column width=45%}
\vspace{0.5cm}
```
für index < Anzahl der Knoten
falls Knotenbezeichnung gleich
gesuchter Bezeichnung
gibt index zurück
gibt -1 zurück
```
::::
:::: {.column width=55%}
\pause
```java
int knotenFinden(String bezeichnung) {
for (int i = 0; i < anzKnoten; i++) {
if (knotenfeld[i].bezeichnung
== bezeichnung) {
return i;
}
}
return -1;
}
```
::::
:::
## Nachbarn ausgeben
\begin{tikzpicture}
\foreach \y in {2,...,3} {
\node[anchor=south west, minimum size=1cm, draw] at (-3, \y) {};
}
\only<1>{
\node[anchor=south west, minimum size=1cm, draw] at (-3, 0.7) {};
}
\only<2-> {
\node[anchor=south west, minimum size=1cm, draw, fill=magenta!30] at (-3, 0.7) {};
}
\node[] at (-2.5, 1.85) {\large \textbf{...}};
\node[anchor=south west, minimum size=1cm, draw] at (-3, -0.6) {};
\node[] at (-2.5, 0.55) {\large \textbf{...}};
\foreach \y in {0,...,1} {
\node at (-1.75, 3.5 - \y) {\textbf \y};
}
\only<1>{
\node at (-1.75, 1.2) {\textbf 8};
}
\node at (-1.75, -0.1) {\textbf{15}};
\begin{object}[text width=4.2cm]{p: Knoten}{-6, 4.5}
\attribute{name = "Pool"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, 3.5) {};
\draw[-Triangle, thick] (-2.5, 3.5) -- (-3.5, 4);
\begin{object}[text width=4.2cm]{b: Knoten}{-6, 3}
\attribute{name = "Badezimmer"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, 2.5) {};
\draw[-Triangle, thick] (-2.5, 2.5) -- (-3.5, 2.5);
\node at (-6, 1.6) {\large \textbf{...}};
\begin{object}[text width=4.2cm]{a: Knoten}{-6, 1.3}
\attribute{name = "Atelier"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, 1.2) {};
\draw[-Triangle, thick] (-2.5, 1.2) -- (-3.5, 0.8);
\node at (-6, -0.1) {\large \textbf{...}};
\begin{object}[text width=4.2cm]{s: Knoten}{-6, -0.4}
\attribute{name = "Schlafzimmer"}
\end{object}
\node[draw, circle, fill, inner sep=1pt] at (-2.5, -0.1) {};
\draw[-Triangle, thick] (-2.5, -0.1) -- (-3.5, -0.9);
\only<2-> {
\node[magenta] at (-1.75, 1.2) {\textbf 8};
}
\only<3->{
\draw[Triangle-Triangle, thick, dashed] (-1.6, 1.2) -- (-0.4, 1.2);
\node at (-0.25, 1.2) {\textbf{\textcolor{magenta}{8}}};
}
\only<4>{
\node[anchor=south west, minimum size=1cm, fill=teal!30] at (1.5, 0.3) {?};
}
\only<5>{
\node[anchor=south west, minimum size=1cm, fill=teal!30] at (2.5, 0.3) {?};
}
\only<6>{
\node[anchor=south west, minimum size=1cm, fill=teal!30] at (3.5, 0.3) {?};
}
\only<7>{
\node[anchor=south west, minimum size=1cm, fill=teal!30] at (4.5, 0.3) {?};
}
\foreach \y in {0,...,1} {
\node at (-0.25, 3.5 - \y) {\textbf \y};
}
\only<-2>{
\node at (-0.25, 1.2) {\textbf 8};
}
\node at (-0.25, -0.1) {\textbf{15}};
\foreach \y in {2,...,3} {
\node[anchor=south west, minimum size=1cm, draw] at (0, \y) {};
}
\only<-2>{
\node[anchor=south west, minimum size=1cm, draw] at (0, 0.7) {};
}
\only<3-> {
\node[anchor=south west, minimum size=1cm, draw, fill=magenta!30] at (0, 0.7) {};
}
\node[] at (0.5, 1.85) {\large \textbf{...}};
\node[anchor=south west, minimum size=1cm, draw] at (0, -0.6) {};
\node[] at (0.5, 0.55) {\large \textbf{...}};
\foreach \x in {0,...,3}
\node at (\x + 2, 4.5) {\textbf \x};
\foreach \y in {2,...,3} {
\foreach \x in {0,...,3} {
\node[anchor=south west, minimum size=1cm, draw] at (1.5 + \x , -0.5 + \y + \y*0.25) {};
}
\node[draw, circle, fill, inner sep=1pt] at (0.5, \y + 0.5) {};
\draw[-Triangle, thick] (0.5, \y + 0.5) -- (1.5, \y + \y*0.25);
}
\node at (3.5, 1.6) {\large \textbf{...}};
\foreach \x in {0,...,3} {
\node[anchor=south west, minimum size=1cm, draw] at (1.5 + \x, 0.3) {};
}
\node[draw, circle, fill, inner sep=1pt] at (0.5, 1.2) {};
\draw[-Triangle, thick] (0.5, 1.2) -- (1.5, 0.8);
\node at (3.5, -0.1) {\large \textbf{...}};
\foreach \x in {0,...,3} {
\node[anchor=south west, minimum size=1cm, draw] at (1.5 + \x , -1.4) {};
}
\node[draw, circle, fill, inner sep=1pt] at (0.5, -0.1) {};
\draw[-Triangle, thick] (0.5, -0.1) -- (1.5, -0.9);
\end{tikzpicture}
## \faIcon{pencil-alt} Lösung: Nachbarn ausgeben
`\begin{center}`{=latex}
```
finde index des Ausgangsknoten
für index < Anzahl der Knoten
falls ausgehende Kante von Ausgangs- zu aktuellem Knoten
gib aktuelle Knoten-Bezeichnung aus
```
\vspace{0.2cm}
```java
void nachbarnAusgeben(String bezeichnung) {
int knotenIndex = knotenFinden(bezeichnung);
for (int i = 0; i < anzKnoten; i++) {
if (adjazenzmatrix[knotenIndex][i] != -1) {
println(knotenfeld[i].bezeichnung);
}
}
}
```
`\end{center}`{=latex}
## \faIcon{desktop} Arbeitsauftrag: Nachbarn zählen \hfill 7 min
Implementiere eine Methode, die die Anzahl der ausgehenden Kanten eines Knoten zählt.
`\begin{enumerate}`{=latex}
\item Implementiere die Methode `int ausgehendeKantenZaehlen(String bezeichner)`{.java}
`\end{enumerate}`{=latex}
### Tipp
Orientiere dich an der Methode `nachbarnAusgeben(String bezeichnung)`{.java}.
## Manfred sucht ein neues Labyrinth
\begin{tikzpicture}
\node {\includegraphics[keepaspectratio, width=\textwidth]{topic/img/laboscout.png}};
\node at (-5, 0) {\includegraphics[keepaspectratio, height=\textheight]{topic/img/manfred_cut_out.png}};
\end{tikzpicture}
## \only<2>{\faIcon{desktop}/\faIcon{pencil-alt} Arbeitsauftrag:} Manfred sucht ein neues Labyrinth
::: {.columns align=center}
:::: {.column width=30%}

::::
:::: {.column width=70%}
> Bei LaboScout24 kann ich die Labyrinthe als Graph herunterladen.
> Mich würde interessieren:
1. Sind die Wege in dem Labyrinth alle gleich schwierig?
2. Verlaufen manche Gänge nur in eine Richtung?
3. \faIcon{earlybirds} **[Für Schnelle]{.underline}**: Wie viele Sackgassen sind in dem Labyrinth?
\pause
### Arbeitsauftrag \faIcon{hands-helping}
Entwickelt Vorgehen in Java oder Pseudocode um Manfreds Fragen zu beantworten.
::::
:::
## Lösung: Gewichtete Graphen erkennen
### \faIcon[regular]{lightbulb} Idee:
In einem \boldred{gewichteten} Graphen gibt es mindestens eine Kante mit Gewicht $> 1$.
Also müssen wir \boldred{alle} Kantengewichte überprüfen.
\pause
```java
boolean istUngewichtet() {
for (int i=0; i < anzKnoten; i++) {
for (int j=0; j < anzKnoten; j++) {
if (adjazenzmatrix[i][j] > 1) {
return false; // Graph ist gewichtet
}
}
}
return true; // Graph ist ungewichtet
}
```
## Lösung: Ungerichtete Graphen erkennen
### \faIcon[regular]{lightbulb} Idee:
\pause
::: {.columns}
:::: {.column width=60%}
Die Adjazenzmatrix eines \boldred{ungerichteten} Graphen muss achsensymmetrisch zu ihrer Diagonalen sein.
::::
:::: {.column width=30%}
\begin{tabular}{c | c | c}
\rowcolor{gray!30} \cellcolor{gray} & v1 & v2 \\
\hline
\cellcolor{gray!30} v1 & \cellcolor{yellow!30} & \boldred{1} \\
\hline
\cellcolor{gray!30} v2 & \boldred{1} & \cellcolor{yellow!30} \\
\end{tabular}
::::
:::
\pause
\vspace{0.3cm}
Also müssen wir prüfen ob \boldred{beide} Richtungen einer Kante gleich sind.
\pause
### Überprüfung in Java \faIcon{java}
```java
if (adjazenzmatrix[i][j] != adjazenzmatrix[j][i]
return false;
}
}
```
|