Beispiel #1
0
        /// <summary>
        /// Compute the cycles of the extended smallest set of smallest rings (ESSSR)
        /// for an existing minimum cycle basis. Choosing the set to be canonical
        /// means the set depends on the order of the vertices and may <b>not</b> be
        /// consistent in subgraphs. Given a different order of vertices the same
        /// cycles may not be found.
        /// </summary>
        /// <param name="mcb">minimum cycle basis</param>
        /// <param name="canonical">should the set be canonical (non-unique)</param>
        public TripletShortCycles(MinimumCycleBasis mcb, bool canonical)
        {
            // don't reorder neighbors as the MCB was already done on this ordering
            this.graph     = Copy(mcb.graph);
            this.canonical = canonical;

            // all minimum cycle basis paths belong to the set
            foreach (var path in mcb.GetPaths())
            {
                basis.Add(new Path(Arrays.CopyOf(path, path.Length - 1)));
            }

            // count the number of cycles each vertex belongs to and try to find a
            // cycle though the triple of 'v' and two of it's neighbors
            int ord = graph.Length;

            int[] nCycles = NCycles(basis, ord);
            for (int v = 0; v < ord; v++)
            {
                if (nCycles[v] > 1)
                {
                    FindTriple(v);
                }
            }
        }
Beispiel #2
0
        public virtual void Size_norbornane()
        {
            int[][]           norbornane = Norbornane;
            MinimumCycleBasis mcb        = new MinimumCycleBasis(norbornane);

            int[][] paths = mcb.GetPaths();
            Assert.AreEqual(2, paths.Length);
        }
Beispiel #3
0
        public virtual void Paths_cyclophane_even()
        {
            int[][]           cyclophane_even = CyclophaneEven;
            MinimumCycleBasis mcb             = new MinimumCycleBasis(cyclophane_even);

            int[][] paths = mcb.GetPaths();
            Assert.AreEqual(2, paths.Length);
            int[][] expected = new int[][] { new[] { 3, 2, 1, 0, 5, 4, 3 }, new[] { 3, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3 } };
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(expected, paths));
        }
Beispiel #4
0
        public virtual void Paths_anthracene()
        {
            int[][]           anthracene = Anthracene;
            MinimumCycleBasis mcb        = new MinimumCycleBasis(anthracene);

            int[][] paths = mcb.GetPaths();
            Assert.AreEqual(3, paths.Length);
            int[][] expected = new int[][] { new[] { 5, 0, 1, 2, 3, 4, 5 }, new[] { 9, 6, 5, 4, 7, 8, 9 }, new[] { 9, 8, 10, 11, 12, 13, 9 } };
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(expected, paths));
        }
Beispiel #5
0
        public virtual void Paths_napthalene()
        {
            int[][]           napthalene = Naphthalene;
            MinimumCycleBasis mcb        = new MinimumCycleBasis(napthalene);

            int[][] paths = mcb.GetPaths();
            Assert.AreEqual(2, paths.Length);
            int[][] expected = new int[][] { new[] { 5, 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 7, 8, 9, 6, 5 } };
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(expected, paths));
        }
Beispiel #6
0
        public virtual void Paths_bicyclo()
        {
            int[][]           bicyclo = Bicyclo;
            MinimumCycleBasis mcb     = new MinimumCycleBasis(bicyclo);

            int[][] paths = mcb.GetPaths();
            Assert.AreEqual(2, paths.Length);
            int[][] expected = new int[][] { new[] { 5, 0, 1, 2, 3, 4, 5 }, new[] { 5, 0, 1, 2, 7, 6, 5 } };
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(expected, paths));
        }
Beispiel #7
0
                /// <inheritdoc/>
                public override int[][] Apply(int[][] graph, int length)
                {
                    InitialCycles     ic  = InitialCycles.OfBiconnectedComponent(graph, length);
                    MinimumCycleBasis mcb = new MinimumCycleBasis(ic, true);

                    // As per the old aromaticity detector if the MCB/SSSR is made
                    // of 2 or 3 rings we check all rings for aromaticity - otherwise
                    // we just check the MCB/SSSR
                    if (mcb.Count > 3)
                    {
                        return(mcb.GetPaths());
                    }
                    else
                    {
                        return(All.Apply(graph, length));
                    }
                }