InChI
 
Loading...
Searching...
No Matches
ichi_bns.h
Go to the documentation of this file.
1/*
2 * International Chemical Identifier (InChI)
3 * Version 1
4 * Software version 1.07
5 * April 30, 2024
6 *
7 * MIT License
8 *
9 * Copyright (c) 2024 IUPAC and InChI Trust
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in all
19 * copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28*
29* The InChI library and programs are free software developed under the
30 * auspices of the International Union of Pure and Applied Chemistry (IUPAC).
31 * Originally developed at NIST.
32 * Modifications and additions by IUPAC and the InChI Trust.
33 * Some portions of code were developed/changed by external contributors
34 * (either contractor or volunteer) which are listed in the file
35 * 'External-contributors' included in this distribution.
36 *
37 * info@inchi-trust.org
38 *
39*/
40
41
42#ifndef _INCHI_BNS_H_
43#define _INCHI_BNS_H_
44
45
46#include "incomdef.h"
47#include "inpdef.h"
48
49
50/*#define FIX_SRU_CYCLIZING_PS_BONDS_IN_BNS 1*/
51
52#define BN_MAX_ALTP 16
53/*#define MAX_VERTEX 1024*/ /* including s; if vert[] has num_vert then MAX_VERTEX has (2*num_vert+2+FIRST_INDX) elements */
54
55/* forward declarations */
56
63
64/* define BNS types */
65
66typedef int Vertex;
67typedef int EdgeIndex;
68typedef int Edge[2]; /* Edge[0] = vertex1, Edge[1] = iedge or -(1+vertex1) if vertex2 = s or t */
69typedef int BNS_IEDGE;
70typedef int EdgeFlow;
71typedef int VertexFlow;
72
73
74#define BNS_EDGE_FORBIDDEN_MASK 1
75#define BNS_EDGE_FORBIDDEN_TEMP 2
76#define BNS_EDGE_FORBIDDEN_TEST 4
77
78/* BNS vertex types */
79
80#define BNS_VERT_TYPE_ATOM 0x0001
81#define BNS_VERT_TYPE_ENDPOINT 0x0002 /* attribute */
82#define BNS_VERT_TYPE_TGROUP 0x0004
83#define BNS_VERT_TYPE_C_POINT 0x0008
84#define BNS_VERT_TYPE_C_GROUP 0x0010
85#define BNS_VERT_TYPE_SUPER_TGROUP 0x0020
86#define BNS_VERT_TYPE_TEMP 0x0040
87
88#define BNS_VERT_TYPE__AUX 0x0080 /* vertex added to build charge substructures */
89#define BNS_VERT_TYPE_C_NEGATIVE 0x0100 /* negative charge group; attribute, should be used with BNS_VERT_TYPE_C_GROUP */
90#define BNS_VERT_TYPE_ACID 0x0200 /* only for this type are allowed paths: t_group-atom-c_group_neg (path_TACN) */
91#define BNS_VERT_TYPE_CARBON_GR 0x0400 /* charge of carbon atom; should be used with BNS_VT_C_POS, BNS_VT_C_NEG */
92#define BNS_VERT_TYPE_METAL_GR 0x0800 /* metal atom group; may be used alone or with BNS_VT_M_POS, BNS_VT_M_NEG */
93
94#define BNS_VERT_TYPE_ANY_GROUP (BNS_VERT_TYPE_TGROUP | BNS_VERT_TYPE_C_GROUP | BNS_VERT_TYPE_SUPER_TGROUP)
95
96/* InChI->Structure */
97
98#define BNS_VT_C_POS BNS_VERT_TYPE_C_GROUP /* positive charge group, heteroat */
99#define BNS_VT_C_NEG (BNS_VERT_TYPE_C_GROUP | BNS_VERT_TYPE_C_NEGATIVE) /* negative charge group, heteroat */
100#define BNS_VT_C_POS_C (BNS_VT_C_POS | BNS_VERT_TYPE_CARBON_GR) /* positive charge group, C, Si, Ge, Sn */
101#define BNS_VT_C_NEG_C (BNS_VT_C_NEG | BNS_VERT_TYPE_CARBON_GR) /* negative charge group, C, Si, Ge, Sn */
102#define BNS_VT_C_POS_M (BNS_VT_C_POS | BNS_VERT_TYPE_METAL_GR) /* positive charge group, metal */
103#define BNS_VT_C_NEG_M (BNS_VT_C_NEG | BNS_VERT_TYPE_METAL_GR) /* negative charge group, metal */
104#define BNS_VT_M_GROUP BNS_VERT_TYPE_METAL_GR /* metal-group, flower vertex */
105
106#define BNS_VT_C_POS_ALL (BNS_VERT_TYPE_SUPER_TGROUP | BNS_VERT_TYPE_C_GROUP) /* supergroup (+) */
107#define BNS_VT_C_NEG_ALL (BNS_VT_C_POS_ALL | BNS_VERT_TYPE_C_NEGATIVE) /* supergroup (-) */
108
109#define BNS_VT_CHRG_STRUCT (BNS_VERT_TYPE__AUX | BNS_VERT_TYPE_TEMP) /* ChargeStruct vertex */
110#define BNS_VT_YVCONNECTOR BNS_VERT_TYPE__AUX /* group connection */
111
112#define IS_BNS_VT_C_OR_CSUPER_GR(X) ((X) & BNS_VT_C_POS)
113#define IS_BNS_VT_C_GR(X) (((X) & BNS_VT_C_POS_ALL) == BNS_VERT_TYPE_C_GROUP)
114#define IS_BNS_VT_CM_GR(X) (((X) & BNS_VT_C_POS_M) == BNS_VT_C_POS_M) /* metal charge group */
115#define IS_BNS_VT_M_GR(X) ((X) == BNS_VERT_TYPE_METAL_GR ) /* metal flower base or vertices */
116#define IS_BNS_VT_YVCONNECTOR(X) (((X) & BNS_VERT_TYPE__AUX) && !((X) & BNS_VERT_TYPE_TEMP))
117#define IS_BNS_VT_CHRG_STRUCT(X) (((X) & BNS_VERT_TYPE__AUX) && ((X) & BNS_VERT_TYPE_TEMP))
118#define IS_BNS_VT_ATOM(X) ((X) & BNS_VERT_TYPE_ATOM)
119
120#define BNS_ADD_SUPER_TGROUP 1 /* reserve one more edge for a t-group to connect to a single super-t-group */
121#define NUM_KINDS_OF_GROUPS 2 /* 1 accounts for t-group kind, one more 1 accounts for c-group kind */
122
123#define BNS_ADD_ATOMS 2 /* max. number of fictitious atoms to add (except t-gtoups) */
124#define BNS_ADD_EDGES 1 /* max. number of edges to add to each atom (except edges to a t-group or c-group) */
125
135
136#define ALTP_PATH_LEN(altp) (altp)[iALTP_PATH_LEN].number /* number of bonds = number of atoms-1*/
137#define ALTP_END_ATOM(altp) (altp)[iALTP_END_ATOM].number
138#define ALTP_START_ATOM(altp) (altp)[iALTP_START_ATOM].number
139#define ALTP_THIS_ATOM_NEIGHBOR(altp,X) (altp)[iALTP_NEIGHBOR+(X)].ineigh[0] /* 0 <= X < path_len */
140#define ALTP_NEXT_ATOM_NEIGHBOR(altp,X) (altp)[iALTP_NEIGHBOR+(X)].ineigh[1]
141#define ALTP_CUR_THIS_ATOM_NEIGHBOR(altp) (altp)[iALTP_NEIGHBOR+ALTP_PATH_LEN(altp)].ineigh[0] /* 0 <= X < path_len */
142#define ALTP_CUR_NEXT_ATOM_NEIGHBOR(altp) (altp)[iALTP_NEIGHBOR+ALTP_PATH_LEN(altp)].ineigh[1]
143#define ALTP_NEXT(altp) (++ALTP_PATH_LEN(altp))
144#define ALTP_PREV(altp) (--ALTP_PATH_LEN(altp))
145#define ALTP_MAY_ADD(altp) (iALTP_NEIGHBOR + (altp)[iALTP_PATH_LEN].number < (altp)[iALTP_MAX_LEN].number)
146#define ALTP_ALLOCATED_LEN(altp) (altp)[iALTP_MAX_LEN].number
147#define ALTP_DELTA(altp) (altp)[iALTP_FLOW].flow[0]
148#define ALTP_OVERFLOW(altp) (altp)[iALTP_FLOW].flow[1]
149
150#define Vertex_s 0
151#define Vertex_t 1
152
153#define NO_VERTEX -2
154#define BLOSSOM_BASE -1
155
156#define ADD_CAPACITY_RADICAL 1 /* add capacity to radical */
157
158#define MAX_BOND_EDGE_CAP 2 /* triple bond */
159#define AROM_BOND_EDGE_CAP 1
160#define MAX_TGROUP_EDGE_CAP 2 /* -NH2 provides max. capacity */
161
162/* edge to s or t */
163#define EDGE_FLOW_ST_MASK 0x3fff /* mask for flow */
164#define EDGE_FLOW_ST_PATH 0x4000 /* mark: the edge belongs to the augmenting path */
165
166/* edges between other vertices */
167/* EdgeFlow WAS defined as S_SHORT; change from S_CHAR made 9-23-2005 */
168#define EDGE_FLOW_MASK 0x3fff /* mask for flow */
169#define EDGE_FLOW_PATH 0x4000 /* mark: the edge belongs to the augmenting path */
170
171/*********************************************************************************/
172#if ( ADD_CAPACITY_RADICAL == 1 ) /* { */
173/* -- do not treat triplets as moving dots -- 2004-02-18 --
174#define MAX_AT_FLOW(X) (((X).chem_bonds_valence - (X).valence)+\
175 ((is_centerpoint_elem((X).el_number)||get_endpoint_valence((X).el_number))?\
176 (((X).radical==RADICAL_DOUBLET)+2*((X).radical==RADICAL_TRIPLET)):0))
177*/
178#define MAX_AT_FLOW(X) (((X).chem_bonds_valence - (X).valence)+\
179 ((is_centerpoint_elem((X).el_number)||get_endpoint_valence((X).el_number))?\
180 (((X).radical==RADICAL_DOUBLET)/*+2*((X).radical==RADICAL_TRIPLET)*/):0))
181
182
183#else /* } ADD_CAPACITY_RADICAL { */
184
185#define MAX_AT_FLOW(X) (((X).chem_bonds_valence - (X).valence)
186
187#endif /* } ADD_CAPACITY_RADICAL */
188
189/**************************** BNS_EDGE ************************************/
190typedef struct BnsEdge {
191 AT_NUMB neighbor1; /* the smaller neighbor */
192 AT_NUMB neighbor12; /* neighbor1 ^ neighbor2 */
193 AT_NUMB neigh_ord[2]; /* ordering number of the neighbor: [0]: at<neighbor, [1]: at>neighbor */
194 EdgeFlow cap; /* Edge capacity */
195 EdgeFlow cap0; /* Initial edge capacity */
196 EdgeFlow flow; /* Edge flow */
197 EdgeFlow flow0; /* Initial flow */
198 /*S_CHAR delta; */
199 S_CHAR pass; /* number of times changed in AugmentEdge() */
202
203/**************************** BNS_ST_EDGE ************************************/
204typedef struct BnsStEdge {
205 VertexFlow cap; /* Edge capacity */
206 VertexFlow cap0; /* Initial edge capacity */
207 VertexFlow flow; /* Edge flow */
208 VertexFlow flow0; /* Initial edge flow */
209 S_CHAR pass; /* number of times changed in AugmentEdge() */
210 /*S_CHAR delta; */
212
213/**************************** BNS_VERTEX ************************************/
214typedef struct BnsVertex {
215
216 BNS_ST_EDGE st_edge; /* 0,1 capacity and flow of the edge to s or t */
217 AT_NUMB type; /* 2, atom, t-group, or added atom: BNS_VERT_TYPE_TGROUP, etc. */
218 AT_NUMB num_adj_edges; /* 3, actual number of neighbors incl. t-groups, excl. s or t */
219 AT_NUMB max_adj_edges; /* 4, including reserved */
220 /*S_CHAR path_neigh[2];*/ /* 5 found path information */
221 /* indexes of Edges */
222 BNS_IEDGE *iedge; /* 6 a pointer to the array of edge indexes adjacent to this vertex */
224
225/**************************** BNS_ALT_PATH ************************************/
231
232/**************************** BN_STRUCT ************************************/
234
235 int num_atoms; /* number of real atoms */
236 /*int len_atoms; */ /* size of filled with real atoms portion of the BNS_VERTEX data */
237 int num_added_atoms; /* number of added fictitious atoms */
238 int nMaxAddAtoms; /* max. number of atoms to add (not including t-groups) */
239 int num_c_groups; /* number of added c-groups */
240 int num_t_groups; /* number of added t-groups */
241 int num_vertices; /* total number currently in effect; includes t-groups and added atoms */
242 /*int len_vertices; */ /* allocation size for BNS_VERTEX data */
243 int num_bonds; /* number of real bonds/2 = number of edges between real atoms */
244 int num_edges; /* number of currently in effect */
245 int num_iedges; /* added 9-16-2005; used only in InChI Reversing */
246 int num_added_edges; /* number of added edges (not including edges to t-groups) */
247 int nMaxAddEdges; /* max. number edges of add to each atom (not including edges to t-groups) */
248
249 int max_vertices; /* allocation size for BNS_VERTEX structures */
250 int max_edges; /* allocation size for edge[]; iedge has length 2*max_edges */
251 int max_iedges; /* allocation size for iedge */
252
253 int tot_st_cap; /* not used, only calculated */
254 int tot_st_flow; /* not used, only calculated */
255
256 int len_alt_path; /* length of alt_path[] */
257
258 int bNotASimplePath; /* alternating path traversed same bond 2 times in opposite directions */
259 int bChangeFlow; /* actually change flow */
260
261 BNS_VERTEX *vert; /* vertices */
262 BNS_EDGE *edge; /* edges */
264 BNS_ALT_PATH *alt_path; /* current altp[] element */
265 BNS_ALT_PATH *altp[BN_MAX_ALTP]; /* keep alt. paths */
266
269
270 INCHI_MODE *pbTautFlags; /* carry it through all functions; never NULL */
271 INCHI_MODE *pbTautFlagsDone; /* carry it through all functions; never NULL */
272 AT_NUMB type_TACN; /* BNS_VERT_TYPE_ACID: if non-zero than only for it path type_T-type_TACN-type_CN allowed */
273 AT_NUMB type_T; /* BNS_VERT_TYPE_TGROUP */
274 AT_NUMB type_CN; /* BNS_VERT_TYPE_C_GROUP | BNS_VERT_TYPE_C_NEGATIVE */
276 /* v. 1.05 */
280
281/********************* BN_DATA *******************************************/
282typedef enum tagBnsRadSrchMode {
283 RAD_SRCH_NORM = 0, /* normal search for normalization */
284 RAD_SRCH_FROM_FICT = 1 /* search from fict. vertices to atoms */
286typedef struct BalancedNetworkData {
287 Vertex *BasePtr; /*[MAX_VERTEX]; pointer toward the base of C(v) */
288 Edge *SwitchEdge; /*[MAX_VERTEX]; a pair of vertices and an edge, implemented here as [*][2] array */
289 S_CHAR *Tree; /*[MAX_VERTEX]; indicates presence in ScanQ, T, T', s-reachability */
290 Vertex *ScanQ; /*[MAX_VERTEX]; contains the set S of s-reachable vertices */
291 int QSize; /* index of the last element added to ScanQ */
292 Vertex *Pu; /*[MAX_VERTEX/2+1] */
293 Vertex *Pv; /*[MAX_VERTEX/2+1] */
294 int max_num_vertices; /* allocation size of all except Pu, Pv */
295 int max_len_Pu_Pv; /* allocation size of Pu and Pv */
296#if ( BNS_RAD_SEARCH == 1 )
297 Vertex *RadEndpoints; /*[MAX_VERTEX*/
302 BRS_MODE bRadSrchMode; /* 1 => connect fict. vertices-radicals to the accessible atoms */
303#endif
305
306/* internal array size */
307#define MAX_ALT_AATG_ARRAY_LEN 127
308/* detected endpoint markings */
309#define AATG_MARK_IN_PATH 1 /* atom in path detected by the BNS */
310#define AATG_MARK_WAS_IN_PATH 2 /* found to be in path before next level */
311/* output */
312#define AATG_MARK_MAIN_TYPE 4 /* atom O-"salt" */
313#define AATG_MARK_OTHER_TYPE 8 /* other atom to be tested */
314
315struct tagTautomerGroupsInfo; /* forward declaration */
316
317/******************** atoms in alt path through taut group ****************/
318typedef struct BN_AtomsAtTautGroup {
323 AT_NUMB *nEndPoint; /* original t-group number */
324 S_CHAR *nMarkedAtom; /* atom mark, see AATG_MARK_* */
328
329
330/************ store changes in flow and capacity to test a bond ****************/
331
343
344
345#define ALT_PATH_MODE_TAUTOM 1
346#define ALT_PATH_MODE_CHARGE 2
347#define ALT_PATH_MODE_4_SALT 3 /* mark alt bonds along the path */
348#define ALT_PATH_MODE_4_SALT2 4 /* mark alt bonds along the path, path to taut. group fict. vertex if exists */
349#define ALT_PATH_MODE_REM2H_CHG 5 /* remove 2 H along alt. path AH-=-BH => A=-=B and change bonds to alternating */
350#define ALT_PATH_MODE_ADD2H_CHG 6 /* add 2 H along alt. path A=-=B => AH-=-BH and change bonds to alternating */
351#define ALT_PATH_MODE_REM2H_TST 7 /* test-remove 2 H along alt. path AH-=-BH => A=-=B; restore changed bonds */
352#define ALT_PATH_MODE_ADD2H_TST 8 /* test-add 2 H along alt. path A=-=B => AH-=-BH; restore changed bonds */
353#define ALT_PATH_MODE_REM_PROTON 9 /* remove proton, adjust bonds, charges, H-counts 2004-03-05 */
354#if ( KETO_ENOL_TAUT == 1 )
355#define ALT_PATH_MODE_TAUTOM_KET 10 /* same as ALT_PATH_MODE_TAUTOM, applies to C=-OH or CH-=O; H may be (-) */
356#endif
357
358#if ( TAUT_PT_22_00 == 1 )
359#define ALT_PATH_MODE_TAUTOM_PT_22_00 11
360#endif
361#if ( TAUT_PT_16_00 == 1 )
362#define ALT_PATH_MODE_TAUTOM_PT_16_00 12
363#endif
364#if ( TAUT_PT_06_00 == 1 )
365#define ALT_PATH_MODE_TAUTOM_PT_06_00 13
366#endif
367#if ( TAUT_PT_39_00 == 1 )
368#define ALT_PATH_MODE_TAUTOM_PT_39_00 14
369#endif
370#if ( TAUT_PT_13_00 == 1 )
371#define ALT_PATH_MODE_TAUTOM_PT_13_00 15
372#endif
373#if ( TAUT_PT_18_00 == 1 )
374#define ALT_PATH_MODE_TAUTOM_PT_18_00 16
375#endif
376
378#define BIT_WORD_MASK ((bitWord)~0)
379
380typedef struct tagNodeSet {
382 int num_set; /* number of sets */
383 int len_set; /* number of bitWords in each set */
385
386
387#ifndef COMPILE_ALL_CPP
388#ifdef __cplusplus
389extern "C" {
390#endif
391#endif
392
393
394/*********************************************************************************
395 bChangeFlow:
396 1 => change flow inside the BNS search
397 3 => change flow inside the BNS search and undo the flow change in the BNS structure here
398 4 => change bonds in the structure according to the flow
399 8 => make altern. bonds in the structure
400
401 Note: (bChangeFlow & 1) == 1 is needed for multiple runs
402**********************************************************************************/
403
404/* "EF" = "Edge Flow" */
405#define BNS_EF_CHNG_FLOW 1 /* change Balanced Network (BN) flow inside the BNS search */
406#define BNS_EF_RSTR_FLOW 2 /* undo BN flow changes after BNS */
407#define BNS_EF_CHNG_RSTR (BNS_EF_CHNG_FLOW | BNS_EF_RSTR_FLOW)
408#define BNS_EF_CHNG_BONDS 4 /* change bonds in the structure according to the BN flow */
409#define BNS_EF_ALTR_BONDS 8 /* make altern. bonds in the structure if the flow has changed */
410#define BNS_EF_UPD_RAD_ORI 16 /* update BN flow0 & Atom radical values:
411 flow0 := flow, radical:=st_cap - st_flow */
412#define BNS_EF_SET_NOSTEREO 32 /* in combination with BNS_EF_ALTR_BONDS only:
413 ALT12 bond cannot be stereogenic */
414#define BNS_EF_UPD_H_CHARGE 64 /* update charges and H-counts according to change flow to c- and t-group vertices */
416#define BNS_EF_SAVE_ALL (BNS_EF_CHNG_FLOW | BNS_EF_CHNG_BONDS | BNS_EF_UPD_RAD_ORI)
417#define BNS_EF_ALTR_NS (BNS_EF_ALTR_BONDS | BNS_EF_SET_NOSTEREO)
418
419#define BNS_EF_RAD_SRCH 128 /* search for rafical paths closures */
420
421
422 struct tagCANON_GLOBALS;
423
424 int NodeSetCreate( struct tagCANON_GLOBALS *pCG, NodeSet *pSet, int n, int L );
425 void NodeSetFree( struct tagCANON_GLOBALS *pCG, NodeSet *pSet );
426
427 int IsNodeSetEmpty( NodeSet *cur_nodes, int k );
428 int DoNodeSetsIntersect( NodeSet *cur_nodes, int k1, int k2 );
429 void AddNodeSet2ToNodeSet1( NodeSet *cur_nodes, int k1, int k2 );
430 void NodeSetFromRadEndpoints( struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, /*Node *v*/ Vertex RadEndpoints[], int num_v );
431 void RemoveFromNodeSet( struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex v[], int num_v );
432 int AddNodesToRadEndpoints( struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex RadEndpoints[], Vertex vRad, int nStart, int nLen );
434
436 struct BN_AtomsAtTautGroup *pAATG, inp_ATOM *at, int num_atoms,
437 int jj2, int jj1, struct tagSaltChargeCandidate *s_candidate, int nNumCandidates,
438 AT_NUMB *nForbiddenAtom, int nNumForbiddenAtoms );
439
440 int bExistsAltPath( struct tagCANON_GLOBALS *pCG,
441 struct BalancedNetworkStructure *pBNS,
442 struct BalancedNetworkData *pBD,
443 struct BN_AtomsAtTautGroup *pAATG,
444 inp_ATOM *at,
445 int num_atoms,
446 int nVertDoubleBond,
447 int nVertSingleBond,
448 int path_type );
449 int bExistsAnyAltPath( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD,
450 inp_ATOM *at, int num_atoms, int nVertDoubleBond, int nVertSingleBond, int path_type );
451 int AddTGroups2BnStruct( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
452 struct tagTautomerGroupsInfo *tgi );
453 int AddSuperTGroup2BnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
454 struct tagTautomerGroupsInfo *tgi );
455 int AddCGroups2BnStruct( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
456 struct tagChargeGroupsInfo *cgi );
457
458 int ReInitBnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_at, int bRemoveGroupsFromAtoms );
459 int ReInitBnStructAddGroups( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
460 struct tagTautomerGroupsInfo *tgi, struct tagChargeGroupsInfo *cgi );
463 int DisconnectTestAtomFromTGroup( struct BalancedNetworkStructure *pBNS, int v1, int *pv2, BNS_FLOW_CHANGES *fcd );
464 int DisconnectTGroupFromSuperTGroup( struct BalancedNetworkStructure *pBNS, int v1, int *pv1, int *pv2,
465 BNS_FLOW_CHANGES *fcd );
466 int ReconnectTestAtomToTGroup( struct BalancedNetworkStructure *pBNS, int v1, int v2, int ie, BNS_FLOW_CHANGES *fcd );
467
468 int bIsHardRemHCandidate( inp_ATOM *at, int i, int *cSubType );
469
470 /* moved from ichi_bns.c 2005-08-23 */
471 int RunBalancedNetworkSearch( BN_STRUCT *pBNS, BN_DATA *pBD, int bChangeFlow );
472 BN_STRUCT* AllocateAndInitBnStruct( inp_ATOM *at, int num_atoms, int nMaxAddAtoms, int nMaxAddEdges, int max_altp, int *num_changed_bonds );
475 int ReInitBnStructForMoveableAltBondTest( BN_STRUCT *pBNS, inp_ATOM *at, int num_atoms );
476 void ClearAllBnDataVertices( Vertex *v, Vertex value, int size );
477 void ClearAllBnDataEdges( Edge *e, Vertex value, int size );
479 BN_DATA *AllocateAndInitBnData( int max_num_vertices );
480 int ReInitBnData( BN_DATA *pBD );
481 int SetForbiddenEdges( BN_STRUCT *pBNS, inp_ATOM *at, int num_atoms, int edge_forbidden_mask,
482 int nebend, int *ebend );
483 /* main function: find augmenting path */
484 int BalancedNetworkSearch( BN_STRUCT* pBNS, BN_DATA *pBD, int bChangeFlow );
485
486 int SetRadEndpoints( BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode );
487 int SetRadEndpoints2( struct tagCANON_GLOBALS *pCG, BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode );
488 int RemoveRadEndpoints( BN_STRUCT *pBNS, BN_DATA *pBD, inp_ATOM *at );
489
490 int AddRemoveProtonsRestr( inp_ATOM *at, int num_atoms, int *num_protons_to_add,
491 int nNumProtAddedByRestr, INCHI_MODE bNormalizationFlags,
492 int num_tg, int nChargeRevrs, int nChargeInChI );
493 int AddRemoveIsoProtonsRestr( inp_ATOM *at, int num_atoms, NUM_H num_protons_to_add[], int num_tg );
494
495
496#ifndef COMPILE_ALL_CPP
497#ifdef __cplusplus
498}
499#endif
500#endif
501
502
503
504#endif /* _INCHI_BNS_H_ */
int IsNodeSetEmpty(NodeSet *cur_nodes, int k)
Definition ichican2.c:1201
int nExists2AtMoveAltPath(struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD, struct BN_AtomsAtTautGroup *pAATG, inp_ATOM *at, int num_atoms, int jj2, int jj1, struct tagSaltChargeCandidate *s_candidate, int nNumCandidates, AT_NUMB *nForbiddenAtom, int nNumForbiddenAtoms)
struct BnsEdge BNS_EDGE
int NodeSetCreate(struct tagCANON_GLOBALS *pCG, NodeSet *pSet, int n, int L)
Definition ichican2.c:718
int ReInitBnStruct(struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_at, int bRemoveGroupsFromAtoms)
Definition ichi_bns.c:9095
BN_STRUCT * DeAllocateBnStruct(BN_STRUCT *pBNS)
Definition ichi_bns.c:9003
int EdgeIndex
Definition ichi_bns.h:67
int AddRemoveProtonsRestr(inp_ATOM *at, int num_atoms, int *num_protons_to_add, int nNumProtAddedByRestr, INCHI_MODE bNormalizationFlags, int num_tg, int nChargeRevrs, int nChargeInChI)
Definition ichi_bns.c:12048
#define BN_MAX_ALTP
Definition ichi_bns.h:52
struct BnsStEdge BNS_ST_EDGE
union BnsAltPath BNS_ALT_PATH
struct tagBNS_FLOW_CHANGES BNS_FLOW_CHANGES
int BalancedNetworkSearch(BN_STRUCT *pBNS, BN_DATA *pBD, int bChangeFlow)
Definition ichi_bns.c:10772
int AddTGroups2BnStruct(struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms, struct tagTautomerGroupsInfo *tgi)
Definition ichi_bns.c:9202
int VertexFlow
Definition ichi_bns.h:71
struct BalancedNetworkStructure BN_STRUCT
void AddNodeSet2ToNodeSet1(NodeSet *cur_nodes, int k1, int k2)
Definition ichican2.c:1223
int EdgeFlow
Definition ichi_bns.h:70
int AddSuperTGroup2BnStruct(struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms, struct tagTautomerGroupsInfo *tgi)
void NodeSetFree(struct tagCANON_GLOBALS *pCG, NodeSet *pSet)
Definition ichican2.c:754
BN_DATA * DeAllocateBnData(BN_DATA *pBD)
Definition ichi_bns.c:9624
BN_DATA * AllocateAndInitBnData(int max_num_vertices)
Definition ichi_bns.c:9670
struct BalancedNetworkData BN_DATA
int AddRemoveIsoProtonsRestr(inp_ATOM *at, int num_atoms, NUM_H num_protons_to_add[], int num_tg)
Definition ichi_bns.c:12352
int bExistsAnyAltPath(struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD, inp_ATOM *at, int num_atoms, int nVertDoubleBond, int nVertSingleBond, int path_type)
Definition ichi_bns.c:7511
int RemoveRadEndpoints(BN_STRUCT *pBNS, BN_DATA *pBD, inp_ATOM *at)
Definition ichi_bns.c:7805
int SetRadEndpoints(BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode)
Definition ichi_bns.c:7962
U_SHORT bitWord
Definition ichi_bns.h:377
void NodeSetFromRadEndpoints(struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex RadEndpoints[], int num_v)
Definition ichican2.c:1138
int RunBalancedNetworkSearch(BN_STRUCT *pBNS, BN_DATA *pBD, int bChangeFlow)
Definition ichi_bns.c:687
int ReconnectTestAtomToTGroup(struct BalancedNetworkStructure *pBNS, int v1, int v2, int ie, BNS_FLOW_CHANGES *fcd)
int DoNodeSetsIntersect(NodeSet *cur_nodes, int k1, int k2)
Definition ichican2.c:1178
int SetRadEndpoints2(struct tagCANON_GLOBALS *pCG, BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode)
Definition ichi_bns.c:8057
int bIsHardRemHCandidate(inp_ATOM *at, int i, int *cSubType)
Definition ichi_bns.c:3578
int ReInitBnData(BN_DATA *pBD)
Definition ichi_bns.c:9711
int DisconnectTestAtomFromTGroup(struct BalancedNetworkStructure *pBNS, int v1, int *pv2, BNS_FLOW_CHANGES *fcd)
enum tagAltPathConst ALT_CONST
int AddNodesToRadEndpoints(struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex RadEndpoints[], Vertex vRad, int nStart, int nLen)
Definition ichican2.c:1241
struct tagNodeSet NodeSet
struct BN_AtomsAtTautGroup BN_AATG
int SetForbiddenEdges(BN_STRUCT *pBNS, inp_ATOM *at, int num_atoms, int edge_forbidden_mask, int nebend, int *ebend)
Definition ichi_bns.c:2000
int Vertex
Definition ichi_bns.h:66
tagAltPathConst
Definition ichi_bns.h:126
@ iALTP_PATH_LEN
Definition ichi_bns.h:129
@ iALTP_MAX_LEN
Definition ichi_bns.h:127
@ iALTP_NEIGHBOR
Definition ichi_bns.h:132
@ iALTP_HDR_LEN
Definition ichi_bns.h:133
@ iALTP_END_ATOM
Definition ichi_bns.h:131
@ iALTP_FLOW
Definition ichi_bns.h:128
@ iALTP_START_ATOM
Definition ichi_bns.h:130
int bExistsAltPath(struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD, struct BN_AtomsAtTautGroup *pAATG, inp_ATOM *at, int num_atoms, int nVertDoubleBond, int nVertSingleBond, int path_type)
Definition ichi_bns.c:8386
void ClearAllBnDataVertices(Vertex *v, Vertex value, int size)
Definition ichi_bns.c:9602
int Edge[2]
Definition ichi_bns.h:68
int BNS_IEDGE
Definition ichi_bns.h:69
int AddCGroups2BnStruct(struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms, struct tagChargeGroupsInfo *cgi)
Definition ichi_bns.c:9399
int ReInitBnStructForMoveableAltBondTest(BN_STRUCT *pBNS, inp_ATOM *at, int num_atoms)
int ReInitBnStructAltPaths(BN_STRUCT *pBNS)
Definition ichi_bns.c:9035
void RemoveFromNodeSet(struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex v[], int num_v)
Definition ichican2.c:1159
tagBnsRadSrchMode
Definition ichi_bns.h:282
@ RAD_SRCH_NORM
Definition ichi_bns.h:283
@ RAD_SRCH_FROM_FICT
Definition ichi_bns.h:284
struct BnsVertex BNS_VERTEX
enum tagBnsRadSrchMode BRS_MODE
void ClearAllBnDataEdges(Edge *e, Vertex value, int size)
Definition ichi_bns.c:9613
int DisconnectTGroupFromSuperTGroup(struct BalancedNetworkStructure *pBNS, int v1, int *pv1, int *pv2, BNS_FLOW_CHANGES *fcd)
int ReInitBnStructAddGroups(struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms, struct tagTautomerGroupsInfo *tgi, struct tagChargeGroupsInfo *cgi)
Definition ichi_bns.c:9055
BN_STRUCT * AllocateAndInitBnStruct(inp_ATOM *at, int num_atoms, int nMaxAddAtoms, int nMaxAddEdges, int max_altp, int *num_changed_bonds)
Definition ichi_bns.c:8776
unsigned short AT_NUMB
Definition ichisize.h:45
signed short NUM_H
Definition ichisize.h:49
unsigned long INCHI_MODE
Definition ichisize.h:60
signed char S_CHAR
Definition inchi_api.h:113
unsigned short U_SHORT
Definition inchi_api.h:120
Definition ichi_bns.h:318
int nNumOthersAdj2Tgroup
Definition ichi_bns.h:322
AT_NUMB * nEndPoint
Definition ichi_bns.h:323
struct tagTautomerGroupsInfo * t_group_info
Definition ichi_bns.h:326
int nAllocLen
Definition ichi_bns.h:319
S_CHAR * nMarkedAtom
Definition ichi_bns.h:324
int nNumMainAdj2Tgroup
Definition ichi_bns.h:321
int nNumFound
Definition ichi_bns.h:320
int * nAtTypeTotals
Definition ichi_bns.h:325
Definition ichi_bns.h:286
int nNumRadEndpoints
Definition ichi_bns.h:298
Vertex * BasePtr
Definition ichi_bns.h:287
S_CHAR * Tree
Definition ichi_bns.h:289
int max_num_vertices
Definition ichi_bns.h:294
int nNumRadEdges
Definition ichi_bns.h:300
int max_len_Pu_Pv
Definition ichi_bns.h:295
Vertex * RadEndpoints
Definition ichi_bns.h:297
Vertex * Pv
Definition ichi_bns.h:293
Edge * SwitchEdge
Definition ichi_bns.h:288
BRS_MODE bRadSrchMode
Definition ichi_bns.h:302
int QSize
Definition ichi_bns.h:291
EdgeIndex * RadEdges
Definition ichi_bns.h:299
Vertex * Pu
Definition ichi_bns.h:292
int nNumRadicals
Definition ichi_bns.h:301
Vertex * ScanQ
Definition ichi_bns.h:290
Definition ichi_bns.h:233
int num_iedges
Definition ichi_bns.h:245
int bNotASimplePath
Definition ichi_bns.h:258
int num_added_atoms
Definition ichi_bns.h:237
INCHI_MODE * pbTautFlagsDone
Definition ichi_bns.h:271
int num_t_groups
Definition ichi_bns.h:240
BNS_IEDGE * iedge
Definition ichi_bns.h:263
int num_bonds
Definition ichi_bns.h:243
int bChangeFlow
Definition ichi_bns.h:259
AT_NUMB type_T
Definition ichi_bns.h:273
int max_iedges
Definition ichi_bns.h:251
int tot_st_cap
Definition ichi_bns.h:253
int num_edges
Definition ichi_bns.h:244
int max_vertices
Definition ichi_bns.h:249
BNS_ALT_PATH * alt_path
Definition ichi_bns.h:264
int num_vertices
Definition ichi_bns.h:241
BNS_ALT_PATH * altp[BN_MAX_ALTP]
Definition ichi_bns.h:265
int num_c_groups
Definition ichi_bns.h:239
int tot_st_flow
Definition ichi_bns.h:254
BNS_EDGE * edge
Definition ichi_bns.h:262
struct tagINCHI_CLOCK * ic
Definition ichi_bns.h:277
AT_NUMB type_CN
Definition ichi_bns.h:274
int num_atoms
Definition ichi_bns.h:235
BNS_VERTEX * vert
Definition ichi_bns.h:261
int num_altp
Definition ichi_bns.h:268
S_CHAR edge_forbidden_mask
Definition ichi_bns.h:275
struct tagInchiTime * ulTimeOutTime
Definition ichi_bns.h:278
int nMaxAddAtoms
Definition ichi_bns.h:238
int len_alt_path
Definition ichi_bns.h:256
int max_edges
Definition ichi_bns.h:250
int num_added_edges
Definition ichi_bns.h:246
INCHI_MODE * pbTautFlags
Definition ichi_bns.h:270
AT_NUMB type_TACN
Definition ichi_bns.h:272
int nMaxAddEdges
Definition ichi_bns.h:247
int max_altp
Definition ichi_bns.h:267
Definition ichi_bns.h:190
EdgeFlow cap0
Definition ichi_bns.h:195
EdgeFlow cap
Definition ichi_bns.h:194
AT_NUMB neighbor1
Definition ichi_bns.h:191
AT_NUMB neigh_ord[2]
Definition ichi_bns.h:193
AT_NUMB neighbor12
Definition ichi_bns.h:192
EdgeFlow flow
Definition ichi_bns.h:196
EdgeFlow flow0
Definition ichi_bns.h:197
S_CHAR forbidden
Definition ichi_bns.h:200
S_CHAR pass
Definition ichi_bns.h:199
Definition ichi_bns.h:204
S_CHAR pass
Definition ichi_bns.h:209
VertexFlow cap
Definition ichi_bns.h:205
VertexFlow cap0
Definition ichi_bns.h:206
VertexFlow flow0
Definition ichi_bns.h:208
VertexFlow flow
Definition ichi_bns.h:207
Definition ichi_bns.h:214
AT_NUMB type
Definition ichi_bns.h:217
BNS_IEDGE * iedge
Definition ichi_bns.h:222
BNS_ST_EDGE st_edge
Definition ichi_bns.h:216
AT_NUMB num_adj_edges
Definition ichi_bns.h:218
AT_NUMB max_adj_edges
Definition ichi_bns.h:219
Definition ichi_bns.h:332
VertexFlow cap_st1
Definition ichi_bns.h:337
EdgeFlow flow
Definition ichi_bns.h:334
VertexFlow cap_st2
Definition ichi_bns.h:340
Vertex v2
Definition ichi_bns.h:339
VertexFlow flow_st2
Definition ichi_bns.h:341
VertexFlow flow_st1
Definition ichi_bns.h:338
BNS_IEDGE iedge
Definition ichi_bns.h:333
EdgeFlow cap
Definition ichi_bns.h:335
Vertex v1
Definition ichi_bns.h:336
Definition ichicant.h:338
Definition ichitaut.h:303
Definition ichitime.h:85
Definition ichitime.h:69
Definition inpdef.h:110
Definition ichi_bns.h:380
int len_set
Definition ichi_bns.h:383
bitWord ** bitword
Definition ichi_bns.h:381
int num_set
Definition ichi_bns.h:382
Definition ichitaut.h:314
Definition ichitaut.h:222
Definition ichi_bns.h:226
VertexFlow flow[2]
Definition ichi_bns.h:227
AT_NUMB ineigh[2]
Definition ichi_bns.h:229
Vertex number
Definition ichi_bns.h:228