problème test dijkstra
This commit is contained in:
parent
23fc5a8475
commit
e636a00aad
1 changed files with 24 additions and 22 deletions
|
@ -15,43 +15,45 @@ 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 mapName;
|
private static String mapName1;
|
||||||
private static GraphReader reader;
|
private static GraphReader reader1;
|
||||||
private static Graph graph;
|
private static Graph graph1;
|
||||||
private static Node origin;
|
private static Node origin1;
|
||||||
private static Node destination;
|
private static Node destination1;
|
||||||
private static DijkstraAlgorithm dijkstra;
|
private static DijkstraAlgorithm dijkstra1;
|
||||||
private static BellmanFordAlgorithm bellman;
|
private static BellmanFordAlgorithm bellman1;
|
||||||
private static ShortestPathSolution solDijkstra;
|
private static ShortestPathSolution solDijkstra1;
|
||||||
private static ShortestPathSolution solBellman;
|
private static ShortestPathSolution solBellman1;
|
||||||
|
private static Random random1 = new Random();
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initAll() throws IOException{
|
public static void initAll() throws IOException{
|
||||||
|
|
||||||
mapName = "/mnt/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
|
mapName1 = "/mnt/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
|
||||||
// Create a graph reader.
|
// Create a graph reader.
|
||||||
reader = new BinaryGraphReader(
|
reader1 = new BinaryGraphReader(
|
||||||
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
|
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName1))));
|
||||||
|
|
||||||
// Read the graph.
|
// Read the graph.
|
||||||
graph = reader.read();
|
graph1 = reader1.read();
|
||||||
//final int numNodes = graph.size();
|
final int numNodes1 = graph1.size();
|
||||||
origin = graph.get(0);
|
origin1 = graph1.get(random1.nextInt(numNodes1));
|
||||||
destination = graph.get(6);
|
destination1 = graph1.get(random1.nextInt(numNodes1));
|
||||||
dijkstra = new DijkstraAlgorithm(new ShortestPathData(graph,origin,destination,ArcInspectorFactory.getAllFilters().get(0)));
|
dijkstra1 = new DijkstraAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));
|
||||||
bellman = new BellmanFordAlgorithm(new ShortestPathData(graph,origin,destination,ArcInspectorFactory.getAllFilters().get(0)));
|
bellman1 = new BellmanFordAlgorithm(new ShortestPathData(graph1,origin1,destination1,ArcInspectorFactory.getAllFilters().get(0)));
|
||||||
solDijkstra = dijkstra.run();
|
solDijkstra1 = dijkstra1.run();
|
||||||
solBellman = bellman.run();
|
solBellman1 = bellman1.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDijkstra(){
|
public void testDijkstra1(){
|
||||||
assertEquals(solDijkstra.getPath().getLength(),solBellman.getPath().getLength(),0.00001);
|
assertEquals(solDijkstra1.getPath().getLength(),solBellman1.getPath().getLength(),0.00001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue