InChI
 
Loading...
Searching...
No Matches
ichi_bns.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2024 IUPAC and InChI Trust
4 */
5
6
7#ifndef _INCHI_BNS_H_
8#define _INCHI_BNS_H_
9
10
11#include "incomdef.h"
12#include "inpdef.h"
13
14
15/*#define FIX_SRU_CYCLIZING_PS_BONDS_IN_BNS 1*/
16
17#define BN_MAX_ALTP 16
18/*#define MAX_VERTEX 1024*/ /* including s; if vert[] has num_vert then MAX_VERTEX has (2*num_vert+2+FIRST_INDX) elements */
19
20/* forward declarations */
21
28
29/* define BNS types */
30
31typedef int Vertex;
32typedef int EdgeIndex;
33typedef int Edge[2]; /* Edge[0] = vertex1, Edge[1] = iedge or -(1+vertex1) if vertex2 = s or t */
34typedef int BNS_IEDGE;
35typedef int EdgeFlow;
36typedef int VertexFlow;
37
38
39#define BNS_EDGE_FORBIDDEN_MASK 1
40#define BNS_EDGE_FORBIDDEN_TEMP 2
41#define BNS_EDGE_FORBIDDEN_TEST 4
42
43/* BNS vertex types */
44
45#define BNS_VERT_TYPE_ATOM 0x0001
46#define BNS_VERT_TYPE_ENDPOINT 0x0002 /* attribute */
47#define BNS_VERT_TYPE_TGROUP 0x0004
48#define BNS_VERT_TYPE_C_POINT 0x0008
49#define BNS_VERT_TYPE_C_GROUP 0x0010
50#define BNS_VERT_TYPE_SUPER_TGROUP 0x0020
51#define BNS_VERT_TYPE_TEMP 0x0040
52
53#define BNS_VERT_TYPE__AUX 0x0080 /* vertex added to build charge substructures */
54#define BNS_VERT_TYPE_C_NEGATIVE 0x0100 /* negative charge group; attribute, should be used with BNS_VERT_TYPE_C_GROUP */
55#define BNS_VERT_TYPE_ACID 0x0200 /* only for this type are allowed paths: t_group-atom-c_group_neg (path_TACN) */
56#define BNS_VERT_TYPE_CARBON_GR 0x0400 /* charge of carbon atom; should be used with BNS_VT_C_POS, BNS_VT_C_NEG */
57#define BNS_VERT_TYPE_METAL_GR 0x0800 /* metal atom group; may be used alone or with BNS_VT_M_POS, BNS_VT_M_NEG */
58
59#define BNS_VERT_TYPE_ANY_GROUP (BNS_VERT_TYPE_TGROUP | BNS_VERT_TYPE_C_GROUP | BNS_VERT_TYPE_SUPER_TGROUP)
60
61/* InChI->Structure */
62
63#define BNS_VT_C_POS BNS_VERT_TYPE_C_GROUP /* positive charge group, heteroat */
64#define BNS_VT_C_NEG (BNS_VERT_TYPE_C_GROUP | BNS_VERT_TYPE_C_NEGATIVE) /* negative charge group, heteroat */
65#define BNS_VT_C_POS_C (BNS_VT_C_POS | BNS_VERT_TYPE_CARBON_GR) /* positive charge group, C, Si, Ge, Sn */
66#define BNS_VT_C_NEG_C (BNS_VT_C_NEG | BNS_VERT_TYPE_CARBON_GR) /* negative charge group, C, Si, Ge, Sn */
67#define BNS_VT_C_POS_M (BNS_VT_C_POS | BNS_VERT_TYPE_METAL_GR) /* positive charge group, metal */
68#define BNS_VT_C_NEG_M (BNS_VT_C_NEG | BNS_VERT_TYPE_METAL_GR) /* negative charge group, metal */
69#define BNS_VT_M_GROUP BNS_VERT_TYPE_METAL_GR /* metal-group, flower vertex */
70
71#define BNS_VT_C_POS_ALL (BNS_VERT_TYPE_SUPER_TGROUP | BNS_VERT_TYPE_C_GROUP) /* supergroup (+) */
72#define BNS_VT_C_NEG_ALL (BNS_VT_C_POS_ALL | BNS_VERT_TYPE_C_NEGATIVE) /* supergroup (-) */
73
74#define BNS_VT_CHRG_STRUCT (BNS_VERT_TYPE__AUX | BNS_VERT_TYPE_TEMP) /* ChargeStruct vertex */
75#define BNS_VT_YVCONNECTOR BNS_VERT_TYPE__AUX /* group connection */
76
77#define IS_BNS_VT_C_OR_CSUPER_GR(X) ((X) & BNS_VT_C_POS)
78#define IS_BNS_VT_C_GR(X) (((X) & BNS_VT_C_POS_ALL) == BNS_VERT_TYPE_C_GROUP)
79#define IS_BNS_VT_CM_GR(X) (((X) & BNS_VT_C_POS_M) == BNS_VT_C_POS_M) /* metal charge group */
80#define IS_BNS_VT_M_GR(X) ((X) == BNS_VERT_TYPE_METAL_GR ) /* metal flower base or vertices */
81#define IS_BNS_VT_YVCONNECTOR(X) (((X) & BNS_VERT_TYPE__AUX) && !((X) & BNS_VERT_TYPE_TEMP))
82#define IS_BNS_VT_CHRG_STRUCT(X) (((X) & BNS_VERT_TYPE__AUX) && ((X) & BNS_VERT_TYPE_TEMP))
83#define IS_BNS_VT_ATOM(X) ((X) & BNS_VERT_TYPE_ATOM)
84
85#define BNS_ADD_SUPER_TGROUP 1 /* reserve one more edge for a t-group to connect to a single super-t-group */
86#define NUM_KINDS_OF_GROUPS 2 /* 1 accounts for t-group kind, one more 1 accounts for c-group kind */
87
88#define BNS_ADD_ATOMS 2 /* max. number of fictitious atoms to add (except t-gtoups) */
89#define BNS_ADD_EDGES 1 /* max. number of edges to add to each atom (except edges to a t-group or c-group) */
90
100
101#define ALTP_PATH_LEN(altp) (altp)[iALTP_PATH_LEN].number /* number of bonds = number of atoms-1*/
102#define ALTP_END_ATOM(altp) (altp)[iALTP_END_ATOM].number
103#define ALTP_START_ATOM(altp) (altp)[iALTP_START_ATOM].number
104#define ALTP_THIS_ATOM_NEIGHBOR(altp,X) (altp)[iALTP_NEIGHBOR+(X)].ineigh[0] /* 0 <= X < path_len */
105#define ALTP_NEXT_ATOM_NEIGHBOR(altp,X) (altp)[iALTP_NEIGHBOR+(X)].ineigh[1]
106#define ALTP_CUR_THIS_ATOM_NEIGHBOR(altp) (altp)[iALTP_NEIGHBOR+ALTP_PATH_LEN(altp)].ineigh[0] /* 0 <= X < path_len */
107#define ALTP_CUR_NEXT_ATOM_NEIGHBOR(altp) (altp)[iALTP_NEIGHBOR+ALTP_PATH_LEN(altp)].ineigh[1]
108#define ALTP_NEXT(altp) (++ALTP_PATH_LEN(altp))
109#define ALTP_PREV(altp) (--ALTP_PATH_LEN(altp))
110#define ALTP_MAY_ADD(altp) (iALTP_NEIGHBOR + (altp)[iALTP_PATH_LEN].number < (altp)[iALTP_MAX_LEN].number)
111#define ALTP_ALLOCATED_LEN(altp) (altp)[iALTP_MAX_LEN].number
112#define ALTP_DELTA(altp) (altp)[iALTP_FLOW].flow[0]
113#define ALTP_OVERFLOW(altp) (altp)[iALTP_FLOW].flow[1]
114
115#define Vertex_s 0
116#define Vertex_t 1
117
118#define NO_VERTEX -2
119#define BLOSSOM_BASE -1
120
121#define ADD_CAPACITY_RADICAL 1 /* add capacity to radical */
122
123#define MAX_BOND_EDGE_CAP 2 /* triple bond */
124#define AROM_BOND_EDGE_CAP 1
125#define MAX_TGROUP_EDGE_CAP 2 /* -NH2 provides max. capacity */
126
127/* edge to s or t */
128#define EDGE_FLOW_ST_MASK 0x3fff /* mask for flow */
129#define EDGE_FLOW_ST_PATH 0x4000 /* mark: the edge belongs to the augmenting path */
130
131/* edges between other vertices */
132/* EdgeFlow WAS defined as S_SHORT; change from S_CHAR made 9-23-2005 */
133#define EDGE_FLOW_MASK 0x3fff /* mask for flow */
134#define EDGE_FLOW_PATH 0x4000 /* mark: the edge belongs to the augmenting path */
135
136/*********************************************************************************/
137#if ( ADD_CAPACITY_RADICAL == 1 ) /* { */
138/* -- do not treat triplets as moving dots -- 2004-02-18 --
139#define MAX_AT_FLOW(X) (((X).chem_bonds_valence - (X).valence)+\
140 ((is_centerpoint_elem((X).el_number)||get_endpoint_valence((X).el_number))?\
141 (((X).radical==RADICAL_DOUBLET)+2*((X).radical==RADICAL_TRIPLET)):0))
142*/
143#define MAX_AT_FLOW(X) (((X).chem_bonds_valence - (X).valence)+\
144 ((is_centerpoint_elem((X).el_number)||get_endpoint_valence((X).el_number))?\
145 (((X).radical==RADICAL_DOUBLET)/*+2*((X).radical==RADICAL_TRIPLET)*/):0))
146
147
148#else /* } ADD_CAPACITY_RADICAL { */
149
150#define MAX_AT_FLOW(X) (((X).chem_bonds_valence - (X).valence)
151
152#endif /* } ADD_CAPACITY_RADICAL */
153
154/**************************** BNS_EDGE ************************************/
155typedef struct BnsEdge {
156 AT_NUMB neighbor1; /* the smaller neighbor */
157 AT_NUMB neighbor12; /* neighbor1 ^ neighbor2 */
158 AT_NUMB neigh_ord[2]; /* ordering number of the neighbor: [0]: at<neighbor, [1]: at>neighbor */
159 EdgeFlow cap; /* Edge capacity */
160 EdgeFlow cap0; /* Initial edge capacity */
161 EdgeFlow flow; /* Edge flow */
162 EdgeFlow flow0; /* Initial flow */
163 /*S_CHAR delta; */
164 S_CHAR pass; /* number of times changed in AugmentEdge() */
167
168/**************************** BNS_ST_EDGE ************************************/
169typedef struct BnsStEdge {
170 VertexFlow cap; /* Edge capacity */
171 VertexFlow cap0; /* Initial edge capacity */
172 VertexFlow flow; /* Edge flow */
173 VertexFlow flow0; /* Initial edge flow */
174 S_CHAR pass; /* number of times changed in AugmentEdge() */
175 /*S_CHAR delta; */
177
178/**************************** BNS_VERTEX ************************************/
179typedef struct BnsVertex {
180
181 BNS_ST_EDGE st_edge; /* 0,1 capacity and flow of the edge to s or t */
182 AT_NUMB type; /* 2, atom, t-group, or added atom: BNS_VERT_TYPE_TGROUP, etc. */
183 AT_NUMB num_adj_edges; /* 3, actual number of neighbors incl. t-groups, excl. s or t */
184 AT_NUMB max_adj_edges; /* 4, including reserved */
185 /*S_CHAR path_neigh[2];*/ /* 5 found path information */
186 /* indexes of Edges */
187 BNS_IEDGE *iedge; /* 6 a pointer to the array of edge indexes adjacent to this vertex */
189
190/**************************** BNS_ALT_PATH ************************************/
196
197/**************************** BN_STRUCT ************************************/
199
200 int num_atoms; /* number of real atoms */
201 /*int len_atoms; */ /* size of filled with real atoms portion of the BNS_VERTEX data */
202 int num_added_atoms; /* number of added fictitious atoms */
203 int nMaxAddAtoms; /* max. number of atoms to add (not including t-groups) */
204 int num_c_groups; /* number of added c-groups */
205 int num_t_groups; /* number of added t-groups */
206 int num_vertices; /* total number currently in effect; includes t-groups and added atoms */
207 /*int len_vertices; */ /* allocation size for BNS_VERTEX data */
208 int num_bonds; /* number of real bonds/2 = number of edges between real atoms */
209 int num_edges; /* number of currently in effect */
210 int num_iedges; /* added 9-16-2005; used only in InChI Reversing */
211 int num_added_edges; /* number of added edges (not including edges to t-groups) */
212 int nMaxAddEdges; /* max. number edges of add to each atom (not including edges to t-groups) */
213
214 int max_vertices; /* allocation size for BNS_VERTEX structures */
215 int max_edges; /* allocation size for edge[]; iedge has length 2*max_edges */
216 int max_iedges; /* allocation size for iedge */
217
218 int tot_st_cap; /* not used, only calculated */
219 int tot_st_flow; /* not used, only calculated */
220
221 int len_alt_path; /* length of alt_path[] */
222
223 int bNotASimplePath; /* alternating path traversed same bond 2 times in opposite directions */
224 int bChangeFlow; /* actually change flow */
225
226 BNS_VERTEX *vert; /* vertices */
227 BNS_EDGE *edge; /* edges */
229 BNS_ALT_PATH *alt_path; /* current altp[] element */
230 BNS_ALT_PATH *altp[BN_MAX_ALTP]; /* keep alt. paths */
231
234
235 INCHI_MODE *pbTautFlags; /* carry it through all functions; never NULL */
236 INCHI_MODE *pbTautFlagsDone; /* carry it through all functions; never NULL */
237 AT_NUMB type_TACN; /* BNS_VERT_TYPE_ACID: if non-zero than only for it path type_T-type_TACN-type_CN allowed */
238 AT_NUMB type_T; /* BNS_VERT_TYPE_TGROUP */
239 AT_NUMB type_CN; /* BNS_VERT_TYPE_C_GROUP | BNS_VERT_TYPE_C_NEGATIVE */
241 /* v. 1.05 */
245
246/********************* BN_DATA *******************************************/
247typedef enum tagBnsRadSrchMode {
248 RAD_SRCH_NORM = 0, /* normal search for normalization */
249 RAD_SRCH_FROM_FICT = 1 /* search from fict. vertices to atoms */
251typedef struct BalancedNetworkData {
252 Vertex *BasePtr; /*[MAX_VERTEX]; pointer toward the base of C(v) */
253 Edge *SwitchEdge; /*[MAX_VERTEX]; a pair of vertices and an edge, implemented here as [*][2] array */
254 S_CHAR *Tree; /*[MAX_VERTEX]; indicates presence in ScanQ, T, T', s-reachability */
255 Vertex *ScanQ; /*[MAX_VERTEX]; contains the set S of s-reachable vertices */
256 int QSize; /* index of the last element added to ScanQ */
257 Vertex *Pu; /*[MAX_VERTEX/2+1] */
258 Vertex *Pv; /*[MAX_VERTEX/2+1] */
259 int max_num_vertices; /* allocation size of all except Pu, Pv */
260 int max_len_Pu_Pv; /* allocation size of Pu and Pv */
261#if ( BNS_RAD_SEARCH == 1 )
262 Vertex *RadEndpoints; /*[MAX_VERTEX*/
267 BRS_MODE bRadSrchMode; /* 1 => connect fict. vertices-radicals to the accessible atoms */
268#endif
270
271/* internal array size */
272#define MAX_ALT_AATG_ARRAY_LEN 127
273/* detected endpoint markings */
274#define AATG_MARK_IN_PATH 1 /* atom in path detected by the BNS */
275#define AATG_MARK_WAS_IN_PATH 2 /* found to be in path before next level */
276/* output */
277#define AATG_MARK_MAIN_TYPE 4 /* atom O-"salt" */
278#define AATG_MARK_OTHER_TYPE 8 /* other atom to be tested */
279
280struct tagTautomerGroupsInfo; /* forward declaration */
281
282/******************** atoms in alt path through taut group ****************/
283typedef struct BN_AtomsAtTautGroup {
288 AT_NUMB *nEndPoint; /* original t-group number */
289 S_CHAR *nMarkedAtom; /* atom mark, see AATG_MARK_* */
293
294
295/************ store changes in flow and capacity to test a bond ****************/
296
308
309
310#define ALT_PATH_MODE_TAUTOM 1
311#define ALT_PATH_MODE_CHARGE 2
312#define ALT_PATH_MODE_4_SALT 3 /* mark alt bonds along the path */
313#define ALT_PATH_MODE_4_SALT2 4 /* mark alt bonds along the path, path to taut. group fict. vertex if exists */
314#define ALT_PATH_MODE_REM2H_CHG 5 /* remove 2 H along alt. path AH-=-BH => A=-=B and change bonds to alternating */
315#define ALT_PATH_MODE_ADD2H_CHG 6 /* add 2 H along alt. path A=-=B => AH-=-BH and change bonds to alternating */
316#define ALT_PATH_MODE_REM2H_TST 7 /* test-remove 2 H along alt. path AH-=-BH => A=-=B; restore changed bonds */
317#define ALT_PATH_MODE_ADD2H_TST 8 /* test-add 2 H along alt. path A=-=B => AH-=-BH; restore changed bonds */
318#define ALT_PATH_MODE_REM_PROTON 9 /* remove proton, adjust bonds, charges, H-counts 2004-03-05 */
319#if ( KETO_ENOL_TAUT == 1 )
320#define ALT_PATH_MODE_TAUTOM_KET 10 /* same as ALT_PATH_MODE_TAUTOM, applies to C=-OH or CH-=O; H may be (-) */
321#endif
322
323#if ( TAUT_PT_22_00 == 1 )
324#define ALT_PATH_MODE_TAUTOM_PT_22_00 11
325#endif
326#if ( TAUT_PT_16_00 == 1 )
327#define ALT_PATH_MODE_TAUTOM_PT_16_00 12
328#endif
329#if ( TAUT_PT_06_00 == 1 )
330#define ALT_PATH_MODE_TAUTOM_PT_06_00 13
331#endif
332#if ( TAUT_PT_39_00 == 1 )
333#define ALT_PATH_MODE_TAUTOM_PT_39_00 14
334#endif
335#if ( TAUT_PT_13_00 == 1 )
336#define ALT_PATH_MODE_TAUTOM_PT_13_00 15
337#endif
338#if ( TAUT_PT_18_00 == 1 )
339#define ALT_PATH_MODE_TAUTOM_PT_18_00 16
340#endif
341
343#define BIT_WORD_MASK ((bitWord)~0)
344
345typedef struct tagNodeSet {
347 int num_set; /* number of sets */
348 int len_set; /* number of bitWords in each set */
350
351
352#ifndef COMPILE_ALL_CPP
353#ifdef __cplusplus
354extern "C" {
355#endif
356#endif
357
358
359/*********************************************************************************
360 bChangeFlow:
361 1 => change flow inside the BNS search
362 3 => change flow inside the BNS search and undo the flow change in the BNS structure here
363 4 => change bonds in the structure according to the flow
364 8 => make altern. bonds in the structure
365
366 Note: (bChangeFlow & 1) == 1 is needed for multiple runs
367**********************************************************************************/
368
369/* "EF" = "Edge Flow" */
370#define BNS_EF_CHNG_FLOW 1 /* change Balanced Network (BN) flow inside the BNS search */
371#define BNS_EF_RSTR_FLOW 2 /* undo BN flow changes after BNS */
372#define BNS_EF_CHNG_RSTR (BNS_EF_CHNG_FLOW | BNS_EF_RSTR_FLOW)
373#define BNS_EF_CHNG_BONDS 4 /* change bonds in the structure according to the BN flow */
374#define BNS_EF_ALTR_BONDS 8 /* make altern. bonds in the structure if the flow has changed */
375#define BNS_EF_UPD_RAD_ORI 16 /* update BN flow0 & Atom radical values:
376 flow0 := flow, radical:=st_cap - st_flow */
377#define BNS_EF_SET_NOSTEREO 32 /* in combination with BNS_EF_ALTR_BONDS only:
378 ALT12 bond cannot be stereogenic */
379#define BNS_EF_UPD_H_CHARGE 64 /* update charges and H-counts according to change flow to c- and t-group vertices */
381#define BNS_EF_SAVE_ALL (BNS_EF_CHNG_FLOW | BNS_EF_CHNG_BONDS | BNS_EF_UPD_RAD_ORI)
382#define BNS_EF_ALTR_NS (BNS_EF_ALTR_BONDS | BNS_EF_SET_NOSTEREO)
383
384#define BNS_EF_RAD_SRCH 128 /* search for rafical paths closures */
385
386
387 struct tagCANON_GLOBALS;
388
389 int NodeSetCreate( struct tagCANON_GLOBALS *pCG, NodeSet *pSet, int n, int L );
390 void NodeSetFree( struct tagCANON_GLOBALS *pCG, NodeSet *pSet );
391
392 int IsNodeSetEmpty( NodeSet *cur_nodes, int k );
393 int DoNodeSetsIntersect( NodeSet *cur_nodes, int k1, int k2 );
394 void AddNodeSet2ToNodeSet1( NodeSet *cur_nodes, int k1, int k2 );
395 void NodeSetFromRadEndpoints( struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, /*Node *v*/ Vertex RadEndpoints[], int num_v );
396 void RemoveFromNodeSet( struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex v[], int num_v );
397 int AddNodesToRadEndpoints( struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex RadEndpoints[], Vertex vRad, int nStart, int nLen );
399
401 struct BN_AtomsAtTautGroup *pAATG, inp_ATOM *at, int num_atoms,
402 int jj2, int jj1, struct tagSaltChargeCandidate *s_candidate, int nNumCandidates,
403 AT_NUMB *nForbiddenAtom, int nNumForbiddenAtoms );
404
405 int bExistsAltPath( struct tagCANON_GLOBALS *pCG,
406 struct BalancedNetworkStructure *pBNS,
407 struct BalancedNetworkData *pBD,
408 struct BN_AtomsAtTautGroup *pAATG,
409 inp_ATOM *at,
410 int num_atoms,
411 int nVertDoubleBond,
412 int nVertSingleBond,
413 int path_type );
414 int bExistsAnyAltPath( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, struct BalancedNetworkData *pBD,
415 inp_ATOM *at, int num_atoms, int nVertDoubleBond, int nVertSingleBond, int path_type );
416 int AddTGroups2BnStruct( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
417 struct tagTautomerGroupsInfo *tgi );
418 int AddSuperTGroup2BnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
419 struct tagTautomerGroupsInfo *tgi );
420 int AddCGroups2BnStruct( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
421 struct tagChargeGroupsInfo *cgi );
422
423 int ReInitBnStruct( struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_at, int bRemoveGroupsFromAtoms );
424 int ReInitBnStructAddGroups( struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms,
425 struct tagTautomerGroupsInfo *tgi, struct tagChargeGroupsInfo *cgi );
428 int DisconnectTestAtomFromTGroup( struct BalancedNetworkStructure *pBNS, int v1, int *pv2, BNS_FLOW_CHANGES *fcd );
429 int DisconnectTGroupFromSuperTGroup( struct BalancedNetworkStructure *pBNS, int v1, int *pv1, int *pv2,
430 BNS_FLOW_CHANGES *fcd );
431 int ReconnectTestAtomToTGroup( struct BalancedNetworkStructure *pBNS, int v1, int v2, int ie, BNS_FLOW_CHANGES *fcd );
432
433 int bIsHardRemHCandidate( inp_ATOM *at, int i, int *cSubType );
434
435 /* moved from ichi_bns.c 2005-08-23 */
436 int RunBalancedNetworkSearch( BN_STRUCT *pBNS, BN_DATA *pBD, int bChangeFlow );
437 BN_STRUCT* AllocateAndInitBnStruct( inp_ATOM *at, int num_atoms, int nMaxAddAtoms, int nMaxAddEdges, int max_altp, int *num_changed_bonds );
440 int ReInitBnStructForMoveableAltBondTest( BN_STRUCT *pBNS, inp_ATOM *at, int num_atoms );
441 void ClearAllBnDataVertices( Vertex *v, Vertex value, int size );
442 void ClearAllBnDataEdges( Edge *e, Vertex value, int size );
444 BN_DATA *AllocateAndInitBnData( int max_num_vertices );
445 int ReInitBnData( BN_DATA *pBD );
446 int SetForbiddenEdges( BN_STRUCT *pBNS, inp_ATOM *at, int num_atoms, int edge_forbidden_mask,
447 int nebend, int *ebend );
448 /* main function: find augmenting path */
449 int BalancedNetworkSearch( BN_STRUCT* pBNS, BN_DATA *pBD, int bChangeFlow );
450
451 int SetRadEndpoints( BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode );
452 int SetRadEndpoints2( struct tagCANON_GLOBALS *pCG, BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode );
453 int RemoveRadEndpoints( BN_STRUCT *pBNS, BN_DATA *pBD, inp_ATOM *at );
454
455 int AddRemoveProtonsRestr( inp_ATOM *at, int num_atoms, int *num_protons_to_add,
456 int nNumProtAddedByRestr, INCHI_MODE bNormalizationFlags,
457 int num_tg, int nChargeRevrs, int nChargeInChI );
458 int AddRemoveIsoProtonsRestr( inp_ATOM *at, int num_atoms, NUM_H num_protons_to_add[], int num_tg );
459
460
461#ifndef COMPILE_ALL_CPP
462#ifdef __cplusplus
463}
464#endif
465#endif
466
467
468
469#endif /* _INCHI_BNS_H_ */
int IsNodeSetEmpty(NodeSet *cur_nodes, int k)
Definition ichican2.c:1166
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:683
int ReInitBnStruct(struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_at, int bRemoveGroupsFromAtoms)
Definition ichi_bns.c:9066
BN_STRUCT * DeAllocateBnStruct(BN_STRUCT *pBNS)
Definition ichi_bns.c:8974
int EdgeIndex
Definition ichi_bns.h:32
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:12020
#define BN_MAX_ALTP
Definition ichi_bns.h:17
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:10743
int AddTGroups2BnStruct(struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms, struct tagTautomerGroupsInfo *tgi)
Definition ichi_bns.c:9173
int VertexFlow
Definition ichi_bns.h:36
struct BalancedNetworkStructure BN_STRUCT
void AddNodeSet2ToNodeSet1(NodeSet *cur_nodes, int k1, int k2)
Definition ichican2.c:1188
int EdgeFlow
Definition ichi_bns.h:35
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:719
BN_DATA * DeAllocateBnData(BN_DATA *pBD)
Definition ichi_bns.c:9595
BN_DATA * AllocateAndInitBnData(int max_num_vertices)
Definition ichi_bns.c:9641
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:12324
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:7482
int RemoveRadEndpoints(BN_STRUCT *pBNS, BN_DATA *pBD, inp_ATOM *at)
Definition ichi_bns.c:7776
int SetRadEndpoints(BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode)
Definition ichi_bns.c:7933
U_SHORT bitWord
Definition ichi_bns.h:342
void NodeSetFromRadEndpoints(struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex RadEndpoints[], int num_v)
Definition ichican2.c:1103
int RunBalancedNetworkSearch(BN_STRUCT *pBNS, BN_DATA *pBD, int bChangeFlow)
Definition ichi_bns.c:653
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:1143
int SetRadEndpoints2(struct tagCANON_GLOBALS *pCG, BN_STRUCT *pBNS, BN_DATA *pBD, BRS_MODE bRadSrchMode)
Definition ichi_bns.c:8028
int bIsHardRemHCandidate(inp_ATOM *at, int i, int *cSubType)
Definition ichi_bns.c:3546
int ReInitBnData(BN_DATA *pBD)
Definition ichi_bns.c:9682
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:1206
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:1966
int Vertex
Definition ichi_bns.h:31
tagAltPathConst
Definition ichi_bns.h:91
@ iALTP_PATH_LEN
Definition ichi_bns.h:94
@ iALTP_MAX_LEN
Definition ichi_bns.h:92
@ iALTP_NEIGHBOR
Definition ichi_bns.h:97
@ iALTP_HDR_LEN
Definition ichi_bns.h:98
@ iALTP_END_ATOM
Definition ichi_bns.h:96
@ iALTP_FLOW
Definition ichi_bns.h:93
@ iALTP_START_ATOM
Definition ichi_bns.h:95
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:8357
void ClearAllBnDataVertices(Vertex *v, Vertex value, int size)
Definition ichi_bns.c:9573
int Edge[2]
Definition ichi_bns.h:33
int BNS_IEDGE
Definition ichi_bns.h:34
int AddCGroups2BnStruct(struct tagCANON_GLOBALS *pCG, struct BalancedNetworkStructure *pBNS, inp_ATOM *at, int num_atoms, struct tagChargeGroupsInfo *cgi)
Definition ichi_bns.c:9370
int ReInitBnStructForMoveableAltBondTest(BN_STRUCT *pBNS, inp_ATOM *at, int num_atoms)
int ReInitBnStructAltPaths(BN_STRUCT *pBNS)
Definition ichi_bns.c:9006
void RemoveFromNodeSet(struct tagCANON_GLOBALS *pCG, NodeSet *cur_nodes, int k, Vertex v[], int num_v)
Definition ichican2.c:1124
tagBnsRadSrchMode
Definition ichi_bns.h:247
@ RAD_SRCH_NORM
Definition ichi_bns.h:248
@ RAD_SRCH_FROM_FICT
Definition ichi_bns.h:249
struct BnsVertex BNS_VERTEX
enum tagBnsRadSrchMode BRS_MODE
void ClearAllBnDataEdges(Edge *e, Vertex value, int size)
Definition ichi_bns.c:9584
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:9026
BN_STRUCT * AllocateAndInitBnStruct(inp_ATOM *at, int num_atoms, int nMaxAddAtoms, int nMaxAddEdges, int max_altp, int *num_changed_bonds)
Definition ichi_bns.c:8747
unsigned short AT_NUMB
Definition ichisize.h:10
signed short NUM_H
Definition ichisize.h:14
unsigned long INCHI_MODE
Definition ichisize.h:25
signed char S_CHAR
Definition inchi_api.h:78
unsigned short U_SHORT
Definition inchi_api.h:85
Definition ichi_bns.h:283
int nNumOthersAdj2Tgroup
Definition ichi_bns.h:287
AT_NUMB * nEndPoint
Definition ichi_bns.h:288
struct tagTautomerGroupsInfo * t_group_info
Definition ichi_bns.h:291
int nAllocLen
Definition ichi_bns.h:284
S_CHAR * nMarkedAtom
Definition ichi_bns.h:289
int nNumMainAdj2Tgroup
Definition ichi_bns.h:286
int nNumFound
Definition ichi_bns.h:285
int * nAtTypeTotals
Definition ichi_bns.h:290
Definition ichi_bns.h:251
int nNumRadEndpoints
Definition ichi_bns.h:263
Vertex * BasePtr
Definition ichi_bns.h:252
S_CHAR * Tree
Definition ichi_bns.h:254
int max_num_vertices
Definition ichi_bns.h:259
int nNumRadEdges
Definition ichi_bns.h:265
int max_len_Pu_Pv
Definition ichi_bns.h:260
Vertex * RadEndpoints
Definition ichi_bns.h:262
Vertex * Pv
Definition ichi_bns.h:258
Edge * SwitchEdge
Definition ichi_bns.h:253
BRS_MODE bRadSrchMode
Definition ichi_bns.h:267
int QSize
Definition ichi_bns.h:256
EdgeIndex * RadEdges
Definition ichi_bns.h:264
Vertex * Pu
Definition ichi_bns.h:257
int nNumRadicals
Definition ichi_bns.h:266
Vertex * ScanQ
Definition ichi_bns.h:255
Definition ichi_bns.h:198
int num_iedges
Definition ichi_bns.h:210
int bNotASimplePath
Definition ichi_bns.h:223
int num_added_atoms
Definition ichi_bns.h:202
INCHI_MODE * pbTautFlagsDone
Definition ichi_bns.h:236
int num_t_groups
Definition ichi_bns.h:205
BNS_IEDGE * iedge
Definition ichi_bns.h:228
int num_bonds
Definition ichi_bns.h:208
int bChangeFlow
Definition ichi_bns.h:224
AT_NUMB type_T
Definition ichi_bns.h:238
int max_iedges
Definition ichi_bns.h:216
int tot_st_cap
Definition ichi_bns.h:218
int num_edges
Definition ichi_bns.h:209
int max_vertices
Definition ichi_bns.h:214
BNS_ALT_PATH * alt_path
Definition ichi_bns.h:229
int num_vertices
Definition ichi_bns.h:206
BNS_ALT_PATH * altp[BN_MAX_ALTP]
Definition ichi_bns.h:230
int num_c_groups
Definition ichi_bns.h:204
int tot_st_flow
Definition ichi_bns.h:219
BNS_EDGE * edge
Definition ichi_bns.h:227
struct tagINCHI_CLOCK * ic
Definition ichi_bns.h:242
AT_NUMB type_CN
Definition ichi_bns.h:239
int num_atoms
Definition ichi_bns.h:200
BNS_VERTEX * vert
Definition ichi_bns.h:226
int num_altp
Definition ichi_bns.h:233
S_CHAR edge_forbidden_mask
Definition ichi_bns.h:240
struct tagInchiTime * ulTimeOutTime
Definition ichi_bns.h:243
int nMaxAddAtoms
Definition ichi_bns.h:203
int len_alt_path
Definition ichi_bns.h:221
int max_edges
Definition ichi_bns.h:215
int num_added_edges
Definition ichi_bns.h:211
INCHI_MODE * pbTautFlags
Definition ichi_bns.h:235
AT_NUMB type_TACN
Definition ichi_bns.h:237
int nMaxAddEdges
Definition ichi_bns.h:212
int max_altp
Definition ichi_bns.h:232
Definition ichi_bns.h:155
EdgeFlow cap0
Definition ichi_bns.h:160
EdgeFlow cap
Definition ichi_bns.h:159
AT_NUMB neighbor1
Definition ichi_bns.h:156
AT_NUMB neigh_ord[2]
Definition ichi_bns.h:158
AT_NUMB neighbor12
Definition ichi_bns.h:157
EdgeFlow flow
Definition ichi_bns.h:161
EdgeFlow flow0
Definition ichi_bns.h:162
S_CHAR forbidden
Definition ichi_bns.h:165
S_CHAR pass
Definition ichi_bns.h:164
Definition ichi_bns.h:169
S_CHAR pass
Definition ichi_bns.h:174
VertexFlow cap
Definition ichi_bns.h:170
VertexFlow cap0
Definition ichi_bns.h:171
VertexFlow flow0
Definition ichi_bns.h:173
VertexFlow flow
Definition ichi_bns.h:172
Definition ichi_bns.h:179
AT_NUMB type
Definition ichi_bns.h:182
BNS_IEDGE * iedge
Definition ichi_bns.h:187
BNS_ST_EDGE st_edge
Definition ichi_bns.h:181
AT_NUMB num_adj_edges
Definition ichi_bns.h:183
AT_NUMB max_adj_edges
Definition ichi_bns.h:184
Definition ichi_bns.h:297
VertexFlow cap_st1
Definition ichi_bns.h:302
EdgeFlow flow
Definition ichi_bns.h:299
VertexFlow cap_st2
Definition ichi_bns.h:305
Vertex v2
Definition ichi_bns.h:304
VertexFlow flow_st2
Definition ichi_bns.h:306
VertexFlow flow_st1
Definition ichi_bns.h:303
BNS_IEDGE iedge
Definition ichi_bns.h:298
EdgeFlow cap
Definition ichi_bns.h:300
Vertex v1
Definition ichi_bns.h:301
Definition ichicant.h:303
Definition ichitaut.h:268
Definition ichitime.h:50
Definition ichitime.h:34
Structure describing an input atom.
Definition inpdef.h:107
Definition ichi_bns.h:345
int len_set
Definition ichi_bns.h:348
bitWord ** bitword
Definition ichi_bns.h:346
int num_set
Definition ichi_bns.h:347
Definition ichitaut.h:279
Definition ichitaut.h:187
Definition ichi_bns.h:191
VertexFlow flow[2]
Definition ichi_bns.h:192
AT_NUMB ineigh[2]
Definition ichi_bns.h:194
Vertex number
Definition ichi_bns.h:193