GSListPtr intersection = node_list_and(this_color->details->candidate_nodes,
intersection = node_list_and(this_color->details->candidate_nodes,
color_resource(resource_t *lh_resource, GSListPtr sorted_rsc, GSListPtr colors){	int lpc = 0;	cl_log(LOG_DEBUG, "Coloring resource");	print_resource(lh_resource, FALSE);		lh_resource->constraints = g_slist_sort(lh_resource->constraints, sort_cons_strength);	cl_log(LOG_DEBUG, "Pre-processing");	//------ Pre-processing	for(; lpc < g_slist_length(lh_resource->constraints); lpc++) {		rsc_constraint_t *constraint = (rsc_constraint_t*)g_slist_nth_data(lh_resource->constraints, lpc);		color_t *other_color = NULL;		color_t *local_color = NULL;		cl_log(LOG_DEBUG, "Processing constraint %d", lpc);		print_cons(constraint, FALSE);		if(constraint->is_placement == FALSE) {			continue;		}		if(constraint->type != rsc_to_rsc) {			continue;		}		if(constraint->rsc_rh == NULL) {			cl_log(LOG_ERR, "rsc_rh was NULL for %s", constraint->id);			continue;		}		other_color = constraint->rsc_rh->color;		local_color = find_color(lh_resource->candidate_colors, other_color);		switch(constraint->strength) {			case must:				/// not yet...				break;				// x * should * should_not = x			case should:				if(constraint->rsc_rh->provisional == FALSE) {					local_color->local_weight = 						local_color->local_weight * 2.0;				}				break;			case should_not:				if(constraint->rsc_rh->provisional == FALSE) {					local_color->local_weight = 						local_color->local_weight * 0.5;				}				break;			case must_not:				   if(constraint->rsc_rh->provisional == FALSE) {					   lh_resource->candidate_colors = g_slist_remove(lh_resource->candidate_colors, local_color);				   }				break;			default:				// error				break;		}	}	// filter out nodes with a negative weight	filter_nodes(lh_resource);  	/* Choose a color from the candidates or,	 *  create a new one if no color is suitable 	 * (this may need modification pending further napkin drawings)	 */	lh_resource->candidate_colors = g_slist_sort(lh_resource->candidate_colors, sort_color_weight);	cl_log(LOG_DEBUG, "Choose a color from %d possibilities", g_slist_length(lh_resource->candidate_colors ));	for(lpc = 0; 	    lpc < g_slist_length(lh_resource->candidate_colors)		    && lh_resource->provisional;	    lpc++) {		color_t *this_color = (color_t*)g_slist_nth_data(lh_resource->candidate_colors, lpc);		print_color(this_color, FALSE);		GSListPtr intersection = node_list_and(this_color->details->candidate_nodes, 						       lh_resource->allowed_nodes);		cl_log(LOG_DEBUG, "Checking the node intersection %d", g_slist_length(intersection));		if(g_slist_length(intersection) != 0) {			// TODO: merge node weights			g_slist_free(this_color->details->candidate_nodes);			this_color->details->candidate_nodes = intersection;			lh_resource->color = this_color;			lh_resource->provisional = FALSE;		}	}  	if(lh_resource->provisional) {		// Create new color		cl_log(LOG_DEBUG, "Create a new color");		current_color = create_color(lh_resource->allowed_nodes);		lh_resource->color = current_color;		lh_resource->provisional = FALSE;	}	cl_log(LOG_DEBUG, "Post-processing");	//------ Post-processing	for(lpc = 0; lpc < g_slist_length(lh_resource->constraints); lpc++) {		rsc_constraint_t *constraint = (rsc_constraint_t*)g_slist_nth_data(lh_resource->constraints, lpc);		color_t *local_color = lh_resource->color;		color_t *other_color = NULL;		if(constraint->is_placement == FALSE) {			continue;		} else if(constraint->type != rsc_to_rsc) {			continue;		}				other_color = find_color(constraint->rsc_rh->candidate_colors,					 local_color);		switch(constraint->strength) {			case must:				if(constraint->rsc_rh->provisional == TRUE) {					constraint->rsc_rh->color = other_color;					constraint->rsc_rh->provisional = FALSE;					color_resource(constraint->rsc_rh, sorted_rsc, colors);				}				// else check for error				break;				// x * should * should_not = x			case should:				/* will be taken care of in the pre-processing stage of coloring rsc_rh				   if(constraint->rsc_rh->provisional == TRUE) {				   other_color->weight = other_color->weight * 2.0;				   }				*/				break;			case should_not:				/* will be taken care of in the pre-processing stage of coloring rsc_rh				   if(constraint->rsc_rh->provisional == TRUE) {				   other_color->weight = other_color->weight * 0.5;				   }				*/				break;			case must_not:				/* will be taken care of in the pre-processing stage of coloring rsc_rh 				   if(constraint->rsc_rh->provisional == FALSE) {				   g_slist_remove(constraint->rsc_rh->candidate_colors, other_color);				   }				*/				if(constraint->rsc_rh->provisional == TRUE) {					// check for error				}				break;			default:				// error				break;		}	}}