-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bellman-Ford implemented and test added. AStarNode classes changed to
deprecated. Close #28
- Loading branch information
Pablo Rodríguez Mier
committed
Apr 6, 2013
1 parent
4af1a17
commit 8a258be
Showing
6 changed files
with
127 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/test/java/es/usc/citius/lab/hipster/algorithm/BellmanFordTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2013 Centro de Investigación en Tecnoloxías da Información (CITIUS). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package es.usc.citius.lab.hipster.algorithm; | ||
|
||
import es.usc.citius.lab.hipster.testutils.JungEdge; | ||
import edu.uci.ics.jung.graph.DirectedGraph; | ||
import es.usc.citius.lab.hipster.testutils.AlgorithmIteratorFromMazeCreator; | ||
import es.usc.citius.lab.hipster.testutils.JungDirectedGraphFromMazeCreator; | ||
import es.usc.citius.lab.hipster.testutils.MazeSearch; | ||
import es.usc.citius.lab.hipster.util.maze.Maze2D; | ||
import java.awt.Point; | ||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Executes tests over predefined maze strings, comparing the results between | ||
* Jung and AD* iterator. | ||
* | ||
* @author Adrián González Sieira <[email protected]> | ||
* @author Pablo Rodríguez Mier <[email protected]> | ||
* @since 26/03/2013 | ||
* @version 1.0 | ||
*/ | ||
public class BellmanFordTest { | ||
|
||
public BellmanFordTest() { | ||
} | ||
|
||
|
||
|
||
@Test | ||
public void BF_Maze1() throws InterruptedException { | ||
Maze2D maze = new Maze2D(MazeSearch.getTestMaze1()); | ||
execute(maze, false); | ||
} | ||
|
||
@Test | ||
public void BF_Maze2() throws InterruptedException { | ||
Maze2D maze = new Maze2D(MazeSearch.getTestMaze2()); | ||
execute(maze, false); | ||
} | ||
|
||
@Test | ||
public void BF_Maze3() throws InterruptedException { | ||
Maze2D maze = new Maze2D(MazeSearch.getTestMaze3()); | ||
execute(maze, false); | ||
} | ||
|
||
@Test | ||
public void BF_Maze4() throws InterruptedException { | ||
Maze2D maze = new Maze2D(MazeSearch.getTestMaze4()); | ||
execute(maze, false); | ||
} | ||
|
||
@Test | ||
public void BF_Maze5() throws InterruptedException { | ||
Maze2D maze = new Maze2D(MazeSearch.getTestMaze5()); | ||
execute(maze, false); | ||
} | ||
|
||
private void execute(Maze2D maze, boolean heuristic) throws InterruptedException { | ||
BellmanFord<Point> it = AlgorithmIteratorFromMazeCreator.bellmanFord(maze, heuristic); | ||
DirectedGraph<Point, JungEdge> graph = JungDirectedGraphFromMazeCreator.create(maze); | ||
MazeSearch.Result resultJung = MazeSearch.executeJungSearch(graph, maze); | ||
MazeSearch.Result resultIterator = MazeSearch.executePrintIteratorSearch(it, maze); | ||
assertEquals(resultIterator.getCost(), resultJung.getCost(), 0.001); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters