aboutsummaryrefslogtreecommitdiff
path: root/Info/11/NTG/1/Intro/slides.md
blob: b8d45636e324a9a9ff3b8475577a4f87bb087c92 (plain)
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
---
header-includes: |
    \makeatletter
    \beamer@ignorenonframefalse
    \makeatother
    \usepackage[most]{tcolorbox}
    \usetikzlibrary {decorations.markings}
---

## \faIcon{hands-helping} / \faIcon{chalkboard} Arbeitsauftrag: Fachbegriffe \hfill{} 1/5

### Diskutiert folgende Aussage:

\vspace{1cm}
> Damit der Computer sich etwas merken kann, muss eine Variable oder ein Attribut zuerst **initialisiert** und dann **deklariert** werden.
> Die beiden Schritten sind [immer]{.underline} von einander getrennt und dürfen [niemals]{.niemals} in der selben Zeile stehen.

## \faIcon{hands-helping} / \faIcon{chalkboard} Arbeitsauftrag: Objekt Erzeugung \hfill{} 2/5

### Diskutiert folgende Aussage:

\vspace{1cm}
> Die besondere Methode, die Objekte einer Klasse erzeugt, heißt **Konstruktor**, weil sie ein neues Objekt *konstruiert*.
> In Java hat der Konstruktor immer den Namen `new`{.java}, da ein **neues** Objekt erzeugt wird.

## \faIcon{hands-helping} / \faIcon{chalkboard} Arbeitsauftrag: Beziehungen \hfill{} 3/5

### Diskutiert folgende Aussage:

\vspace{1cm}
> Im folgenden Klassendiagramm erbt die Klasse `Person` von der Klasse `Lebewesen` und die Klasse `Gruppe` erbt von der Klasse `Person`.

\begin{center}
\begin{tikzpicture}
\begin{class}[text width=3cm]{Lebewesen}{0, 3}
\attribute{alter}
\operation{bewegen()}
\end{class}

\begin{class}[text width=3cm]{Person}{0, 0}
\attribute{name}
\inherit{Lebewesen}
\end{class}

\begin{class}[text width=3cm]{Gruppe}{6, 0}
\attribute{mitglieder}
\end{class}

\association{Person}{}{0..n}{Gruppe}{2..*}{};
\end{tikzpicture}
\end{center}

## \faIcon{hands-helping} / \faIcon{chalkboard} Arbeitsauftrag: Code verstehen \hfill{} 4/5

### Diskutiert folgende Aussage:

::: {.columns}
:::: {.column width=45%}
```java
int[] zahlen = {3, 6, 2, 7, 1};
for (int i = zahlen.length - 1; i > 1; i--) {
  println(zahlen[i]);
}

```
::::

:::: {.column width=55%}
\vspace{2.5cm}
> Der Code gibt [alle]{.underline} Einträge des Arrays `zahlen` absteigend sortiert aus.
::::
:::

## \faIcon{hands-helping} / \faIcon{chalkboard} Arbeitsauftrag: Vererbung \hfill{} 5/5

### Diskutiert folgende Aussage:

::: {.columns}
:::: {.column width=45%}
```java
class A {
  int a;
  A() { a = 42; }
  void gibAus() {
    println(a);
  }
}
```
::::

:::: {.column width=55%}
```java
class B extends A {
  B(int b) {
    super(b);
    gibAus();
  }
}
```
::::
:::

\vspace{1cm}
> Dieser Code ist ein korrektes Java Programm!


## Worum gehts heute?

\begin{center}
\begin{tikzpicture}
\only<1> {
  \node[rotate=-2] {\Huge{Grafen}};
}
\only<2,3>{
  \node[rotate=3] at (0, 0) {\includegraphics[keepaspectratio, width=6cm]{img/vlad_tepes_002.jpg}};
}
\only<4> { \node[rotate=-1] {\Huge{Graph\underline{en}}};
}
\only<5,6> {
  \node[rotate=-2] {\includegraphics[keepaspectratio, width=8cm]{img/graphen.jpg}};
}
\only<3, 6> {
  \draw[red, line width=2pt] (-3.5, -3.5) -- (3.5, 3.5) (3.5, -3.5) -- (-3.5, 3.5);
}
\end{tikzpicture}
\end{center}

##

![](img/bike.png){.center}

##

