static boolean
biplabel(graph *g, int m, int n, graph *h)
/* h := bipartite labelling of g; else return FALSE */
{
	int i,j;
#if MAXN
	int colour[MAXN];
	permutation lab[MAXN];
#else
	DYNALLSTAT(int,colour,colour_sz);
	DYNALLSTAT(permutation,lab,lab_sz);

	DYNALLOC1(int,colour,colour_sz,n,"biplabg");
	DYNALLOC1(permutation,lab,lab_sz,n,"biplabg");
#endif

	if (!twocolouring(g,colour,m,n)) return FALSE;

	j = 0;
	for (i = 0; i < n; ++i) if (colour[i] == 0) lab[j++] = i;
	for (i = 0; i < n; ++i) if (colour[i] == 1) lab[j++] = i;

	updatecan(g,h,lab,0,m,n);

	return TRUE;
}
Exemple #2
0
boolean
isbipartite(graph *g, int m, int n)
/* Test if g is bipartite */
{
#if MAXN
    int colour[MAXN];
#else
    DYNALLSTAT(int,colour,colour_sz);
#endif

    /* if (m == 1) return isbipartite1(g,n);  */

#if !MAXN
    DYNALLOC1(int,colour,colour_sz,n,"isbipartite");
#endif

    return twocolouring(g,colour,m,n);
}