Dokumentation weiter
This commit is contained in:
parent
4677283164
commit
761b81b1c4
1 changed files with 46 additions and 14 deletions
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
\usepackage[utf8]{inputenc}
|
||||
|
||||
\makeatletter
|
||||
\def\BState{\State\hskip-\ALG@thistlm}
|
||||
\makeatother
|
||||
%\makeatletter
|
||||
%\def\BState{\State\hskip-\ALG@thistlm}
|
||||
%\makeatother
|
||||
|
||||
\title{FOP Projektgruppe 175}
|
||||
\author{Steffen Wagner\\
|
||||
|
|
@ -31,22 +31,21 @@
|
|||
\caption{Bildung von Kanten}\label{euclid}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{generateEdges}{}
|
||||
\If{nodes is empty} return
|
||||
\EndIf
|
||||
\If{nodes is empty} return \EndIf
|
||||
\State $castle \gets allCastles[0]$
|
||||
\State $remainingCastles \gets allCastles$
|
||||
\BState \emph{loop:}
|
||||
\Loop
|
||||
\If{$remainingCastles$ is empty} break
|
||||
\EndIf
|
||||
\State connect $castle$ to nearest castle
|
||||
\State $castle \gets nearest castle$
|
||||
\State remove $castle$ from $remainingCastles$
|
||||
\BState \emph{end loop}
|
||||
\BState \emph{for each castle in allCastles:}
|
||||
\State \emph{for each nearCastle in allCastlesInRadius(castle):}
|
||||
\EndLoop
|
||||
\ForAll{castle in allCastles}
|
||||
\ForAll{nearCastle in allCastlesInRadius(castle)}
|
||||
\State connect $castle$ to $nearCastle$
|
||||
\State \emph{end for each}
|
||||
\BState \emph{end for each}
|
||||
\EndFor
|
||||
\EndFor
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
|
@ -88,7 +87,7 @@
|
|||
\State $\text{neighborsOf } firstNode$
|
||||
\State $\rightarrow \text{filter out all } x \text{ where } allVisitedNodes \text{ contains } x$
|
||||
\State $\rightarrow \text{append to } nextVisitNodes$
|
||||
\BState \emph{loop}
|
||||
\Loop
|
||||
\If {$nextVisitNodes \text{ is empty}$}
|
||||
break
|
||||
\EndIf
|
||||
|
|
@ -97,7 +96,7 @@
|
|||
\State $\rightarrow \text{filter out all } x \text{ where } allVisitedNodes \text{ contains } x$
|
||||
\State $\rightarrow \text{append to } nextVisitNodes$
|
||||
\State $\text{delete first element of } nextVisitNodes$
|
||||
\BState \emph{end loop}
|
||||
\EndLoop
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
|
@ -132,12 +131,45 @@
|
|||
\subsection{Wege finden}
|
||||
\subsubsection{Teil (a)}
|
||||
|
||||
$O(n) = $
|
||||
\begin{algorithm}
|
||||
\caption{Berechnung der Distanzen}\label{euclid}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{run}{}
|
||||
\State $v \gets$ getSmallestNode()
|
||||
\Loop
|
||||
\If{$v$ is null} break \EndIf
|
||||
\State $v \gets getSmallestNode()$
|
||||
\EndLoop
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
|
||||
$$O(n) = $$
|
||||
|
||||
$n$ soll in diesem Fall die Anzahl an Knoten wiedergeben.
|
||||
|
||||
Da es sich bei \texttt{availableNodes} um eine
|
||||
\texttt{LinkedList<Node<T>>} handelt, muss bei jedem
|
||||
Durchgehen der Liste jedes Element einzeln abgearbeitet
|
||||
werden. In der Funktion \texttt{getSmallestNode()} ist
|
||||
dies der Fall.
|
||||
|
||||
\subsubsection{Teil (b)}
|
||||
|
||||
Anstelle einer \texttt{LinkedList} braucht man eine
|
||||
Datenstruktur, die bereits nach der Größe sortiert ist,
|
||||
damit bei dem Zugriff auf das kleinste Element nur ein
|
||||
Schritt erforderlich ist.
|
||||
|
||||
$$O(n) = $$
|
||||
|
||||
\subsubsection{Teil (c)}
|
||||
|
||||
Invariante: Nach $h \geq 0$ Durchläufen gilt:
|
||||
|
||||
|
||||
|
||||
\subsection{Kürzester Pfad zu allen Knoten}
|
||||
|
||||
\end{document}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue