third_party/inchi/INCHI_BASE/src/ichican2.c
AT_RANK nGetMcr2( AT_RANK *nEqArray, AT_RANK n )
{
    AT_RANK n1, n2, mcr; /*  recursive version is much shorter. */

    INCHI_HEAPCHK

    n1 = nEqArray[(int) n];

    if (n == n1)
    {
        return n;
    }

    /*  1st pass: find mcr */
    while (n1 != ( n2 = nEqArray[(int) n1] ))
    {
        n1 = n2;
    }

    /*  2nd pass: copy mcr to each element of the set starting from nEqArray[n] */
    mcr = n1;
    n1 = n;
    while ( /*n1*/ mcr != ( n2 = nEqArray[(int) n1] ))
    {
        nEqArray[(int) n1] = mcr;
        n1 = n2;
    }

    INCHI_HEAPCHK

    return ( mcr );
}
/****************************************************************************
  Get minimal set (class) representative and partially compress the
  partitioning mcr = minimal class representative.
****************************************************************************/
Get minimal set (class) representative and partially compress the
partitioning mcr = minimal class representative.
Get minimal set ( class ) representative and partially compress the partitioning mcr = minimal class representative .
AT_RANK nGetMcr2( AT_RANK *nEqArray, AT_RANK n )
{
    AT_RANK n1, n2, mcr; 
    INCHI_HEAPCHK
    n1 = nEqArray[(int) n];
    if (n == n1)
    {
        return n;
    }
    while (n1 != ( n2 = nEqArray[(int) n1] ))
    {
        n1 = n2;
    }
    mcr = n1;
    n1 = n;
    while (  mcr != ( n2 = nEqArray[(int) n1] ))
    {
        nEqArray[(int) n1] = mcr;
        n1 = n2;
    }
    INCHI_HEAPCHK
    return ( mcr );
}
AT_RANK nGetMcr2 ( AT_RANK * nEqArray , AT_RANK n ) { AT_RANK n1 , n2 , mcr ; INCHI_HEAPCHK n1 = nEqArray [ ( int ) n ] ; if ( n == n1 ) { return n ; } while ( n1 != ( n2 = nEqArray [ ( int ) n1 ] ) ) { n1 = n2 ; } mcr = n1 ; n1 = n ; while ( mcr != ( n2 = nEqArray [ ( int ) n1 ] ) ) { nEqArray [ ( int ) n1 ] = mcr ; n1 = n2 ; } INCHI_HEAPCHK return ( mcr ) ; }
Get minimal set (class) representative and partially compress the
partitioning mcr = minimal class representative.
Get minimal set ( class ) representative and partially compress the partitioning mcr = minimal class representative .
/*  recursive version is much shorter. */ /*  1st pass: find mcr */ /*  2nd pass: copy mcr to each element of the set starting from nEqArray[n] */ /*n1*/