Esempio n. 1
0
static int isAlternating(int nbtot, int nbop, int doflip) {
#ifdef DO_PROFILING
    isAlternatingCount++;
#endif
    
    int i;
    EDGE *e, *elast;
    
    for(i = 0; i<nv; i++){
        int degreeBegin = degree[i];
        e = elast = firstedge[i];
        do {
            if(degreeBegin == degree[e->end]) return 0;
            e = e->next;
        } while(e != elast);
    }
    
    //we need the dual graph
    //nf stores the number of faces
    //(i.e. the number of vertices in the dual graph) (Duh!)
    int nf = make_dual();
    
    for(i = 0; i<nf; i++){
        int sizeBegin = facesize[i];
        e = elast = facestart[i];
        do {
            if(sizeBegin == e->left_facesize) return 0;
            e = e->invers->prev;
        } while(e != elast);
    }
    
    return 1;
}
static int
bitrade_filter(int nbtot, int nbop, int doflip)
{
    // int v1, v2, v3;
    int nf;
    register int i;
    // EDGE *e,*elast;

    nf = make_dual();

    RESETMARKS;

    for(i = 0; i < nf; ++i) {
        // Tag the three edges in this clockwise face:
        facestart[i]->tag = i;
        facestart[i]->invers->prev->tag = i;
        facestart[i]->invers->prev->invers->prev->tag = i;
    }

    // fixme not checking if malloc succeeded
    vertex_colour = (int *) malloc(sizeof(int)*nv);

    row_label = (int *) malloc(sizeof(int)*nf);
    col_label = (int *) malloc(sizeof(int)*nf);
    sym_label = (int *) malloc(sizeof(int)*nf);

    T1 = (triple *) malloc(sizeof(triple)*(nv-2));
    T2 = (triple *) malloc(sizeof(triple)*(nv-2));

    max_row_label = max_col_label = max_sym_label = 0;
    max_entry_index1 = max_entry_index2 = 0;

    for (i = 0; i < nv; ++i) {
        vertex_colour[i] = -1;
        row_label[i] = -1;
        col_label[i] = -1;
        sym_label[i] = -1;
    }

    walk_faces(0, 0);

    // printf("%d %d %d\n", max_row_label, max_col_label, max_sym_label);
    write_integer(max_row_label);
    write_integer(max_col_label);
    write_integer(max_sym_label);

    assert(nv - 2 == max_entry_index1);
    assert(nv - 2 == max_entry_index2);

    // printf("%d\n", nv - 2);
    write_integer(nv - 2);
    for (i = 0; i < max_entry_index1; ++i) {
      // printf("%d %d %d\n", T1[i].x, T1[i].y, T1[i].z);
      write_integer(T1[i].x);
      write_integer(T1[i].y);
      write_integer(T1[i].z);
    }
    // printf("%d\n", nv - 2);
    // write_integer(nv - 2);
    for (i = 0; i < max_entry_index2; ++i) {
        // printf("%d %d %d\n", T2[i].x, T2[i].y, T2[i].z);
      write_integer(T2[i].x);
      write_integer(T2[i].y);
      write_integer(T2[i].z);
    }

    free(vertex_colour);
    free(row_label);
    free(col_label);
    free(sym_label);

    free(T1);
    free(T2);

    return TRUE;
}