-conflict_found:
- /* We had a conflict. Generate next set */
- if (which[all_size-curr_size+1] == all_size-curr_size+1) {
- curr_size--;
- for (i=0; i<curr_size; ++i)
- which[all_size-curr_size+i] = i;
- } else {
- int redo = 1;
- while (redo) {
- int pos = all_size;
- do {
- pos--;
- } while (!(which[pos] = (which[pos]+1) % all_size));
-
- for (i=pos+1; i<all_size; ++i)
- which[i] = MIN(which[i-1]+1, all_size-1);
-
- redo = 0;
- for (i=all_size-curr_size; i<all_size-1; ++i)
- if (which[i]>=which[i+1]) {
- redo = 1;
- break;
- }
+
+
+ /* now compute the best set out of the unsafe nodes*/
+ best = bitset_alloca(unsafe_count);
+
+ if (unsafe_count > MIS_HEUR_TRIGGER) {
+ /* Heuristic: Greedy trial and error form index 0 to unsafe_count-1 */
+ for (i=0; i<unsafe_count; ++i) {
+ bitset_set(best, i);
+ /* check if it is a stable set */
+ for (o=bitset_next_set(best, 0); o!=-1 && o<=i; o=bitset_next_set(best, o+1))
+ if (qnode_are_conflicting(qn, unsafe[i], unsafe[o])) {
+ bitset_clear(best, i); /* clear the bit and try next one */
+ break;
+ }
+ }
+ /* compute the weight */
+ bitset_foreach(best, pos)
+ best_weight += unsafe_costs[pos];
+ } else {
+ /* Exact Algorithm: Brute force */
+ curr = bitset_alloca(unsafe_count);
+ bitset_set_all(curr);
+ while (!bitset_is_empty(curr)) {
+ /* check if curr is a stable set */
+ for (i=bitset_next_set(curr, 0); i!=-1; i=bitset_next_set(curr, i+1))
+ for (o=bitset_next_set(curr, i); o!=-1; o=bitset_next_set(curr, o+1)) /* !!!!! difference to ou_max_ind_set_costs(): NOT (curr, i+1) */
+ if (qnode_are_conflicting(qn, unsafe[i], unsafe[o]))
+ goto no_stable_set;
+
+ /* if we arrive here, we have a stable set */
+ /* compute the weight of the stable set*/
+ curr_weight = 0;
+ bitset_foreach(curr, pos)
+ curr_weight += unsafe_costs[pos];
+
+ /* any better ? */
+ if (curr_weight > best_weight) {
+ best_weight = curr_weight;
+ bitset_copy(best, curr);