Logo Search packages:      
Sourcecode: cdk version File versions  Download package

static IRing org::openscience::cdk::tools::manipulator::RingSetManipulator::getMostComplexRing ( IRingSet  ringSet ) [inline, static]

Returns the ring with the highest numbers of other rings attached to it.

Parameters:
ringSetThe collection of rings
Returns:
the ring with the highest numbers of other rings attached to it.

Definition at line 173 of file RingSetManipulator.java.

References org::openscience::cdk::interfaces::IAtomContainer::getAtom(), and org::openscience::cdk::interfaces::IAtomContainer::getAtomCount().

Referenced by org::openscience::cdk::layout::StructureDiagramGenerator::layoutRingSet().

      {
            int[] neighbors = new int[ringSet.getAtomContainerCount()];
            IRing ring1, ring2;
            IAtom atom1, atom2;
            int mostComplex = 0, mostComplexPosition = 0;
            /* for all rings in this RingSet */
            for (int i = 0; i < ringSet.getAtomContainerCount(); i++)
            {
                  /* Take each ring */
                  ring1 = (IRing)ringSet.getAtomContainer(i);
                  /* look at each Atom in this ring whether it is part of any other ring */
                  for (int j = 0; j < ring1.getAtomCount(); j++)
                  {
                        atom1 = ring1.getAtom(j);
                        /* Look at each of the other rings in the ringset */
                        for (int k = i + 1; k < ringSet.getAtomContainerCount(); k++)
                        {
                              ring2 = (IRing)ringSet.getAtomContainer(k);
                              if (ring1 != ring2)
                              {
                                    for (int l = 0; l < ring2.getAtomCount(); l++)
                                    {
                                          atom2 = ring2.getAtom(l);
                                          if (atom1 == atom2)
                                          {
                                                neighbors[i]++;                                             
                                                neighbors[k]++;
                                                break;
                                          }
                                    }
                              }
                        }
                  }
            }
            for (int i = 0; i < neighbors.length; i++)
            {
                  if (neighbors[i] > mostComplex)
                  {
                        mostComplex = neighbors[i];
                        mostComplexPosition = i;
                  }
            }
            return (IRing) ringSet.getAtomContainer(mostComplexPosition);
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index