예제 #1
0
        /// <summary>
        /// Create a new generator the given chemical graph.
        /// </summary>
        /// <param name="g">chemical graph</param>
        /// <param name="visitedAt">the index of the atom in the output</param>
        /// <param name="rnums"></param>
        Generator(Graph g, int[] visitedAt, IRingNumbering rnums)
        {
            this.g         = g;
            this.rnums     = rnums;
            this.sb        = new StringBuilder(g.Order * 2);
            this.visitedAt = visitedAt;
            this.tmp       = new int[4];
            this.tokens    = new AtomToken[g.Order];
            this.rings     = new Dictionary <int, IList <RingClosure> >();

            // prepare ring closures and topologies
            Arrays.Fill(visitedAt, -1);
            for (int u = 0; u < g.Order && nVisit < g.Order; u++)
            {
                if (visitedAt[u] < 0)
                {
                    Prepare(u, u);
                }
            }

            if (g.GetFlags(Graph.HAS_EXT_STRO) != 0)
            {
                for (int u = 0; u < g.Order; u++)
                {
                    if (g.TopologyOf(u).Configuration.Type == Configuration.ConfigurationType.ExtendedTetrahedral)
                    {
                        SetAllenalStereo(g, visitedAt, u);
                    }
                }
            }

            // write notation
            nVisit = 0;
            Arrays.Fill(visitedAt, -1);
            for (int u = 0; u < g.Order && nVisit < g.Order; u++)
            {
                if (visitedAt[u] < 0)
                {
                    if (u > 0)
                    {
                        rnums.Reset();
                        Write(u, u, Bond.Dot);
                    }
                    else
                    {
                        Write(u, u, Bond.Implicit);
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Create a new generator the given chemical graph.
 /// </summary>
 /// <param name="g">chemical graph</param>
 /// <param name="rnums"></param>
 public Generator(Graph g, IRingNumbering rnums)
     : this(g, new int[g.Order], rnums)
 {
 }