Exemplo n.º 1
0
 @Test
 public void testAStar_time() {
   MapGraph mapGraph = new MapGraph();
   mapGraph.addRoad("Road 1", new Point2D.Double(0, 20), new Point2D.Double(100, 20), 35);
   mapGraph.addRoad("Road 2", new Point2D.Double(20, 0), new Point2D.Double(20, 100), 5);
   mapGraph.addRoad("Road 3", new Point2D.Double(0, 80), new Point2D.Double(100, 80), 35);
   mapGraph.addRoad("Road 4", new Point2D.Double(80, 0), new Point2D.Double(80, 100), 35);
   mapGraph.addRoad("Slanted road", new Point2D.Double(25, 15), new Point2D.Double(75, 85), 5);
   LinkedList<Intersection> shortestPath1 =
       mapGraph.shortestPath_time(
           mapGraph.getIntersectionByName("Road 3 + Road 4"),
           mapGraph.getIntersectionByName("Road 1 + Road 2"));
   if (shortestPath1 == null) fail();
   System.out.println(shortestPath1);
   Iterator<Intersection> test = shortestPath1.iterator();
   assertEquals("Road 3 + Road 4", test.next().toString());
   assertEquals("Road 1 + Road 4", test.next().toString());
   assertEquals("Road 1 + Slanted road", test.next().toString());
   assertEquals("Road 1 + Road 2", test.next().toString());
   assertFalse(test.hasNext());
 }