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 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; }