Compare commits
No commits in common. "1821ccfa7093170ff78c9dc40a87bf4ec2241aef" and "3eab8045ccb27832d40136133c6ab41ad86de65e" have entirely different histories.
1821ccfa70
...
3eab8045cc
1 changed files with 22 additions and 24 deletions
|
@ -15,45 +15,43 @@ import java.io.IOException;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class DijkstraTest {
|
public class DijkstraTest {
|
||||||
|
|
||||||
private static String mapName1;
|
private static String mapName;
|
||||||
private static GraphReader reader1;
|
private static GraphReader reader;
|
||||||
private static Graph graph1;
|
private static Graph graph;
|
||||||
private static Node origin1;
|
private static Node origin;
|
||||||
private static Node destination1;
|
private static Node destination;
|
||||||
private static DijkstraAlgorithm dijkstra1;
|
private static DijkstraAlgorithm dijkstra;
|
||||||
private static BellmanFordAlgorithm bellman1;
|
private static BellmanFordAlgorithm bellman;
|
||||||
private static ShortestPathSolution solDijkstra1;
|
private static ShortestPathSolution solDijkstra;
|
||||||
private static ShortestPathSolution solBellman1;
|
private static ShortestPathSolution solBellman;
|
||||||
private static Random random1 = new Random();
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initAll() throws IOException{
|
public static void initAll() throws IOException{
|
||||||
|
|
||||||
mapName1 = "/mnt/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
|
mapName = "/mnt/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
|
||||||
// Create a graph reader.
|
// Create a graph reader.
|
||||||
reader1 = new BinaryGraphReader(
|
reader = new BinaryGraphReader(
|
||||||
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName1))));
|
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
|
||||||
|
|
||||||
// Read the graph.
|
// Read the graph.
|
||||||
graph1 = reader1.read();
|
graph = reader.read();
|
||||||
final int numNodes1 = graph1.size();
|
//final int numNodes = graph.size();
|
||||||
origin1 = graph1.get(random1.nextInt(numNodes1));
|
origin = graph.get(0);
|
||||||
destination1 = graph1.get(random1.nextInt(numNodes1));
|
destination = graph.get(6);
|
||||||
dijkstra1 = new DijkstraAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));
|
dijkstra = new DijkstraAlgorithm(new ShortestPathData(graph,origin,destination,ArcInspectorFactory.getAllFilters().get(0)));
|
||||||
bellman1 = new BellmanFordAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));
|
bellman = new BellmanFordAlgorithm(new ShortestPathData(graph,origin,destination,ArcInspectorFactory.getAllFilters().get(0)));
|
||||||
solDijkstra1 = dijkstra1.run();
|
solDijkstra = dijkstra.run();
|
||||||
solBellman1 = bellman1.run();
|
solBellman = bellman.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDijkstra1(){
|
public void testDijkstra(){
|
||||||
assertEquals(solDijkstra1.getPath().getLength(),solBellman1.getPath().getLength(),0.00001);
|
assertEquals(solDijkstra.getPath().getLength(),solBellman.getPath().getLength(),0.00001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue