private static void createLargeRoom() throws Exception {
    int gridResolution = 4;
    AccessibilityGraphImpl room1 =
        GraphFactory.createRectangularGridGraph(100, 100, gridResolution, 0, 0);

    room1.write("src/main/resources/graphs/large-room.txt");

    GraphGridAdaptor graphGridAdaptor = new GraphGridAdaptor();
    graphGridAdaptor.setGraph(room1);
    graphGridAdaptor.afterPropertiesSet();
    graphGridAdaptor.write(new File("src/main/resources/grids/" + "large-room.txt"));
  }
  private static void create4Rooms() throws Exception {
    int gridResolution = 2;
    AccessibilityGraphImpl room1 =
        GraphFactory.createRectangularGridGraph(40, 30, gridResolution, 0, 0);

    AccessibilityGraphImpl corridor12 =
        GraphFactory.createRectangularGridGraph(2, 4, gridResolution, 42, 14);

    AccessibilityGraphImpl connect = GraphFactory.connect(room1, corridor12, gridResolution);

    AccessibilityGraphImpl room2 =
        GraphFactory.createRectangularGridGraph(40, 30, gridResolution, 46, 0);

    connect = GraphFactory.connect(connect, room2, gridResolution);

    AccessibilityGraphImpl room3 =
        GraphFactory.createRectangularGridGraph(40, 30, gridResolution, 0, 36);

    AccessibilityGraphImpl corridor13 =
        GraphFactory.createRectangularGridGraph(4, 2, gridResolution, 18, 32);

    connect = GraphFactory.connect(connect, room3, gridResolution);
    connect = GraphFactory.connect(connect, corridor13, gridResolution);

    AccessibilityGraphImpl room4 =
        GraphFactory.createRectangularGridGraph(40, 30, gridResolution, 46, 36);

    AccessibilityGraphImpl corridor34 =
        GraphFactory.createRectangularGridGraph(4, 2, gridResolution, 66, 32);
    connect = GraphFactory.connect(connect, corridor34, gridResolution);

    AccessibilityGraphImpl corridor24 =
        GraphFactory.createRectangularGridGraph(2, 4, gridResolution, 42, 50);
    connect = GraphFactory.connect(connect, corridor24, gridResolution);

    connect = GraphFactory.connect(connect, room4, gridResolution);

    System.out.println(connect.getBoundingBox());

    new GraphGUI(connect);

    connect.write("src/main/resources/graphs/4rooms-graph.txt");

    GraphGridAdaptor graphGridAdaptor = new GraphGridAdaptor();
    graphGridAdaptor.setGraph(connect);
    graphGridAdaptor.afterPropertiesSet();
    graphGridAdaptor.write(new File("src/main/resources/grids/" + "4rooms-grid.txt"));
  }
  private static double getCost(List<Location> path, AccessibilityGraphImpl graph) {
    double cost = 0;

    for (int i = 0; i < path.size() - 1; i++) {
      cost += graph.getShortestPathLength(path.get(i), path.get(i + 1));
    }

    return cost;
  }
  public static void main(String[] args) {
    AccessibilityGraphImpl graph = new AccessibilityGraphImpl();

    Location location1 = graph.addAccessibleLocation(0, 0);
    Location location2 = graph.addAccessibleLocation(0, 1);
    Location location3 = graph.addAccessibleLocation(1, 0);
    Location location4 = graph.addAccessibleLocation(1, 1);

    List<Location> locations = Arrays.asList(location1, location2, location3, location4);

    Location start = graph.addAccessibleLocation(-1, 0);
    Location finish = graph.addAccessibleLocation(2, 0);

    for (Location loc : graph) {
      for (Location loc1 : graph) {
        graph.addAccessibilityRelation(loc, loc1);
      }
    }

    BruteForceTSPSolver solver = new BruteForceTSPSolver(graph);
    List<Location> computeTSP = solver.computeTSP(start, finish, locations, 10);

    System.out.println(computeTSP);

    System.out.println(getCost(computeTSP, graph));

    computeTSP = Arrays.asList(start, location1, location2, location4, location3, finish);
    System.out.println(getCost(computeTSP, graph));
  }
  private static void create2Rooms() throws Exception {
    AccessibilityGraphImpl room1 =
        GraphFactory.createRectangularGridGraph(300, 300, 3, 3, 10, 10.0);
    AccessibilityGraphImpl room2 =
        GraphFactory.createRectangularGridGraph(300, 300, 3, 3, 10, 400.0);

    room1.copyFrom(room2);
    Location vertex1 = room1.getNearestLocation(new Point2D.Float(160, 310));
    Location vertex2 = room1.getNearestLocation(new Point2D.Float(160, 450));

    System.out.println(vertex1);
    System.out.println(vertex2);

    room1.addAccessibilityRelation(vertex1, vertex2);

    new GraphGUI(room1);

    room1.write("src/main/resources/graphs/2rooms.txt");

    room1.writeGrid("src/main/resources/grids/2rooms.txt");
  }
 private double getCost(Location[] array, int i, int j) {
   return graph.getShortestPathLength(array[i], array[j]);
 }