mirror of https://github.com/2martens/uni.git
147 lines
4.2 KiB
TeX
147 lines
4.2 KiB
TeX
\documentclass[10pt,a4paper,oneside,ngerman,numbers=noenddot]{scrartcl}
|
|
\usepackage[T1]{fontenc}
|
|
\usepackage[utf8]{inputenc}
|
|
\usepackage[ngerman]{babel}
|
|
\usepackage{amsmath}
|
|
\usepackage{amsfonts}
|
|
\usepackage{amssymb}
|
|
\usepackage{bytefield}
|
|
\usepackage{paralist}
|
|
\usepackage{gauss}
|
|
\usepackage{pgfplots}
|
|
\usepackage{textcomp}
|
|
\usepackage[locale=DE,exponent-product=\cdot,detect-all]{siunitx}
|
|
\usepackage{tikz}
|
|
\usepackage{algpseudocode}
|
|
\usepackage{algorithm}
|
|
%\usepackage{algorithmic}
|
|
%\usepackage{minted}
|
|
\usetikzlibrary{automata,matrix,fadings,calc,positioning,decorations.pathreplacing,arrows,decorations.markings}
|
|
\usepackage{polynom}
|
|
\polyset{style=C, div=:,vars=x}
|
|
\pgfplotsset{compat=1.8}
|
|
\pagenumbering{arabic}
|
|
\def\thesection{\arabic{section})}
|
|
\def\thesubsection{(\alph{subsection})}
|
|
\def\thesubsubsection{(\roman{subsubsection})}
|
|
\makeatletter
|
|
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
|
|
\hskip -\arraycolsep
|
|
\let\@ifnextchar\new@ifnextchar
|
|
\array{#1}}
|
|
\makeatother
|
|
\parskip 12pt plus 1pt minus 1pt
|
|
\parindent 0pt
|
|
|
|
\begin{document}
|
|
\author{Reinhard Köhler (6425686), Tronje Krabbe (6435002), \\
|
|
Jim Martens (6420323)}
|
|
\title{Hausaufgaben zum 15. Januar}
|
|
\subtitle{Gruppe 8}
|
|
\maketitle
|
|
|
|
\section{} %1
|
|
\subsection{} %a
|
|
\begin{tabular}{c|c|c|c|c|c|c|c|c}
|
|
EXTRACT & 1 & 2 & 3 & 4 & 5 & 6 & 7 &\\
|
|
\hline
|
|
- & 0 & $\infty$ & $\infty$ & $\infty$ & $\infty$ & $\infty$ & $\infty$ & (v.dist) \\
|
|
& - & - & - & - & - & - & - & (v.$\pi$) \\
|
|
\hline
|
|
1 & 0 & 4 & $\infty$ & $\infty$ & $\infty$ & 5 & $\infty$ & \\
|
|
& - & 1 & - & - & - & 1 & - & \\
|
|
\hline
|
|
2 & 0 & 4 & 14 & $\infty$ & $\infty$ & 5 & 7 & \\
|
|
& - & 1 & 2 & - & - & 1 & 2 & \\
|
|
\hline
|
|
6 & 0 & 4 & 14 & $\infty$ & 14 & 5 & 7 & \\
|
|
& - & 1 & 2 & - & 6 & 1 & 2 & \\
|
|
\hline
|
|
7 & 0 & 4 & 13 & $\infty$ & 10 & 5 & 7 & \\
|
|
& - & 1 & 7 & - & 7 & 1 & 2 & \\
|
|
\hline
|
|
5 & 0 & 4 & 12 & 15 & 10 & 5 & 7 & \\
|
|
& - & 1 & 5 & 5 & 7 & 1 & 2 & \\
|
|
\hline
|
|
3 & 0 & 4 & 12 & 14 & 10 & 5 & 7 & \\
|
|
& - & 1 & 5 & 3 & 7 & 1 & 2 & \\
|
|
\hline
|
|
4 & 0 & 4 & 12 & 14 & 10 & 5 & 7 & \\
|
|
& - & 1 & 5 & 3 & 7 & 1 & 2 &
|
|
\end{tabular}
|
|
|
|
Der kürzeste Pfad von 1 nach 4 verläuft über 2, 7, 5 und 3 nach 4. Insgesamt kostet der Pfad 14.
|
|
\subsection{} %b
|
|
In $G_{2}$ ist 3 die Quelle.
|
|
|
|
\begin{tabular}{c|c|c|c|c|c|c|c|c}
|
|
EXTRACT & 3 & 1 & 2 & 4 & 5 &\\
|
|
\hline
|
|
- & 0 & $\infty$ & $\infty$ & $\infty$ & $\infty$ & (v.dist) \\
|
|
& - & - & - & - & - & (v.$\pi$) \\
|
|
\hline
|
|
3 & 0 & $\infty$ & 9 & 4 & $\infty$ & \\
|
|
& - & - & 3 & 3 & - & \\
|
|
\hline
|
|
4 & 0 & 5 & 8 & 4 & 6 & \\
|
|
& - & 4 & 4 & 3 & 4 & \\
|
|
\hline
|
|
1 & 0 & 5 & 8 & 4 & 6 & \\
|
|
& - & 4 & 4 & 3 & 4 & \\
|
|
\hline
|
|
5 & 0 & 1 & 8 & 4 & 6 & \\
|
|
& - & 5 & 4 & 3 & 4 & \\
|
|
\end{tabular}
|
|
|
|
Durch die negative Kante von 5 nach 1, würde sich der kürzeste Pfad von 1 von 5 auf 1 ändern, was jedoch nicht geht, da 1 bereits besucht wurde. Daher liefert Dijkstra für das Single-Source-Shortest-Path Problem in $G_{2}$ ein falsches Ergebnis.
|
|
\section{} %2
|
|
\begin{algorithm}
|
|
\caption{Relax}
|
|
\begin{algorithmic}[1]
|
|
\Procedure{Relax}{$u,v$}
|
|
\If{$w(u,v) > u.maxWeight$}
|
|
\State $v.maxWeight \gets w(u,v)$
|
|
\State $v.\pi \gets u$
|
|
\EndIf
|
|
\EndProcedure
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
|
|
\begin{algorithm}
|
|
\caption{Initialize single source}
|
|
\begin{algorithmic}[1]
|
|
\Procedure{InitializeSingleSource}{$G,s$}
|
|
\ForAll{$v \in V$}
|
|
\State $v.maxWeight \gets \infty$
|
|
\State $v.\pi \gets NIL$
|
|
\EndFor
|
|
\State $s.maxWeight \gets 0$
|
|
\EndProcedure
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
|
|
\begin{algorithm}
|
|
\caption{Dijkstra für leichtest mögliche schwerste Kanten}
|
|
\begin{algorithmic}[1]
|
|
\Procedure{Dijkstra}{$G,w,s$}
|
|
\State $\Call{InitializeSingleSource}{G,s}$
|
|
\State $Q \gets (V, V.maxWeight)$\Comment{ordered by the maximum weight (edge with highest weight) per path in ascending order}
|
|
\While{$Q \neq \emptyset$}
|
|
\State $u \gets \Call{Extract}{Q}$
|
|
\ForAll{v adjacent to u}
|
|
\State $\Call{Relax}{u,v}$ and update the keys in Q accordingly
|
|
\EndFor
|
|
\EndWhile
|
|
\EndProcedure
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
\section{} %3
|
|
\subsection{} %a
|
|
\subsection{} %b
|
|
\subsection{} %c
|
|
\section{} %4
|
|
\subsection{} %a
|
|
\subsection{} %b
|
|
|
|
\end{document}
|