\begin{center}
\begin{tikzpicture}[edge/.style = {}, path/.style={}, cycle/.style={}, blocked/.style={}]
\node[draw, thick] at (0, 0) {\includegraphics[keepaspectratio=FALSE, height=8cm, width=4.5cm]{img/Copyrighted/navi.png}};
\node[draw, thick] at (4.75, 0) {\includegraphics[keepaspectratio=FALSE, height=8cm, width=4.5cm]{img/Copyrighted/route.png}};
\node[draw, thick] at (9.5, 0) {\includegraphics[keepaspectratio=FALSE, height=8cm, width=4.5cm]{img/Copyrighted/graph.png}};
%\node[draw, thick] at (9.5, 0) {\resizebox{4.5cm}{8cm}{\input{graph.tikz}}};
\end{tikzpicture}
\end{center}

## \faIcon{pencil-alt} Graphen

\pause
Ein \boldred{Graph} besteht aus einer endlichen Menge von \boldred{Knoten V} (engl. vertices) und einer endlichen Menge von \boldred{Kanten E} (engl. edges).

\pause

\vspace{0.5cm}
Jede Kante verbindet **genau zwei** \boldred{Knoten}, die man auch als \boldred{Nachbarknoten} bezeichnet.

## Beispiele {.standout}

Was lässt sich als Graph darstellen?

## \faIcon{pencil-alt} Beispiel

\begin{tikzpicture}[edge/.style = {}, path/.style={}, cycle/.style={}, blocked/.style={}]
\node[align=center] at (10, 5) {\begin{tabular}{r l} \textbf{V} = & \{Nürnberg, \\ & Feucht, \\ & Wendelstein, \\ & ..., München\} \end{tabular}};
\node at (5, 4) {\resizebox{!}{7cm}{\input{graph.tikz}}};
\node[align=center] at (0, 2) {\begin{tabular}{r l} \textbf{E} = & \{Nürnberg- \\ &Wendelstein, \\ & Nürnberg- \\ & Feucht, ... \} \end{tabular}};
\end{tikzpicture}

## Wege durch Graphen

::: {.columns align=center}
:::: {.column width=50%}
Manchmal gibt es nur in eine Richtung einen Radweg und das Fahren in der Gegenrichtung wäre zu gefährlich.  

\vspace{0.5cm}
Beschreibe wie sich diese Gegebenheit mithilfe des Graphen darstellen ließe.

\vspace{0.5cm}
\only<1>{
  {\Large \phantom{$\Rightarrow$ Graph mit \boldred{gerichteten} Kanten}}
}
\only<2>{
  {\Large $\Rightarrow$ Graph mit \boldred{gerichteten} Kanten}
}
::::

:::: {.column width=50%}

\resizebox{\textwidth}{!}{
  \tikzstyle{path} = []
  \tikzstyle{cycle} = []
  \tikzstyle{blocked} = []
\only<1> {
  \tikzstyle{edge} = []
  \input{graph.tikz}
}
\only<2> {
  \tikzstyle{edge} = [-Latex]
  \input{graph.tikz}
}
}

::::
:::

## Wege durch Graphen
::: {.columns align=center}
:::: {.column width=50%}
Aufgrund von unterschiedlichen Distanzen zwischen zwei Orten und Steigungen/Gefällen benötigt ein Radfahrer unterschiedlich lange für die verschiedenen Fahrten zwischen zwei Orten.

\vspace{0.5cm}
Beschreibe wie sich diese Gegebenheit mithilfe des Graphen darstellen ließe.

\vspace{0.5cm}
\only<1>{
  {\Large \phantom{$\Rightarrow$ \boldred{Kantengewichte}}}
}
\only<2>{
  {\Large $\Rightarrow$ \boldred{Kantengewichte}}
}
::::

:::: {.column width=50%}

\resizebox{\textwidth}{!}{
\only<1> {
  \tikzstyle{blocked} = []
  \tikzstyle{path} = []
  \tikzstyle{cycle} = []
  \tikzstyle{edge} = [-Latex]
  \input{graph.tikz}
}
\only<2> {
  \input{weighted_graph.tikz}
}
}

::::
:::

## \faIcon{pencil-alt} Kanten von Graphen

Die Kanten eines Graphen können ...

* \boldred{gerichtet} oder \boldred{ungerichtet} sein.
* eine \boldred{Gewichtung} haben oder nicht.

