third_party/inchi/INCHI_BASE/src/ichirvr7.c
int MarkDisconectedIdenticalToReconnected( InpInChI *pOneInput )
{
    int k1, k2, num_marked = 0;
    int k1max = inchi_max( pOneInput->nNumComponents[INCHI_BAS][TAUT_YES],
                           pOneInput->nNumComponents[INCHI_BAS][TAUT_NON] );

    for (k1 = 0; k1 < k1max; k1++)
    {
        int k2max = inchi_max( pOneInput->nNumComponents[INCHI_REC][TAUT_YES],
                               pOneInput->nNumComponents[INCHI_REC][TAUT_NON] );

        for (k2 = 0; k2 < k2max; k2++)
        {
            int eqM = k1 < pOneInput->nNumComponents[INCHI_BAS][TAUT_YES]
                &&
                k2 < pOneInput->nNumComponents[INCHI_REC][TAUT_YES]
                &&
                !pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nLink /* already linked */
                &&
                !pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].bDeleted
                &&
                pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nNumberOfAtoms
                &&
                pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nNumberOfAtoms ==
                pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nNumberOfAtoms
                &&
                !pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].bDeleted
                &&
                !CompareReversedINChI( pOneInput->pInpInChI[INCHI_REC][TAUT_YES] + k2,
                                       pOneInput->pInpInChI[INCHI_BAS][TAUT_YES] + k1,
                                       NULL, NULL );

            int isF1 = k1 < pOneInput->nNumComponents[INCHI_BAS][TAUT_NON]
                &&
                0 == pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].bDeleted
                &&
                0 < pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nNumberOfAtoms
                ;

            int isF2 = k2 < pOneInput->nNumComponents[INCHI_REC][TAUT_NON]
                &&
                0 == pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].bDeleted
                &&
                0 < pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nNumberOfAtoms
                ;

            int eqF = isF1
                &&
                isF2
                &&
                !pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nLink
                &&
                pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nNumberOfAtoms ==
                pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nNumberOfAtoms
                &&
                !CompareReversedINChI( pOneInput->pInpInChI[INCHI_REC][TAUT_NON] + k2,
                                       pOneInput->pInpInChI[INCHI_BAS][TAUT_NON] + k1,
                                       NULL, NULL )
                ;

            if (eqM && ( !isF1 && !isF2 || eqF ))
            {
                pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nLink = -( k2 + 1 );
                pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nLink = ( k1 + 1 );
                if (eqF)
                {
                    pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nLink = -( k2 + 1 );
                    pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nLink = ( k1 + 1 );
                }
                num_marked++;
                break;
                /* equal InChI has been deleted from the disconnected layer, get next k1 */
            }
        }
    }

    return num_marked;
}
/****************************************************************************
 mark Disconnected InChI components that are exactly same as Reconnected ones
 Disconnected will have a negative number of the reconnected component
 Reconnected will have a positive number of the disconnected component
****************************************************************************/
mark Disconnected InChI components that are exactly same as Reconnected ones
Disconnected will have a negative number of the reconnected component
Reconnected will have a positive number of the disconnected component
mark Disconnected InChI components that are exactly same as Reconnected ones Disconnected will have a negative number of the reconnected component Reconnected will have a positive number of the disconnected component
int MarkDisconectedIdenticalToReconnected( InpInChI *pOneInput )
{
    int k1, k2, num_marked = 0;
    int k1max = inchi_max( pOneInput->nNumComponents[INCHI_BAS][TAUT_YES],
                           pOneInput->nNumComponents[INCHI_BAS][TAUT_NON] );
    for (k1 = 0; k1 < k1max; k1++)
    {
        int k2max = inchi_max( pOneInput->nNumComponents[INCHI_REC][TAUT_YES],
                               pOneInput->nNumComponents[INCHI_REC][TAUT_NON] );
        for (k2 = 0; k2 < k2max; k2++)
        {
            int eqM = k1 < pOneInput->nNumComponents[INCHI_BAS][TAUT_YES]
                &&
                k2 < pOneInput->nNumComponents[INCHI_REC][TAUT_YES]
                &&
                !pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nLink 
                &&
                !pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].bDeleted
                &&
                pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nNumberOfAtoms
                &&
                pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nNumberOfAtoms ==
                pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nNumberOfAtoms
                &&
                !pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].bDeleted
                &&
                !CompareReversedINChI( pOneInput->pInpInChI[INCHI_REC][TAUT_YES] + k2,
                                       pOneInput->pInpInChI[INCHI_BAS][TAUT_YES] + k1,
                                       NULL, NULL );
            int isF1 = k1 < pOneInput->nNumComponents[INCHI_BAS][TAUT_NON]
                &&
                0 == pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].bDeleted
                &&
                0 < pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nNumberOfAtoms
                ;
            int isF2 = k2 < pOneInput->nNumComponents[INCHI_REC][TAUT_NON]
                &&
                0 == pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].bDeleted
                &&
                0 < pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nNumberOfAtoms
                ;
            int eqF = isF1
                &&
                isF2
                &&
                !pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nLink
                &&
                pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nNumberOfAtoms ==
                pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nNumberOfAtoms
                &&
                !CompareReversedINChI( pOneInput->pInpInChI[INCHI_REC][TAUT_NON] + k2,
                                       pOneInput->pInpInChI[INCHI_BAS][TAUT_NON] + k1,
                                       NULL, NULL )
                ;
            if (eqM && ( !isF1 && !isF2 || eqF ))
            {
                pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nLink = -( k2 + 1 );
                pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nLink = ( k1 + 1 );
                if (eqF)
                {
                    pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nLink = -( k2 + 1 );
                    pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nLink = ( k1 + 1 );
                }
                num_marked++;
                break;
            }
        }
    }
    return num_marked;
}
int MarkDisconectedIdenticalToReconnected ( InpInChI * pOneInput ) { int k1 , k2 , num_marked = 0 ; int k1max = inchi_max ( pOneInput -> nNumComponents [ INCHI_BAS ] [ TAUT_YES ] , pOneInput -> nNumComponents [ INCHI_BAS ] [ TAUT_NON ] ) ; for ( k1 = 0 ; k1 < k1max ; k1 ++ ) { int k2max = inchi_max ( pOneInput -> nNumComponents [ INCHI_REC ] [ TAUT_YES ] , pOneInput -> nNumComponents [ INCHI_REC ] [ TAUT_NON ] ) ; for ( k2 = 0 ; k2 < k2max ; k2 ++ ) { int eqM = k1 < pOneInput -> nNumComponents [ INCHI_BAS ] [ TAUT_YES ] && k2 < pOneInput -> nNumComponents [ INCHI_REC ] [ TAUT_YES ] && ! pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_YES ] [ k2 ] . nLink && ! pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_YES ] [ k1 ] . bDeleted && pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_YES ] [ k1 ] . nNumberOfAtoms && pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_YES ] [ k1 ] . nNumberOfAtoms == pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_YES ] [ k2 ] . nNumberOfAtoms && ! pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_YES ] [ k2 ] . bDeleted && ! CompareReversedINChI ( pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_YES ] + k2 , pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_YES ] + k1 , NULL , NULL ) ; int isF1 = k1 < pOneInput -> nNumComponents [ INCHI_BAS ] [ TAUT_NON ] && 0 == pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_NON ] [ k1 ] . bDeleted && 0 < pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_NON ] [ k1 ] . nNumberOfAtoms ; int isF2 = k2 < pOneInput -> nNumComponents [ INCHI_REC ] [ TAUT_NON ] && 0 == pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_NON ] [ k2 ] . bDeleted && 0 < pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_NON ] [ k2 ] . nNumberOfAtoms ; int eqF = isF1 && isF2 && ! pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_NON ] [ k2 ] . nLink && pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_NON ] [ k1 ] . nNumberOfAtoms == pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_NON ] [ k2 ] . nNumberOfAtoms && ! CompareReversedINChI ( pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_NON ] + k2 , pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_NON ] + k1 , NULL , NULL ) ; if ( eqM && ( ! isF1 && ! isF2 || eqF ) ) { pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_YES ] [ k1 ] . nLink = - ( k2 + 1 ) ; pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_YES ] [ k2 ] . nLink = ( k1 + 1 ) ; if ( eqF ) { pOneInput -> pInpInChI [ INCHI_BAS ] [ TAUT_NON ] [ k1 ] . nLink = - ( k2 + 1 ) ; pOneInput -> pInpInChI [ INCHI_REC ] [ TAUT_NON ] [ k2 ] . nLink = ( k1 + 1 ) ; } num_marked ++ ; break ; } } } return num_marked ; }
mark Disconnected InChI components that are exactly same as Reconnected ones
Disconnected will have a negative number of the reconnected component
Reconnected will have a positive number of the disconnected component
mark Disconnected InChI components that are exactly same as Reconnected ones Disconnected will have a negative number of the reconnected component Reconnected will have a positive number of the disconnected component
/* already linked */ /* equal InChI has been deleted from the disconnected layer, get next k1 */