Exemplo n.º 1
0
static int
ref_nonsingle(struct saucy *s, struct coloring *c,
	const int *adj, const int *edg, int cf)
{
	int i, j, k, ret;
	const int cb = cf + c->clen[cf];
	const int size = cb - cf + 1;

	/* Double check for nonsingles which became singles later */
	if (cf == cb) {
		return ref_singleton(s, c, adj, edg, cf);
	}

	/* Establish connected list */
	memcpy(s->junk, c->lab + cf, size * sizeof(int));
	for (i = 0; i < size; ++i) {
		k = s->junk[i];
		for (j = adj[k]; j != adj[k+1]; ++j) {
			data_count(s, c, edg[j]);
		}
	}

	/* Refine the cells we're connected to */
	ret = refine_cell(s, c, ref_nonsingle_cell);

	/* Clear the counts; use lab because junk was overwritten */
	for (i = cf; i <= cb; ++i) {
		k = c->lab[i];
		for (j = adj[k]; j != adj[k+1]; ++j) {
			s->ccount[edg[j]] = 0;
		}
	}

	return ret;
}
Exemplo n.º 2
0
static void
refine(void)
{
	/* Add target to beta */
	beta[nbeta++] = target;
	abmark[target] = 1;

	/* Keep going until refinement stops */
	while (1) {

		/* If discrete, clear alpha and bail */
		if (cells == n) {
			while (nalpha) { abmark[alpha[--nalpha]] = 0; }
			while (nbeta) { abmark[beta[--nbeta]] = 0; }
			break;
		}

		/* Look for something else to refine on */
		if (nbeta) {
			front = beta[--nbeta];
		}
		else if (nalpha) {
			front = alpha[--nalpha];
		}
		else break;
		abmark[front] = 0;

		/* Perform the appropriate refinement operation */
		if (ptn[front] <= lev) {
			ref_singleton(lab[front]);
		}
		else {
			ref_nonsingle(front, front + clen[front]);
		}
	}
}
Exemplo n.º 3
0
static int
ref_singleton_undirected(struct saucy *s, struct coloring *c, int cf)
{
	return ref_singleton(s, c, s->adj, s->edg, cf);
}