// ############################## START FUNC ############################################ function rings(number_of_atoms, branchlist, mconn) { // Two string vectors are created. For each big loop the strings from path_vector1[atom] are builded on // and sent to neighbour atoms respective path_vector2[neighbour]. After each loop all new values from // path_vector2[n] are put in path_vector1[1] and the path_vector2[n] strings are erased. var path_vector1 = new Array(number_of_atoms); var path_vector2 = new Array(number_of_atoms); for(n=0;n1) connections_mod[n][q]=mconn[n][q]; } } // end dispatch routine. (Saves wanted connections.) // The procedure below until helstring=""; is partly not necessary. It creates an // vector sconn, which is not used. connections_mod can probably be retrieved in // a more simple fashion. Unwanted neighbours are dispatched. var helpstring=connections_mod.join("#"); var sconn=helpstring.split(","); helpstring=sconn.join(" "); sconn=helpstring.split(" "); while(sconn.length>1){ helpstring=sconn.join(" "); sconn=helpstring.split(" "); } sconn=helpstring.split("# "); helpstring=sconn.join("#"); sconn=helpstring.split(" #"); helpstring=sconn.join("#"); if(helpstring.charAt(0)==" ") helpstring=helpstring.substring(1,helpstring.length); if(helpstring.charAt(helpstring.length-1)==" ") helpstring=helpstring.substring(0,helpstring.length-1); sconn=helpstring.split("#"); connections_mod=new Array(number_of_atoms); for(n=0;n0 && path_vector1.join("")=="") break; for(n=0;n"+connections_mod[n][q]+" "; opposite_direction=" "+connections_mod[n][q]+"->"+n+" "; // If the string has been builded in the opposite direction before, it is erased (dropped) // If the string has been builded in the same direction before, it is collected in the variable // ring_atoms. // If the path is no more then 1 bond length from any path atom, it must complete with // that same atom. The value if(p>3 can be explained from any good example. With lower values // chlordecone ends up without rings. With higher values chlordecone get additional rings // Chlordecone has 4 6-rings. If any OTHER neighbour close the ring - dispatch the path logicalv=true; if(p>3 && branchlist.Check(n) && tupp[m].indexOf(opposite_direction)==-1 && tupp[m]!=""){ for(w=0;w"+n+" ")>-1) continue; // The atom before is of course in the path if(tupp[m].indexOf(" "+connections_mod[n][w]+"-")>-1) logicalv=false; } } if(tupp[m].indexOf(opposite_direction)==-1 && logicalv){ if(tupp[m].indexOf(the_actual_direction)==-1){ // If a ring is completed, no other should be fallowed in another direction, therefore IF below. if(tupp[m].indexOf(" "+n+"-")==-1) path_vector2[connections_mod[n][q]]=path_vector2[connections_mod[n][q]]+tupp[m]+the_actual_direction+"#"; } else{ if(tupp[m].indexOf(the_actual_direction)==0) ring_atoms = ring_atoms+tupp[m]+"#"; } } } } } } for(n=0;n