third_party/inchi/INCHI_BASE/src/ichican2.c
void RenumberTheGraph( int n,
                       NEIGH_LIST *NeighList,
                       AT_NUMB *old2new,
                       AT_NUMB *new2old,
                       S_CHAR *mark,
                       int bDone )
{
    int        i, k, j;
    NEIGH_LIST nl;

    /* renumber neighbors */
    for (i = 0; i < n; i++)
    {
        for (j = 1; j <= NeighList[i][0]; j++)
        {
            NeighList[i][j] = old2new[NeighList[i][j]];
        }
    }

    /* rearrange NeighList in situ using new2old[] */
    for (k = 0; k < n; k++)
    {
        if (mark[k] & bDone)
            continue;
        if (k == ( j = new2old[k] ))
        {
            mark[k] |= bDone;
            continue;
        }
        /* transposition cycle */
        i = k;
        nl = NeighList[k];
        do
        {
            NeighList[i] = NeighList[j];
            mark[i] |= bDone;
            i = j;
        }
        while (k != ( j = new2old[i] ));
        NeighList[i] = nl;
        mark[i] |= bDone;
    }

#ifdef NEVER
    /* rearrange NeighList in situ using old2new[] */
    s = 0;
    for (k = 0; k < n; k++)
    {
        if (mark[k] & bDone)
            continue;
        if (k == ( j = old2new[k] ))
        {
            mark[k] |= bDone;
            continue;
        }
        /* transposition cycle */
        i = k;
        /* NeighList[j] goes to ith position */
        nl2[s] = NeighList[j];
        s ^= 1;
        do
        {
            nl2[s] = NeighList[i];
            NeighList[i] = nl2[s ^= 1];
            mark[i] |= bDone;
            i = j;
            j = old2new[i];
        }
        while (k != ( j = old2new[i] ));
        NeighList[j] = nl2[s ^= 1];
        mark[j] |= bDone;
    }
#endif

}
/* { how to renumber a graph */
/****************************************************************************/
{ how to renumber a graph
{ how to renumber a graph
void RenumberTheGraph( int n,
                       NEIGH_LIST *NeighList,
                       AT_NUMB *old2new,
                       AT_NUMB *new2old,
                       S_CHAR *mark,
                       int bDone )
{
    int        i, k, j;
    NEIGH_LIST nl;
    for (i = 0; i < n; i++)
    {
        for (j = 1; j <= NeighList[i][0]; j++)
        {
            NeighList[i][j] = old2new[NeighList[i][j]];
        }
    }
    for (k = 0; k < n; k++)
    {
        if (mark[k] & bDone)
            continue;
        if (k == ( j = new2old[k] ))
        {
            mark[k] |= bDone;
            continue;
        }
        i = k;
        nl = NeighList[k];
        do
        {
            NeighList[i] = NeighList[j];
            mark[i] |= bDone;
            i = j;
        }
        while (k != ( j = new2old[i] ));
        NeighList[i] = nl;
        mark[i] |= bDone;
    }
#ifdef NEVER
    s = 0;
    for (k = 0; k < n; k++)
    {
        if (mark[k] & bDone)
            continue;
        if (k == ( j = old2new[k] ))
        {
            mark[k] |= bDone;
            continue;
        }
        i = k;
        nl2[s] = NeighList[j];
        s ^= 1;
        do
        {
            nl2[s] = NeighList[i];
            NeighList[i] = nl2[s ^= 1];
            mark[i] |= bDone;
            i = j;
            j = old2new[i];
        }
        while (k != ( j = old2new[i] ));
        NeighList[j] = nl2[s ^= 1];
        mark[j] |= bDone;
    }
#endif
}
void RenumberTheGraph ( int n , NEIGH_LIST * NeighList , AT_NUMB * old2new , AT_NUMB * new2old , S_CHAR * mark , int bDone ) { int i , k , j ; NEIGH_LIST nl ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 1 ; j <= NeighList [ i ] [ 0 ] ; j ++ ) { NeighList [ i ] [ j ] = old2new [ NeighList [ i ] [ j ] ] ; } } for ( k = 0 ; k < n ; k ++ ) { if ( mark [ k ] & bDone ) continue ; if ( k == ( j = new2old [ k ] ) ) { mark [ k ] |= bDone ; continue ; } i = k ; nl = NeighList [ k ] ; do { NeighList [ i ] = NeighList [ j ] ; mark [ i ] |= bDone ; i = j ; } while ( k != ( j = new2old [ i ] ) ) ; NeighList [ i ] = nl ; mark [ i ] |= bDone ; } #ifdef NEVER s = 0 ; for ( k = 0 ; k < n ; k ++ ) { if ( mark [ k ] & bDone ) continue ; if ( k == ( j = old2new [ k ] ) ) { mark [ k ] |= bDone ; continue ; } i = k ; nl2 [ s ] = NeighList [ j ] ; s ^= 1 ; do { nl2 [ s ] = NeighList [ i ] ; NeighList [ i ] = nl2 [ s ^= 1 ] ; mark [ i ] |= bDone ; i = j ; j = old2new [ i ] ; } while ( k != ( j = old2new [ i ] ) ) ; NeighList [ j ] = nl2 [ s ^= 1 ] ; mark [ j ] |= bDone ; } #endif }
{ how to renumber a graph
{ how to renumber a graph
/* renumber neighbors */ /* rearrange NeighList in situ using new2old[] */ /* transposition cycle */ /* rearrange NeighList in situ using old2new[] */ /* transposition cycle */ /* NeighList[j] goes to ith position */