private static List <List <int> > LabelAtoms(IAtomContainer atomCont) { List <List <int> > labelList = new List <List <int> >(); for (int i = 0; i < atomCont.Atoms.Count; i++) { LabelContainer labelContainer = LabelContainer.Instance; List <int> label = new List <int>(7); // label.SetSize(7); for (int a = 0; a < 7; a++) { label.Insert(a, 0); } IAtom refAtom = atomCont.Atoms[i]; string atom1Type = refAtom.Symbol; label[0] = labelContainer.GetLabelID(atom1Type); int countNeighbors = 1; var connAtoms = atomCont.GetConnectedAtoms(refAtom); foreach (var negAtom in connAtoms) { string atom2Type = negAtom.Symbol; label[countNeighbors++] = labelContainer.GetLabelID(atom2Type); } BubbleSort(label); labelList.Add(label); } return(labelList); }
/// <summary> /// compGraphNodesCZero is used to build up of the edges of the compatibility graph /// </summary> /// <exception cref="System.IO.IOException"></exception> internal int CompatibilityGraphNodesIfCEdgeIsZero() { int countNodes = 1; var map = new List <string>(); compGraphNodesCZero = new List <int>(); //Initialize the compGraphNodesCZero List LabelContainer labelContainer = LabelContainer.Instance; compGraphNodes.Clear(); for (int i = 0; i < source.Atoms.Count; i++) { for (int j = 0; j < target.Atoms.Count; j++) { IAtom atom1 = source.Atoms[i]; IAtom atom2 = target.Atoms[j]; //You can also check object equal or charge, hydrogen count etc if (string.Equals(atom1.Symbol, atom2.Symbol, StringComparison.OrdinalIgnoreCase) && (!map.Contains(i + "_" + j))) { compGraphNodesCZero.Add(i); compGraphNodesCZero.Add(j); compGraphNodesCZero.Add(labelContainer.GetLabelID(atom1.Symbol)); //i.e C is label 1 compGraphNodesCZero.Add(countNodes); compGraphNodes.Add(i); compGraphNodes.Add(j); compGraphNodes.Add(countNodes++); map.Add(i + "_" + j); } } } map.Clear(); return(countNodes); }