\pause
\vspace{0.2cm}
![](img/Copyrighted/graphs.png){.center}

<!-- ::: {.columns} -->
<!-- :::: {.column width=33%} -->
<!-- \begin{center} -->
<!-- \textbf{ungerichtet} -->

<!-- \begin{tikzpicture}[vert/.style={draw, circle}] -->
<!-- \node[vert] (a) {A}; -->
<!-- \node[vert, below left=of a] (b) {B}; -->
<!-- \draw (a) -- (b); -->
<!-- \node[vert, right=of b] (c) {C}; -->
<!-- \draw (a) -- (c); -->
<!-- \node[vert, right=of c] (d) {D}; -->
<!-- \draw (a) -- (d); -->
<!-- \node[vert, below=of c] (e) {E}; -->
<!-- \draw (c) -- (e); -->
<!-- \node[vert, below=of d] (f) {F}; -->
<!-- \draw (d) -- (f); -->
<!-- \end{tikzpicture} -->
<!-- \end{center} -->
<!-- :::: -->

<!-- :::: {.column width=33%} -->
<!-- **gerichtet** -->
<!-- ```{.graphviz} -->
<!-- digraph { -->
  <!-- bgcolor=transparent -->
  <!-- size=5 -->
  <!-- A -> B -->
  <!-- A -> C -->
  <!-- A -> D -->
  <!-- C -> E -->
  <!-- E -> C -->
  <!-- D -> F -->
  <!-- F -> D -->
<!-- } -->
<!-- ``` -->
<!-- :::: -->

<!-- :::: {.column width=33%} -->
<!-- **gewichtet** -->
<!-- ```{.graphviz} -->
<!-- graph { -->
  <!-- bgcolor=transparent -->
  <!-- size=5 -->
  <!-- A -- B [label=10, len=1] -->
  <!-- A -- C [label=15, len=1] -->
  <!-- A -- D [label=20, len=1] -->
  <!-- C -- E [label=30, len=1] -->
  <!-- D -- F [label=20, len=1] -->
<!-- } -->
<!-- ``` -->
<!-- :::: -->
<!-- ::: -->

## Wege durch Graphen

::: {.columns align=center}
:::: {.column width=50%}
Ein \boldred{Pfad (bzw. Weg)} ist eine Folge von Knoten, wobei aufeinanderfolgende Knoten
durch eine Kante miteinander verbunden sind.
::::

:::: {.column width=50%}

\resizebox{\textwidth}{!}{
  \tikzstyle{edge} = []
  \tikzstyle{path} = [draw=blue, thick]
  \tikzstyle{cycle} = []
  \tikzstyle{blocked} = []
  \input{graph.tikz}
}
::::
:::

## Wege durch Graphen

Als \boldred{Länge} eines Pfades bezeichnet man bei ... 

* \boldred{ungewichteten} Graphen die Anzahl der durchlaufenden Kanten
* \boldred{gewichteten} Graphen die Summe der Kantengewichte der durchlaufenden Kanten

## Beispiele

::: {.columns}
:::: {.column width=55%}
Gib die Länge folgender Pfade an:

\begin{tcolorbox}[enhanced,title=1,
  attach boxed title to top left={yshift=-\tcboxedtitleheight/2},
  boxed title style={size=small,colback=blue}]
Wendelstein - Postbauer-Heng - \\ Beilngries - Ingolstadt - Greding
\end{tcolorbox}

\begin{tcolorbox}[enhanced,title=2,
  attach boxed title to top left={yshift=-\tcboxedtitleheight/2},
  boxed title style={size=small,colback=blue}]
Feucht - Neumark i. d. O. - Beilngries~- Kelheim - München - Ingolstadt - Greding
\end{tcolorbox}
::::

:::: {.column width=45%}
\resizebox{\textwidth}{!}{
  \tikzstyle{edge} = []
  \tikzstyle{path} = []
  \tikzstyle{cycle} = []
  \tikzstyle{blocked} = []
  \input{graph.tikz}
}
::::
:::

## Beispiele

::: {.columns}
:::: {.column width=55%}
Gib die Länge folgender Pfade an:

\begin{tcolorbox}[enhanced,title=1,
  attach boxed title to top left={yshift=-\tcboxedtitleheight/2},
  boxed title style={size=small,colback=blue}]
