Exemplo n.º 1
0
                /// <inheritdoc/>
                public override int[][] Apply(int[][] graph, int length)
                {
                    int       threshold = 684; // see. AllRingsFinder.Threshold.Pubchem_99
                    AllCycles ac        = new AllCycles(graph, Math.Min(length, graph.Length), threshold);

                    return(ac.Completed ? ac.GetPaths() : VertexShort.Apply(graph, length));
                }
Exemplo n.º 2
0
        public virtual void Impractical()
        {
            // k12 - ouch
            AllCycles ac = new AllCycles(RegularPathGraphTest.CompleteGraphOfSize(12), 12, 100);

            Assert.IsFalse(ac.Completed);
        }
Exemplo n.º 3
0
        public virtual void CompletedTest()
        {
            AllCycles ac = new AllCycles(RegularPathGraphTest.CompleteGraphOfSize(4), 4, 100);

            Assert.IsTrue(ac.Completed);
            Assert.AreEqual(7, ac.Count);
        }
Exemplo n.º 4
0
            /// <summary>
            /// Find rings in a biconnected component.
            /// </summary>
            /// <param name="g">adjacency list</param>
            /// <param name="length"></param>
            /// <returns></returns>
            /// <exception cref="IntractableException">computation was not feasible</exception>
            private int[][] FindInFused(int[][] g, int length)
            {
                AllCycles allCycles = new AllCycles(g, Math.Min(g.Length, length), threshold);

                if (!allCycles.Completed)
                {
                    throw new IntractableException("A large number of cycles were being generated and the"
                                                   + " computation was aborted. Please us AllCycles/AllRingsFinder with"
                                                   + " and specify a larger threshold or an alternative cycle set.");
                }
                return(allCycles.GetPaths());
            }
Exemplo n.º 5
0
                /// <inheritdoc/>
                public override int[][] Apply(int[][] graph, int length)
                {
                    int       threshold = 684; // see. AllRingsFinder.Threshold.Pubchem_99
                    AllCycles ac        = new AllCycles(graph, Math.Min(length, graph.Length), threshold);

                    if (!ac.Completed)
                    {
                        throw new IntractableException("A large number of cycles were being generated and the"
                                                       + " computation was aborted. Please use AllCycles/AllRingsFinder with"
                                                       + " and specify a larger threshold or use a " + nameof(ICycleFinder) + " with a fall-back"
                                                       + " to a set unique cycles: e.g. " + nameof(Cycles) + "." + nameof(Cycles.AllOrVertexShortFinder) + ".");
                    }
                    return(ac.GetPaths());
                }
Exemplo n.º 6
0
        public virtual void Rank()
        {
            // given vertices based on degree
            int[][] g = new int[][] { new int [] { 0, 0, 0, 0 }, // 5th
                                      new int [] { 0, 0, 0, 0 }, // 6th
                                      new int [] { 0, 0, 0 },    // 4th
                                      new int [] { 0 },          // 2nd
                                      new int [] { 0, 0 },       // 3rd
                                      new int [] {} // 1st
            };
            var actual = AllCycles.GetRank(g);

            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 4, 5, 3, 1, 2, 0 }, actual));
        }
Exemplo n.º 7
0
        public virtual void K5Paths()
        {
            AllCycles ac = new AllCycles(RegularPathGraphTest.CompleteGraphOfSize(5), 5, 1000);

            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[] { 2, 1, 0, 2 }, new[] { 3, 1, 0, 3 }, new[] { 4, 1, 0, 4 }, new[] { 3, 2, 0, 3 }, new[] { 3, 2, 1, 3 },
                new[] { 3, 2, 1, 0, 3 }, new[] { 3, 2, 0, 1, 3 }, new[] { 4, 2, 0, 4 }, new[] { 4, 2, 1, 4 }, new[] { 4, 2, 1, 0, 4 }, new[] { 4, 2, 0, 1, 4 },
                new[] { 3, 0, 2, 1, 3 }, new[] { 4, 0, 2, 1, 4 }, new[] { 4, 3, 0, 4 }, new[] { 4, 3, 1, 4 }, new[] { 4, 3, 1, 0, 4 }, new[] { 4, 3, 0, 1, 4 },
                new[] { 4, 3, 2, 4 }, new[] { 4, 3, 2, 0, 4 }, new[] { 4, 3, 2, 1, 4 }, new[] { 4, 3, 2, 1, 0, 4 }, new[] { 4, 3, 2, 0, 1, 4 },
                new[] { 4, 3, 0, 2, 4 }, new[] { 4, 3, 1, 2, 4 }, new[] { 4, 3, 0, 1, 2, 4 }, new[] { 4, 3, 1, 0, 2, 4 }, new[] { 4, 3, 0, 2, 1, 4 },
                new[] { 4, 3, 1, 2, 0, 4 }, new[] { 4, 0, 3, 1, 4 }, new[] { 4, 0, 3, 2, 4 }, new[] { 4, 0, 3, 2, 1, 4 }, new[] { 4, 0, 3, 1, 2, 4 },
                new[] { 4, 1, 3, 2, 4 }, new[] { 4, 1, 3, 2, 0, 4 }, new[] { 4, 1, 3, 0, 2, 4 }, new[] { 4, 0, 1, 3, 2, 4 }, new[] { 4, 1, 0, 3, 2, 4 }
            },
                              ac.GetPaths()));
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            // convert the molecule to adjacency list - may be redundant in future
            IAtomContainer m = TestMoleculeFactory.MakeAlphaPinene();

            int[][] g = GraphUtil.ToAdjList(m);

            // efficient computation/partitioning of the ring systems
            RingSearch rs = new RingSearch(m, g);

            // isolated cycles don't need to be run
            rs.Isolated();

            // process fused systems separately
            foreach (var fused in rs.Fused())
            {
                const int maxDegree = 100;
                // given the fused subgraph, max cycle size is
                // the number of vertices
                AllCycles ac = new AllCycles(GraphUtil.Subgraph(g, fused), fused.Length, maxDegree);
                // cyclic walks
                int[][] paths = ac.GetPaths();
            }
        }
Exemplo n.º 9
0
        public virtual void K5Size()
        {
            AllCycles ac = new AllCycles(RegularPathGraphTest.CompleteGraphOfSize(5), 5, 1000);

            Assert.AreEqual(37, ac.Count);
        }
Exemplo n.º 10
0
        public virtual void VerticesInOrder()
        {
            var vertices = AllCycles.GetVerticesInOrder(new int[] { 4, 3, 1, 2, 0 });

            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 4, 2, 3, 1, 0 }, vertices));
        }
Exemplo n.º 11
0
        public virtual void K7Size()
        {
            AllCycles ac = new AllCycles(RegularPathGraphTest.CompleteGraphOfSize(7), 7, 1000);

            Assert.AreEqual(1172, ac.Count);
        }