third_party/inchi/INCHI_BASE/src/runichi3.c
void OAD_CollectFragmentBondsAndAtoms(	ORIG_ATOM_DATA  *orig_at_data,
                                        int nforbidden,			/* number of edges forbidden for traversal		*/
                                        int *forbidden_orig,	/* atom nums of forbidden edges					*/
                                                                /* [edge1at1,edge1at2, edge2at1, edge2at2, ... ] */
                                        int *n_fragbonds,
                                        int **fragbonds,
                                        int *n_fragatoms,
                                        int *fragatoms,
                                        int *err,
                                        char *pStrErr)
{
    int i;
    int	max_atoms = orig_at_data->num_inp_atoms;
    int *atnums = NULL;
    subgraf *sg = NULL;
    subgraf_pathfinder *spf = NULL;

    *err = 0;
    atnums = (int *)inchi_calloc(max_atoms, sizeof(int));
    if (!atnums)
    {
        TREAT_ERR(*err, 9045, "Not enough memory");
        goto exit_function;
    }
    for (i = 0; i < max_atoms; i++)
    {
        atnums[i] = orig_at_data->at[i].orig_at_number; /* i+1 normally*/
    }

    sg = subgraf_new(orig_at_data, max_atoms, atnums);
    if (!sg)
    {
        TREAT_ERR(*err, 9045, "Not enough memory");
        goto exit_function;
    }
    spf = subgraf_pathfinder_new(sg, orig_at_data, 0, 0); /* start = end = 0th node */
    if (!spf)
    {
        TREAT_ERR(*err, 9045, "Not enough memory");
        goto exit_function;
    }

    spf->seen[0] = spf->start; 
    spf->nseen = 1;
    *n_fragbonds = 0;
    *n_fragatoms = 0;

    subgraf_pathfinder_run(	spf, 
                            nforbidden, forbidden_orig, /* this corrects cinnectivity of subgraf... */
                            n_fragbonds, fragbonds, 
                            n_fragatoms, fragatoms);


exit_function:
    subgraf_free(sg);
    subgraf_pathfinder_free(spf);
    if (atnums)
    {
        inchi_free(atnums);
    }
    return;
}
/****************************************************************************
 Collect bonds and optionally atoms of fragment
****************************************************************************/
Collect bonds and optionally atoms of fragment
Collect bonds and optionally atoms of fragment
void OAD_CollectFragmentBondsAndAtoms(	ORIG_ATOM_DATA  *orig_at_data,
                                        int nforbidden,			
                                        int *forbidden_orig,	
                                        int *n_fragbonds,
                                        int **fragbonds,
                                        int *n_fragatoms,
                                        int *fragatoms,
                                        int *err,
                                        char *pStrErr)
{
    int i;
    int	max_atoms = orig_at_data->num_inp_atoms;
    int *atnums = NULL;
    subgraf *sg = NULL;
    subgraf_pathfinder *spf = NULL;
    *err = 0;
    atnums = (int *)inchi_calloc(max_atoms, sizeof(int));
    if (!atnums)
    {
        TREAT_ERR(*err, 9045, "Not enough memory");
        goto exit_function;
    }
    for (i = 0; i < max_atoms; i++)
    {
        atnums[i] = orig_at_data->at[i].orig_at_number; 
    }
    sg = subgraf_new(orig_at_data, max_atoms, atnums);
    if (!sg)
    {
        TREAT_ERR(*err, 9045, "Not enough memory");
        goto exit_function;
    }
    spf = subgraf_pathfinder_new(sg, orig_at_data, 0, 0); 
    if (!spf)
    {
        TREAT_ERR(*err, 9045, "Not enough memory");
        goto exit_function;
    }
    spf->seen[0] = spf->start; 
    spf->nseen = 1;
    *n_fragbonds = 0;
    *n_fragatoms = 0;
    subgraf_pathfinder_run(	spf, 
                            nforbidden, forbidden_orig, 
                            n_fragbonds, fragbonds, 
                            n_fragatoms, fragatoms);
exit_function:
    subgraf_free(sg);
    subgraf_pathfinder_free(spf);
    if (atnums)
    {
        inchi_free(atnums);
    }
    return;
}
void OAD_CollectFragmentBondsAndAtoms ( ORIG_ATOM_DATA * orig_at_data , int nforbidden , int * forbidden_orig , int * n_fragbonds , int * * fragbonds , int * n_fragatoms , int * fragatoms , int * err , char * pStrErr ) { int i ; int max_atoms = orig_at_data -> num_inp_atoms ; int * atnums = NULL ; subgraf * sg = NULL ; subgraf_pathfinder * spf = NULL ; * err = 0 ; atnums = ( int * ) inchi_calloc ( max_atoms , sizeof ( int ) ) ; if ( ! atnums ) { TREAT_ERR ( * err , 9045 , " " ) ; goto exit_function ; } for ( i = 0 ; i < max_atoms ; i ++ ) { atnums [ i ] = orig_at_data -> at [ i ] . orig_at_number ; } sg = subgraf_new ( orig_at_data , max_atoms , atnums ) ; if ( ! sg ) { TREAT_ERR ( * err , 9045 , " " ) ; goto exit_function ; } spf = subgraf_pathfinder_new ( sg , orig_at_data , 0 , 0 ) ; if ( ! spf ) { TREAT_ERR ( * err , 9045 , " " ) ; goto exit_function ; } spf -> seen [ 0 ] = spf -> start ; spf -> nseen = 1 ; * n_fragbonds = 0 ; * n_fragatoms = 0 ; subgraf_pathfinder_run ( spf , nforbidden , forbidden_orig , n_fragbonds , fragbonds , n_fragatoms , fragatoms ) ; exit_function : subgraf_free ( sg ) ; subgraf_pathfinder_free ( spf ) ; if ( atnums ) { inchi_free ( atnums ) ; } return ; }
Collect bonds and optionally atoms of fragment
Collect bonds and optionally atoms of fragment
/* number of edges forbidden for traversal		*/ /* atom nums of forbidden edges					*/ /* [edge1at1,edge1at2, edge2at1, edge2at2, ... ] */ /* i+1 normally*/ /* start = end = 0th node */ /* this corrects cinnectivity of subgraf... */