Nürnberg – Wendelstein – Schwanstetten
\end{tcolorbox}

\begin{tcolorbox}[enhanced,title=2,
  attach boxed title to top left={yshift=-\tcboxedtitleheight/2},
  boxed title style={size=small,colback=blue}]
Nürnberg – Wendelstein – \\ Feucht – Nürnberg
\end{tcolorbox}

::::

:::: {.column width=45%}
\resizebox{\textwidth}{!}{
  \input{weighted_graph.tikz}
}
::::
:::

## Wege durch Graphen

::: {.columns align=center}
:::: {.column width=50%}
Ein \boldred{Zyklus (bzw. Kreis)} ist ein einfacher Pfad, bei dem Start- und Zielknoten identisch sind.
::::

:::: {.column width=50%}

\resizebox{\textwidth}{!}{
  \tikzstyle{edge} = []
  \tikzstyle{path} = []
  \tikzstyle{cycle} = [draw=orange, thick]
  \tikzstyle{blocked} = []
  \input{graph.tikz}
}
::::
:::

## Wege durch Graphen

::: {.columns align=center}
:::: {.column width=50%}
Marie hat sich für das Wochenende vorgenommen von Nürnberg nach Kelheim zu radeln.
Am Morgen liest sie jedoch, dass es mehrere Baumaßnahmen gibt:

* Schwanstetten – Greding
* Postbauer-Heng – Beilngries
* Neumarkt i. d. Oberpfalz – Beilngries

sind gesperrt.

Gib an, ob sie ihr Vorhaben dennoch umsetzen kann.

\vspace{0.5cm}
\only<1>{
  {\Huge \phantom{$\Rightarrow$ Nein!}}
}
\only<2>{
  {\Huge $\Rightarrow$ Nein!}
}
::::

:::: {.column width=50%}
\resizebox{\textwidth}{!}{
  \tikzstyle{edge} = []
  \tikzstyle{path} = []
  \tikzstyle{cycle} = []
  \only<1> {
    \tikzstyle{blocked} = []
    \input{graph.tikz}
  }
  \only<2> {
    \tikzstyle{blocked} = [red, dashed, thick]
    \input{graph.tikz}
  }
}
::::
:::

## \faIcon{pencil-alt} Grundbegriffe und Definitionen

Ein Graph heißt ...

* \boldred{zusammenhängend}, wenn von jedem Knoten zu jedem anderen Knoten mindestens ein Pfad existiert.

![](img/Copyrighted/graphs2.png){.center width=70%}

## \faIcon{hands-helping} Grundbegriffe und Definitionen

Fünf Freunde treffen sich auf einer Party und jeder schüttelt jedem die Hand.

Stellen Sie die beschriebene Situation in einem Graphen dar und geben Sie an, wie viele Händeschüttler es gibt.

\pause

\begin{center}
\begin{tikzpicture}[vert/.style={fill=black, circle, inner sep=0pt, minimum size=0.2cm}]
\node[vert] (a) {};
\node[vert, below left = 0.7cm and 0.7cm of a] (b) {};
\node[vert, below right = 0.7cm and 0.7cm of a] (c) {};
\node[vert, below right = 0.7cm and 0.3cm of b] (d) {};
\node[vert, below left = 0.7cm and 0.3cm of c] (e) {};
\draw (a) -- (b);
\draw (a) -- (c);
\draw (a) -- (d);
\draw (a) -- (e);
\draw (b) -- (c);
\draw (b) -- (d);
\draw (b) -- (e);
\draw (c) -- (d);
\draw (c) -- (e);
\draw (d) -- (e);
\end{tikzpicture}
\end{center}

## \faIcon{pencil-alt} Grundbegriffe und Definitionen

Ein Graph heißt ...

* \boldred{zusammenhängend}, wenn von jedem Knoten zu jedem anderen Knoten mindestens ein Pfad existiert.
* \boldred{vollständig}, wenn je zwei Knoten durch genau eine Kante direkt miteinander verbunden sind.

## \faIcon{desktop} Big Bad Joe

[https://www.matheprisma.uni-wuppertal.de/Module/Graphen/index.htm?3](https://www.matheprisma.uni-wuppertal.de/Module/Graphen/index.htm?3)

## \faIcon{desktop} Was haben wir gelernt? {.standout}

\Huge QUIZ