Erster schlechter Algorithmus für Kanten ist da
This commit is contained in:
parent
da6aabcdb0
commit
ae2c6c321f
2 changed files with 17 additions and 18 deletions
|
|
@ -151,7 +151,16 @@ public class GameMap {
|
|||
* jede Burg mit allen anderen in einem bestimmten Radius nochmals verbunden
|
||||
*/
|
||||
private void generateEdges() {
|
||||
// TODO: GameMap#generateEdges()
|
||||
|
||||
List<Node<Castle>> castleNodes = castleGraph.getNodes();
|
||||
|
||||
for (int i = 0; i < castleNodes.size(); i++) {
|
||||
if (i == castleNodes.size() - 1)
|
||||
castleGraph.addEdge(castleNodes.get(i), castleNodes.get(0));
|
||||
else
|
||||
castleGraph.addEdge(castleNodes.get(i), castleNodes.get(i+1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,27 +31,13 @@
|
|||
\caption{Bildung von Kanten}\label{euclid}
|
||||
\begin{algorithmic}[1]
|
||||
\Procedure{generateEdges}{}
|
||||
\State $\textit{firstNode} \gets \text{first element of }\textit{nodes}$
|
||||
\State $allVisitedNodes \gets \textit{empty}$
|
||||
\State $nextVisitNodes \gets empty$
|
||||
\State $\text{append } firstNode \text{ to } allVisitedNodes$
|
||||
\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}
|
||||
\If {$nextVisitNodes \text{ is empty}$}
|
||||
break
|
||||
\EndIf
|
||||
\State $\text{neighborsOf first element of } nextVisitNodes$
|
||||
\State $\rightarrow \text{filter out all } x \text{ where } allVisitedNodes \text{ contains } x$
|
||||
\State $\rightarrow \text{append to } nextVisitNodes$
|
||||
\State $\text{append first element of } nextVisitNodes \text{ to } allVisitedNodes$
|
||||
\State $\text{delete first element of } nextVisitNodes$
|
||||
\BState \emph{end loop}
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\end{algorithm}
|
||||
|
||||
% Erklärung des Algorithmus
|
||||
|
||||
|
||||
\subsection{Überprüfung der Erreichbarkeit aller Knoten}
|
||||
|
||||
Der Algorithmus, der prüft, ob alle Knoten erreichbar sind, ist
|
||||
|
|
@ -97,5 +83,9 @@
|
|||
Nachbarn, die schon in der Liste \texttt{allVisitedNodes}
|
||||
vorhanden sind, werden verworfen. Die restlichen Nachbarn
|
||||
werden der Liste \texttt{nextVisitNodes} hinzugefügt.
|
||||
|
||||
\subsection{Wege finden}
|
||||
|
||||
\subsection{Kürzester Pfad zu allen Knoten}
|
||||
|
||||
\end{document}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue