blatt 5 und aufgabe 1
This commit is contained in:
parent
19aaed7d8f
commit
8e745b3aed
10 changed files with 321 additions and 0 deletions
BIN
übung_5/agt26-blatt05.pdf
Normal file
BIN
übung_5/agt26-blatt05.pdf
Normal file
Binary file not shown.
BIN
übung_5/agt_übung_5.pdf
Normal file
BIN
übung_5/agt_übung_5.pdf
Normal file
Binary file not shown.
17
übung_5/agt_übung_5.tex
Normal file
17
übung_5/agt_übung_5.tex
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
\documentclass[parskip=half]{ngexrcs}
|
||||
\usepackage{hyperref}
|
||||
\setkeys{Gin}{pagebox=artbox, width=0.2\textwidth}
|
||||
|
||||
\subject{Algorithmische Graphentheorie}
|
||||
\title{5. Übungsblatt}
|
||||
\author{Jasper Gude \and Pia Röttgers}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
\points[2em]{25}
|
||||
|
||||
\input{aufgabe_1.tex}
|
||||
\input{aufgabe_2.tex}
|
||||
\input{aufgabe_3.tex}
|
||||
|
||||
\end{document}
|
||||
54
übung_5/aufgabe_1.tex
Normal file
54
übung_5/aufgabe_1.tex
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
\section{Paarungen (Matchings) in Bäumen}
|
||||
\begin{tasks}
|
||||
\item
|
||||
\label{1a}
|
||||
Ein Baum ist ein kreisfreier, zusammenhängender Graph. Ein Baum besitzt ein
|
||||
perfektes Matching genau dann, wenn die Anzahl der Knoten gerade ist und
|
||||
jedes Blatt keine Geschwisterknoten hat.
|
||||
|
||||
Die Anzahl der Knoten muss gerade sein, da in einem perfekten Match\-ing jeder
|
||||
Knoten mit einem anderen gematcht wird.
|
||||
|
||||
Jedes Blatt muss Einzelblatt sein, da der Elternknoten nur mit einem Blatt
|
||||
gematcht werden kann.
|
||||
|
||||
Also ist ein perfektes Matching im Baum eindeutig, da jedes Blatt mit seinem
|
||||
Elternknoten gematcht werden muss. Die Kante ist sicher im Matching enthalten
|
||||
und kann aus dem Graphen entfernt werden. So entsteht ein neues Blatt, für das
|
||||
die selbe Regel gilt.
|
||||
\points{3}
|
||||
\item
|
||||
Der \autoref{alg:treematching} berechnet ein größtes Matching.
|
||||
|
||||
Der Algorithmus ist korrekt, da der Baum $T$ entweder eine gerade Anzahl an
|
||||
Knoten hat, und somit ein perfektes Matching berechnet (Siehe \autoref{1a}) oder genau einen Knoten
|
||||
zu wenig hat und somit das größte Matching um eins kleiner ist, als das perfekte
|
||||
Matching des nächst größeren Baums.
|
||||
|
||||
Die Laufzeit liegt in $\Oh(E)$, da jede Kante maximal einmal zum Matching hinzugefügt
|
||||
und dann aus dem Baum entfernt wird.
|
||||
\begin{algorithm}
|
||||
\centering
|
||||
\caption{Größtes Matching in Bäumen}
|
||||
\label{alg:treematching}
|
||||
\begin{algorithmic}
|
||||
\alg{MatchaTee}{$T = \tup{V, E}$} \+ \\
|
||||
\com{Wurzeln} \\
|
||||
$r \gets V[1]$ \\
|
||||
\com{Wenn Knoten Blatt ist, dann die Kante zum Elternknoten zurückgeben.} \\
|
||||
if $deg(r) = 1$ then \+ \\
|
||||
\com{Die Kante aus dem Baum entfernen.} \\
|
||||
$E \gets E \setminus \set{\set{r, Adj[r]}}$ \\
|
||||
$V \gets V \setminus \set{r}$ \\
|
||||
return $\set{\set{r, Adj[r]}}$ \- \\
|
||||
\com{Rekursiv für die Kinder aufrufen} \\
|
||||
$m \gets \emptyset$ \\
|
||||
foreach $v \in Adj[r]$ do \+ \\
|
||||
$m \gets m \cup \text{\alg{MatchaTee}{T}}$ \- \\
|
||||
return $m$
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
\points{5}
|
||||
\item
|
||||
\points{5}
|
||||
\end{tasks}
|
||||
15
übung_5/aufgabe_2.tex
Normal file
15
übung_5/aufgabe_2.tex
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
\section{Hamiltonkreise}
|
||||
\begin{tasks}
|
||||
\item
|
||||
\points{1}
|
||||
\item
|
||||
\points{2}
|
||||
\item
|
||||
\points{1}
|
||||
\item
|
||||
\points{1}
|
||||
\item
|
||||
\points{1}
|
||||
\item
|
||||
\points{1}
|
||||
\end{tasks}
|
||||
2
übung_5/aufgabe_3.tex
Normal file
2
übung_5/aufgabe_3.tex
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
\section{Perfekte Matchings in bipartiten Graphen}
|
||||
\points{5}
|
||||
38
übung_5/aufgabe_4.tex
Normal file
38
übung_5/aufgabe_4.tex
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
\section{Längste Wege}
|
||||
\begin{tasks}
|
||||
\item
|
||||
Da $s, t$ in $G'$ adjazent zu jedem Knoten in $G$ ist, können wir
|
||||
einen einfachen $s$-$t$-Weg der Länge $k+2$ erzeugen, indem wir
|
||||
einen einfachen Weg der Länge $k$ in $G$ nehmen, $s$ an das eine Ende und $t$ an das andere Ende hängen.
|
||||
|
||||
Umgekehrt kann man aus einem einfachen $s$-$t$-Weg der Länge $k$
|
||||
in $G'$ einen einfachen Weg der Länge $k-2$ in $G$ konstruieren,
|
||||
indem wir $s$ und $t$ entfernen.
|
||||
\points{2}
|
||||
|
||||
\item
|
||||
Ein Hamiltonweg ist ein Weg der alle Knoten in $G$ beinhaltet
|
||||
und somit Länge $n-1$ besitzt.
|
||||
|
||||
Wie wir oben gezeigt haben, kann ein $s$-$t$-Weg der Länge $n+1$
|
||||
in $G'$ leicht in einen Weg der Länge $n-1$ in $G$ umgewandelt
|
||||
werden. Das heißt, dass wir einen Hamiltonweg in $G$ finden,
|
||||
wenn wir einen $s$-$t$-Weg finden.
|
||||
|
||||
Umgekehrt können wir einen Hamiltonweg leicht in einen $s$-$t$-Weg
|
||||
umwandeln, also finden wir einen $s$-$t$-Weg wenn wir einen
|
||||
Hamiltonweg finden.
|
||||
|
||||
Also finden wir einen Hamiltonweg genau dann, wenn wir einen
|
||||
$s$-$t$-Weg finden.
|
||||
\points{1}
|
||||
|
||||
\item
|
||||
Da wir Hamiltonweg auf \algt{Längster $s$-$t$-Weg} reduziert
|
||||
haben, muss also \algt{Längster $s$-$t$-Weg} $\NPe$-schwer sein, denn
|
||||
wenn es in $\Pe$ liegen würde, könnten wir auch Hamiltonweg in
|
||||
polynomieller Zeit lösen. Da wir nicht von $\Pe = \NPe$ ausgehen,
|
||||
ist das nicht möglich.
|
||||
\points{2}
|
||||
|
||||
\end{tasks}
|
||||
BIN
übung_5/figures.pdf
Normal file
BIN
übung_5/figures.pdf
Normal file
Binary file not shown.
71
übung_5/ngexrcs.cls
Normal file
71
übung_5/ngexrcs.cls
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
% vim: set filetype:tex
|
||||
|
||||
% Identification %
|
||||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesClass{ngexrcs}[2021/12/21 ADS Exercise class]
|
||||
|
||||
% Handle options %
|
||||
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}
|
||||
\ProcessOptions\relax
|
||||
|
||||
% More declarations %
|
||||
\LoadClass{scrartcl}
|
||||
|
||||
\KOMAoptions{mpinclude=true}
|
||||
\recalctypearea
|
||||
|
||||
\RequirePackage{ngutils}
|
||||
|
||||
% define fonts
|
||||
\RequirePackage{fontspec}
|
||||
\RequirePackage[math-style=upright]{unicode-math}
|
||||
\setmainfont{TeX Gyre Pagella}
|
||||
\setsansfont{TeX Gyre Heros}
|
||||
\setmonofont{TeX Gyre Cursor}
|
||||
\setmathfont{Euler Math}
|
||||
|
||||
\setlength{\marginparwidth}{1.5\marginparwidth}
|
||||
\setlength{\fboxrule}{\heavyrulewidth}
|
||||
|
||||
% Use sansfont for all title elements
|
||||
\addtokomafont{titlehead}{\sffamily}
|
||||
\addtokomafont{subject}{\sffamily}
|
||||
\addtokomafont{title}{\sffamily}
|
||||
\addtokomafont{subtitle}{\sffamily}
|
||||
\addtokomafont{author}{\sffamily}
|
||||
\addtokomafont{date}{\sffamily}
|
||||
\addtokomafont{publishers}{\sffamily}
|
||||
|
||||
% Use serif font for headings
|
||||
\addtokomafont{disposition}{\rmfamily}
|
||||
|
||||
% Let sections be formated as in: Aufgabe 1 -- Section title
|
||||
\renewcommand*{\sectionformat}{Aufgabe \thesection\autodot\enskip--\enskip}
|
||||
|
||||
% Let points of an exercise be printed as in: [__ / 2]
|
||||
\newkomafont{points}{\sffamily}
|
||||
\newcommand\points[2][1em]{\marginline{\framebox{{\usekomafont{points}\hspace{#1} \textbf{/} #2}}}}
|
||||
|
||||
\newcounter{task}
|
||||
\renewcommand{\thetask}{\@alph\c@task)}
|
||||
\newenvironment{tasks}
|
||||
{
|
||||
\begin{list}{\thetask}
|
||||
{
|
||||
\usecounter{task}
|
||||
\setlength{\leftmargin}{1.6em}
|
||||
}
|
||||
}{%
|
||||
\end{list}
|
||||
}
|
||||
|
||||
\DeclareNewTOC
|
||||
[
|
||||
type=algorithm,
|
||||
types=algorithms,
|
||||
float,
|
||||
floattype=4,
|
||||
name=Algorithmus,
|
||||
listname={Algorithmenverzeichnis}
|
||||
]
|
||||
{loa}
|
||||
124
übung_5/ngutils.sty
Normal file
124
übung_5/ngutils.sty
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesPackage{ngutils}[2025/12/24 Never's LaTeX utils]
|
||||
|
||||
\RequirePackage[ngerman]{babel}
|
||||
\RequirePackage{graphicx}
|
||||
\RequirePackage{tabularx}
|
||||
\RequirePackage{booktabs}
|
||||
\RequirePackage{listings}
|
||||
|
||||
\lstnewenvironment{pseudocode}[1][] %defines the algorithm listing environment
|
||||
{
|
||||
\renewcommand{\lstlistingname}{Algorithmus}
|
||||
\lstset{ %this is the stype
|
||||
mathescape=true,
|
||||
columns=fullflexible,
|
||||
basicstyle=\normalfont,
|
||||
identifierstyle=\scshape,
|
||||
keywordstyle=\bfseries,
|
||||
keywords={, new, if, then, else, while, for, in, to, up, down, foreach, do, return},
|
||||
commentstyle=\itshape,
|
||||
comment=[l]//,
|
||||
delim=[is][\normalfont]{|}{|},
|
||||
tabsize=3,
|
||||
frame=tb,
|
||||
framerule=1pt,
|
||||
#1 % this is to add specific settings to an usage of this environment (for instnce, the caption and referable label)
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
\newcommand{\seilpmi}{\Longleftarrow}
|
||||
|
||||
\newcommand{\NN}{\mathbb{N}}
|
||||
\newcommand{\ZZ}{\mathbb{Z}}
|
||||
\newcommand{\QQ}{\mathbb{Q}}
|
||||
\newcommand{\RR}{\mathbb{R}}
|
||||
\newcommand{\CC}{\mathbb{C}}
|
||||
\newcommand{\PP}{\mathbb{P}}
|
||||
|
||||
\newcommand{\Pe}{\mathrm{P}}
|
||||
\newcommand{\NPe}{\mathrm{NP}}
|
||||
|
||||
\newcommand{\Oh}{\mathcal{O}}
|
||||
\newcommand{\oh}{\scriptstyle{\mathcal{O}}}
|
||||
|
||||
\newcommand{\Eh}{\mathop{\mathrm{E}}}
|
||||
\newcommand{\Var}{\mathop{\mathrm{Var}}}
|
||||
\newcommand{\pot}{\mathop{\mathcal{P}}}
|
||||
\newcommand{\argmax}{\mathop{\mathrm{arg\,max}}}
|
||||
\newcommand{\argmin}{\mathop{\mathrm{arg\,min}}}
|
||||
|
||||
\newcommand{\parens}[1]{\left(#1\right)}
|
||||
\newcommand{\brackets}[1]{\left[#1\right]}
|
||||
\newcommand{\braces}[1]{\left\{#1\right\}}
|
||||
\newcommand{\angled}[1]{\left\langle#1\right\rangle}
|
||||
|
||||
\newcommand{\tup}[1]{\parens{#1}}
|
||||
\newcommand{\ivl}[1]{\brackets{#1}}
|
||||
\newcommand{\set}[1]{\braces{#1}}
|
||||
\newcommand{\arr}[1]{\angled{#1}}
|
||||
\newcommand{\abs}[1]{\lvert#1\rvert}
|
||||
\newcommand{\norm}[1]{\lVert#1\rVert}
|
||||
\newcommand{\ceil}[1]{\lceil#1\rceil}
|
||||
\newcommand{\floor}[1]{\lfloor#1\rfloor}
|
||||
|
||||
\newcommand{\alg}[2]{{\normalfont\scshape#1}{\normalfont(#2)}}
|
||||
\newcommand{\algt}[1]{{\normalfont\scshape#1}}
|
||||
\newcommand{\com}[1]{{\normalfont\itshape/\!\!/ #1}}
|
||||
|
||||
\newenvironment{algorithmic}[1][1em]{
|
||||
\begin{minipage}[t]{\textwidth}
|
||||
\bfseries
|
||||
\begin{tabbing}
|
||||
\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\hspace{#1}\=\kill
|
||||
}{%
|
||||
\end{tabbing}
|
||||
\end{minipage}
|
||||
}
|
||||
|
||||
\newlength{\theoremskip}
|
||||
\setlength{\theoremskip}{6em}
|
||||
|
||||
\newcommand{\theoremfont}{\normalfont\bfseries}
|
||||
\newcommand{\definitionfont}{\normalfont\bfseries}
|
||||
|
||||
\newenvironment{theoremic}[2][\theoremfont]{
|
||||
{#1 #2}
|
||||
\hfill
|
||||
\begin{minipage}[t]{\the\dimexpr\linewidth-\theoremskip\relax}
|
||||
}{
|
||||
\end{minipage}
|
||||
}
|
||||
|
||||
\newenvironment{theorem}{
|
||||
\begin{theoremic}{Satz.}
|
||||
}{
|
||||
\end{theoremic}
|
||||
}
|
||||
|
||||
\newenvironment{lemma}{
|
||||
\begin{theoremic}{Lemma.}
|
||||
}{
|
||||
\end{theoremic}
|
||||
}
|
||||
|
||||
\newenvironment{proof}{
|
||||
\begin{theoremic}{Beweis.}
|
||||
}{
|
||||
\end{theoremic}
|
||||
}
|
||||
|
||||
\newenvironment{definition}{
|
||||
\begin{theoremic}[\definitionfont]{Definition.}
|
||||
}{
|
||||
\end{theoremic}
|
||||
}
|
||||
|
||||
\newenvironment{example}{
|
||||
\begin{theoremic}[\definitionfont]{Beispiel.}
|
||||
}{
|
||||
\end{theoremic}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue