本文整理汇总了C#中IAtomContainer.getConnectedElectronContainers方法的典型用法代码示例。如果您正苦于以下问题:C# IAtomContainer.getConnectedElectronContainers方法的具体用法?C# IAtomContainer.getConnectedElectronContainers怎么用?C# IAtomContainer.getConnectedElectronContainers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAtomContainer
的用法示例。
在下文中一共展示了IAtomContainer.getConnectedElectronContainers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: breadthFirstSearch
/// <summary> Performs a breadthFirstSearch in an AtomContainer starting with a
/// particular sphere, which usually consists of one start atom. While
/// searching the graph, the method marks each visited atom. It then puts all
/// the atoms connected to the atoms in the given sphere into a new vector
/// which forms the sphere to search for the next recursive method call. All
/// atoms that have been visited are put into a molecule container. This
/// breadthFirstSearch does thus find the connected graph for a given start
/// atom.
///
/// </summary>
/// <param name="ac"> The AtomContainer to be searched
/// </param>
/// <param name="sphere"> A sphere of atoms to start the search with
/// </param>
/// <param name="molecule">A molecule into which all the atoms and bonds are stored
/// that are found during search
/// </param>
public static void breadthFirstSearch(IAtomContainer ac, System.Collections.ArrayList sphere, IMolecule molecule, int max)
{
IAtom atom;
IAtom nextAtom;
System.Collections.ArrayList newSphere = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
for (int f = 0; f < sphere.Count; f++)
{
atom = (IAtom)sphere[f];
//System.out.println("atoms "+ atom + f);
//System.out.println("sphere size "+ sphere.size());
molecule.addAtom(atom);
// first copy LonePair's and SingleElectron's of this Atom as they need
// to be copied too
IElectronContainer[] eContainers = ac.getConnectedElectronContainers(atom);
//System.out.println("found #ec's: " + eContainers.length);
for (int i = 0; i < eContainers.Length; i++)
{
if (!(eContainers[i] is IBond))
{
// ok, no bond, thus LonePair or SingleElectron
// System.out.println("adding non bond " + eContainers[i]);
molecule.addElectronContainer(eContainers[i]);
}
}
// now look at bonds
IBond[] bonds = ac.getConnectedBonds(atom);
for (int g = 0; g < bonds.Length; g++)
{
if (!bonds[g].getFlag(CDKConstants.VISITED))
{
molecule.addBond(bonds[g]);
bonds[g].setFlag(CDKConstants.VISITED, true);
}
nextAtom = bonds[g].getConnectedAtom(atom);
if (!nextAtom.getFlag(CDKConstants.VISITED))
{
// System.out.println("wie oft???");
newSphere.Add(nextAtom);
nextAtom.setFlag(CDKConstants.VISITED, true);
}
}
if (max > -1 && molecule.AtomCount > max)
return;
}
if (newSphere.Count > 0)
{
breadthFirstSearch(ac, newSphere, molecule, max);
}
}