public void removeFromSolution() {
    Entry entry = this.selectFromSolution();
    LinkedList<Integer> adjs = new LinkedList<Integer>();
    int node = entry.getLabel();

    if (!this.graph.adjacencyListEmpty(node)) {
      Edge e = this.graph.adjacencyListFirst(node);
      do {
        adjs.add(e.getNode2());
      } while ((e = this.graph.adjacencyNext(node)) != null);

      while (adjs.size() > 0) {
        int adj = adjs.pop();
        // System.out.println("adj: " + adj + " - " + this.candidates_list.size());
        int cont = 0;
        for (Entry c : this.blockeds_list) {
          if ((c.getLabel() == adj) && (this.canEnterCandidate(c))) {
            this.blockeds_list.remove(cont);
            this.candidates_list.add(c);
            break;
          } else {
            cont++;
          }
        }
      }
    }
    this.blockeds_list.add(entry);
  }
  public void removeSelectedFromNeighbors() {
    LinkedList<Integer> adjs = new LinkedList<Integer>();
    int node = this.selected.getLabel();
    // System.out.println("node: " + node + " - " + this.selected_pos + " - " +
    // this.neighbors_list.size() );
    this.neighbors_list.remove(this.selected_pos);
    if (!this.graph.adjacencyListEmpty(node)) {
      Edge e = this.graph.adjacencyListFirst(node);
      do {
        adjs.add(e.getNode2());
      } while ((e = this.graph.adjacencyNext(node)) != null);

      while (adjs.size() > 0) {
        int adj = adjs.pop();
        // System.out.println("adj: " + adj + " - " + this.candidates_list.size());
        int cont = 0;
        for (Entry c : this.blockeds_list) {
          if (c.getLabel() == adj) {
            this.blockeds_list.remove(cont);
            this.candidates_list.add(c);
            break;
          } else {
            cont++;
          }
        }
      }
    }
    this.blockeds_list.add(this.selected);
  }
  public LinkedList<Entry> localSearch() {
    // Deep copy of a list
    this.neighbors_list = new LinkedList<Entry>();
    for (Entry e : this.solution_list) {
      this.neighbors_list.add(e);
    }

    int iteration = 0;

    while (iteration++ < this.max_iterations) {
      this.removeFromSolution();
      if (this.selectFromCandidates() != null) {
        // this.removeSelectedFromCandidates();
        this.removeSelectedFromNeighbors();
        System.out.println("ENTER");
      }
    }

    int cost = 0;
    for (Entry e : this.neighbors_list) {
      cost += e.getCost();
      System.out.println(e.toString());
    }
    System.out.println(cost);

    return (this.neighbors_list);
  }
 public boolean canEnterCandidate(Entry entry) {
   LinkedList<Integer> adjs = new LinkedList<Integer>();
   int node = entry.getLabel();
   if (!this.graph.adjacencyListEmpty(node)) {
     Edge e = this.graph.adjacencyListFirst(node);
     do {
       adjs.add(e.getNode2());
     } while ((e = this.graph.adjacencyNext(node)) != null);
     while (adjs.size() > 0) {
       int adj = adjs.pop();
       for (Entry c : this.neighbors_list) {
         if (c.getLabel() == adj) {
           return false;
         }
       }
     }
   }
   return true;
 }
 public Entry selectFromSolution() {
   int pos = this.rand.nextInt(this.solution_list.size());
   Entry e = this.solution_list.get(pos);
   this.total_cost -= e.getCost();
   return e;
 }