Beispiel #1
0
int *getPowerSet(bid_info *current,int *set, int set_size){
	if(set_size>40)
		printf("Set size:%d\n", set_size);
	unsigned int pow_set_size = pow(2, set_size);
	int counter, j;
	int *temp;
	int *answer;
	temp=(int *)malloc(set_size*sizeof(int));
	int size;
	for(counter = 0; counter < pow_set_size; counter++){
		size=0;
		for(j = 0; j < set_size; j++){
			if(counter & (1<<j)){
				temp[j]=set[j];
				size++;
			}
		}
		int temp2=check_connectedness(current,temp,size)+current->bid_value;
		if(temp2>TEMP_MAX_VALUE){
			TEMP_MAX_VALUE=temp2;
			TEMP_GRAPH_SIZE=size;
			answer=temp;
		}
	}
	return answer;
}
Beispiel #2
0
/*
 * Using all of the above functions, this simply checks whether a given
 * purported tree decomposition for some graph actually is one.
 */
bool is_valid_decomposition(tree_decomposition& T, graph& g)
{
  if (!T.is_tree()) {
    std::cerr << "Error: not a tree" << std::endl;
    return false;
  } else if (!check_vertex_coverage(T,g)) {
    return false;
  } else if (!check_edge_coverage(T,g)) {
    std::cerr << "Error: some edge appears in no bag" << std::endl;
    return false;
  } else if (!check_connectedness(T)) {
    std::cerr << "Error: some vertex induces disconnected components in the tree" << std::endl;
    return false;
  }
  else {
    return true;
  }
}