Exemplo n.º 1
0
        public virtual void TestIsolated_SpiroMedium()
        {
            // medium size spiro cyclo hexane like
            int[][] g = new int[][] { new[] { 1, 5 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 0, 4, 7, 8 }, new[] { 7, 10 }, new[] { 5, 6 }, new[] { 5, 9 }, new[] { 8, 10 },
                                      new[] { 6, 9, 12, 13 }, new[] { 12, 15 }, new[] { 10, 11 }, new[] { 10, 14 }, new[] { 13, 15 }, new[] { 11, 14, 17, 18 }, new[] { 17, 20 }, new[] { 15, 16 }, new[] { 15, 19 },
                                      new[] { 18, 20 }, new[] { 16, 19, 22, 23 }, new[] { 22, 25 }, new[] { 20, 21 }, new[] { 20, 24 }, new[] { 23, 25 }, new[] { 21, 24, 27, 28 }, new[] { 27, 30 },
                                      new[]  { 25, 26 }, new[] { 25, 29 }, new[] { 28, 30 }, new[] { 26, 29, 32, 33 }, new[] { 32, 35 }, new[] { 30, 31 }, new[] { 30, 34 }, new[] { 33, 35 },
                                      new[] { 31, 34, 37, 38 }, new[] { 37, 40 }, new[] { 35, 36 }, new[] { 35, 39 }, new[] { 38, 40 }, new[] { 36, 39, 42, 43 }, new[] { 42, 45 }, new[] { 40, 41 },
                                      new[] { 40, 44 }, new[] { 43, 45 }, new[] { 41, 44, 47, 48 }, new[] { 47, 50 }, new[] { 45, 46 }, new[] { 45, 49 }, new[] { 48, 50 }, new[] { 46, 49, 52, 53 },
                                      new[] { 52, 55 }, new[] { 50, 51 }, new[] { 50, 54 }, new[] { 53, 55 }, new[] { 51, 54, 57, 58 }, new[] { 57, 60 }, new[] { 55, 56 }, new[] { 55, 59 }, new[] { 58, 60 },
                                      new[] { 56, 59 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            Assert.AreEqual(12, isolated.Length);
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5 }, isolated[0]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 5, 6, 7, 8, 9, 10 }, isolated[1]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 10, 11, 12, 13, 14, 15 }, isolated[2]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 15, 16, 17, 18, 19, 20 }, isolated[3]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 20, 21, 22, 23, 24, 25 }, isolated[4]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 25, 26, 27, 28, 29, 30 }, isolated[5]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 30, 31, 32, 33, 34, 35 }, isolated[6]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 35, 36, 37, 38, 39, 40 }, isolated[7]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 40, 41, 42, 43, 44, 45 }, isolated[8]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 45, 46, 47, 48, 49, 50 }, isolated[9]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 50, 51, 52, 53, 54, 55 }, isolated[10]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 55, 56, 57, 58, 59, 60 }, isolated[11]));
        }
Exemplo n.º 2
0
        public virtual void TestIsolated_NonCyclic()
        {
            int[][]             g      = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            Assert.IsTrue(Compares.AreDeepEqual(Array.Empty <int>(), search.Cyclic()));
        }
Exemplo n.º 3
0
        public virtual void TestIsolated()
        {
            // cyclohexane like
            int[][]             g      = new int[][] { new[] { 5, 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4, 0 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            Assert.IsTrue(Compares.AreDeepEqual(new int[][] { new[] { 0, 1, 2, 3, 4, 5 } }, search.Isolated()));
        }
Exemplo n.º 4
0
        public virtual void TestToArray()
        {
            BitArray s = new BitArray(7);

            s.Set(0, true);
            s.Set(6, true);
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 6 }, JumboCyclicVertexSearch.ToArray(s)));
        }
Exemplo n.º 5
0
        public virtual void TestIsolated_Empty()
        {
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(Array.Empty <int[]>());

            Assert.IsTrue(Compares.AreDeepEqual(Array.Empty <int>(), search.Cyclic()));
            Assert.IsTrue(Compares.AreDeepEqual(Array.Empty <int[]>(), search.Isolated()));
            Assert.IsTrue(Compares.AreDeepEqual(Array.Empty <int[]>(), search.Fused()));
        }
Exemplo n.º 6
0
        public virtual void TestCyclic_Int()
        {
            // cyclohexane like
            int[][]             g      = new int[][] { new[] { 5, 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4, 0 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            for (int v = 0; v < g.Length; v++)
            {
                Assert.IsTrue(search.Cyclic(v));
            }
        }
Exemplo n.º 7
0
        public virtual void TestFused()
        {
            int[][]             g      = new int[][] { new[] { 1, 5, 6 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4, 7 }, new[] { 3, 5 }, new[] { 0, 4 }, new[] { 0, 7 }, new[] { 6, 3 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            int[][] fused    = search.Fused();
            Assert.AreEqual(0, isolated.Length);
            Assert.AreEqual(1, fused.Length);
            Assert.AreEqual(g.Length, fused[0].Length);
        }
Exemplo n.º 8
0
        public virtual void TestCopy()
        {
            BitArray set = new BitArray(7);

            set.Set(5, true);
            BitArray cpy = JumboCyclicVertexSearch.Copy(set);

            Assert.IsTrue(cpy[5]);
            set.Set(6, true);
            Assert.IsFalse(cpy[6]);
        }
Exemplo n.º 9
0
        public virtual void TestFused_OrthoFused()
        {
            // napthalene like
            int[][]             g      = new int[][] { new[] { 1, 5 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5, 7 }, new[] { 0, 6, 4 }, new[] { 5, 9 }, new[] { 4, 8 }, new[] { 7, 9 }, new[] { 6, 8 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            int[][] fused    = search.Fused();
            Assert.AreEqual(0, isolated.Length);
            Assert.AreEqual(1, fused.Length);
            Assert.AreEqual(g.Length, fused[0].Length);
        }
Exemplo n.º 10
0
        public virtual void TestIsolated_BenzylBenzene()
        {
            // benzylbenzene like
            int[][] g = new int[][] { new[] { 1, 5 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 0, 4, 12 }, new[] { 7, 11 }, new[] { 6, 8 }, new[] { 7, 9, 12 },
                                      new[] { 8, 10 }, new[] { 9, 11 }, new[] { 6, 10 }, new[] { 8, 5 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            Assert.IsTrue(Compares.AreDeepEqual(2, isolated.Length));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5 }, isolated[0]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 6, 7, 8, 9, 10, 11 }, isolated[1]));
        }
Exemplo n.º 11
0
        public virtual void TestIsolated_Spiro()
        {
            // spiro cyclo hexane like
            int[][] g = new int[][] { new[] { 1, 5 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 0, 4, 7, 8 }, new[] { 7, 10 }, new[] { 5, 6 }, new[] { 5, 9 }, new[] { 8, 10 },
                                      new[] { 6, 9 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            Assert.AreEqual(2, isolated.Length);
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5 }, isolated[0]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 5, 6, 7, 8, 9, 10 }, isolated[1]));
        }
Exemplo n.º 12
0
        public virtual void TestCyclic_IntInt()
        {
            int[][]             g      = new int[][] { new[] { 5, 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4, 0, 6 }, new[] { 5 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            Assert.IsTrue(search.Cyclic(0, 1));
            Assert.IsTrue(search.Cyclic(1, 2));
            Assert.IsTrue(search.Cyclic(2, 3));
            Assert.IsTrue(search.Cyclic(3, 4));
            Assert.IsTrue(search.Cyclic(4, 5));
            Assert.IsTrue(search.Cyclic(5, 0));
            Assert.IsFalse(search.Cyclic(5, 6));
        }
Exemplo n.º 13
0
        public virtual void TestIsolated_Biphenyl()
        {
            // biphenyl like
            int[][] g = new int[][] { new[] { 5, 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4, 0, 6 }, new[] { 11, 7, 5 }, new[] { 6, 8 }, new[] { 7, 9 }, new[] { 8, 10 },
                                      new[]  { 9, 11 }, new[] { 10, 7 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, search.Cyclic()));
            int[][] isolated = search.Isolated();
            Assert.IsTrue(Compares.AreDeepEqual(2, isolated.Length));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5 }, isolated[0]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 6, 7, 8, 9, 10, 11 }, isolated[1]));
        }
Exemplo n.º 14
0
        public virtual void TestFused_BiorthoFused()
        {
            // 3 fused rings
            int[][] g = new int[][] { new[] { 1, 5 }, new[] { 0, 2, 10 }, new[] { 3, 13, 1 }, new[] { 2, 4 }, new[] { 3, 5, 7 }, new[] { 0, 6, 4 }, new[] { 5, 9 }, new[] { 4, 8 }, new[] { 7, 9 },
                                      new[] { 6, 8 }, new[] { 1, 11 }, new[] { 10, 12 }, new[] { 11, 13 }, new[] { 2, 12 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            int[][] fused    = search.Fused();
            Assert.AreEqual(0, isolated.Length);
            Assert.AreEqual(1, fused.Length);
            Assert.AreEqual(g.Length, fused[0].Length);
        }
Exemplo n.º 15
0
        public virtual void TestIsolatedFragments()
        {
            // two disconnected cyclohexanes
            int[][] g = new int[][] { new[] { 5, 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4, 0 }, new[] { 11, 7 }, new[] { 6, 8 }, new[] { 7, 9 }, new[] { 8, 10 },
                                      new[] { 9, 11 }, new[] { 10, 7 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, search.Cyclic()));
            int[][] isolated = search.Isolated();
            Assert.AreEqual(2, isolated.Length);
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5 }, isolated[0]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 6, 7, 8, 9, 10, 11 }, isolated[1]));
        }
Exemplo n.º 16
0
        public virtual void TestFused_BiocycloVertexLinked()
        {
            // biocyclooctanylbiocylooctane like
            int[][] g = new int[][] { new[] { 1, 5 }, new[] { 0, 2 }, new[] { 1, 3, 6, 16 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4, 0, 7 }, new[] { 2, 7 }, new[] { 6, 5 }, new[] { 9, 13 },
                                      new[] { 8, 10 }, new[] { 9, 11, 14 }, new[] { 10, 12 }, new[] { 11, 13 }, new[] { 12, 8, 15, 16 }, new[] { 10, 15 }, new[] { 14, 13 }, new[] { 13, 2 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            int[][] fused    = search.Fused();
            Assert.AreEqual(0, isolated.Length);
            Assert.AreEqual(2, fused.Length);
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, fused[0]));
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 8, 9, 10, 11, 12, 13, 14, 15 }, fused[1]));
        }
Exemplo n.º 17
0
        public virtual void VertexColor()
        {
            // medium size spiro cyclo hexane like
            int[][] g = new int[][] { new[] { 1, 5 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 0, 4, 7, 8 }, new[] { 7, 10 }, new[] { 5, 6 }, new[] { 5, 9 }, new[] { 8, 10 },
                                      new[]  { 6, 9, 12, 13 }, new[] { 12, 15 }, new[] { 10, 11 }, new[] { 10, 14 }, new[] { 13, 15 }, new[] { 11, 14, 17, 18 }, new[] { 17, 20 }, new[] { 15, 16 }, new[] { 15, 19 },
                                      new[]  { 18, 20 }, new[] { 16, 19, 22, 23 }, new[] { 22, 25 }, new[] { 20, 21 }, new[] { 20, 24 }, new[] { 23, 25 }, new[] { 21, 24, 27, 28 }, new[] { 27, 30 },
                                      new[]  { 25, 26 }, new[] { 25, 29 }, new[] { 28, 30 }, new[] { 26, 29, 32, 33 }, new[] { 32, 35 }, new[] { 30, 31 }, new[] { 30, 34 }, new[] { 33, 35 },
                                      new[]  { 31, 34, 37, 38 }, new[] { 37, 40 }, new[] { 35, 36 }, new[] { 35, 39 }, new[] { 38, 40 }, new[] { 36, 39, 42, 43 }, new[] { 42, 45 }, new[] { 40, 41 },
                                      new[]  { 40, 44 }, new[] { 43, 45 }, new[] { 41, 44, 47, 48 }, new[] { 47, 50 }, new[] { 45, 46 }, new[] { 45, 49 }, new[] { 48, 50 }, new[] { 46, 49, 52, 53 },
                                      new[]  { 52, 55 }, new[] { 50, 51 }, new[] { 50, 54 }, new[] { 53, 55 }, new[] { 51, 54, 57, 58 }, new[] { 57, 60 }, new[] { 55, 56 }, new[] { 55, 59 }, new[] { 58, 60 },
                                      new[]  { 56, 59 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[] colors = search.VertexColor();
        }
Exemplo n.º 18
0
        public virtual void TestFused_Cylclophane()
        {
            // medium size spiro cyclophane
            int[][] g = new int[][] { new[] { 1, 5 }, new[] { 0, 2 }, new[] { 1, 3, 50, 46 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 0, 4, 7, 8 }, new[] { 7, 10 }, new[] { 5, 6 }, new[] { 5, 9 },
                                      new[]   { 8, 10 }, new[] { 6, 9, 12, 13 }, new[] { 12, 15 }, new[] { 10, 11 }, new[] { 10, 14 }, new[] { 13, 15, 16, 17 }, new[] { 11, 14 }, new[] { 14, 20 }, new[] { 14, 18 },
                                      new[]   { 17, 19 }, new[] { 18, 20, 21, 22 }, new[] { 16, 19 }, new[] { 19, 25 }, new[] { 19, 23 }, new[] { 22, 24, 26, 30 }, new[] { 23, 25 }, new[] { 21, 24 },
                                      new[]   { 23, 27 }, new[] { 26, 28, 35, 31 }, new[] { 27, 29 }, new[] { 28, 30 }, new[] { 23, 29 }, new[] { 27, 32 }, new[] { 31, 33 }, new[] { 32, 34, 40, 36 },
                                      new[]   { 33, 35 }, new[] { 27, 34 }, new[] { 33, 37 }, new[] { 36, 38 }, new[] { 37, 39, 45, 41 }, new[] { 38, 40 }, new[] { 33, 39 }, new[] { 38, 42 },
                                      new[]   { 41, 43, 58, 59 }, new[] { 42, 44 }, new[] { 43, 45 }, new[] { 38, 44 }, new[] { 2, 47 }, new[] { 46, 48 }, new[] { 47, 49 }, new[] { 48, 50, 51, 55 }, new[] { 2, 49 },
                                      new[]   { 49, 52 }, new[] { 51, 53 }, new[] { 52, 54 }, new[] { 53, 55, 56, 57 }, new[] { 49, 54 }, new[] { 54, 59 }, new[] { 54, 58 }, new[] { 42, 57 }, new[] { 42, 56 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            int[][] fused    = search.Fused();
            Assert.AreEqual(0, isolated.Length);
            Assert.AreEqual(1, fused.Length);
            Assert.AreEqual(g.Length, fused[0].Length);
        }
Exemplo n.º 19
0
        public virtual void TestFused_Fullerene()
        {
            int[][] g = new int[][] { new[] { 1, 4, 8 }, new[] { 0, 2, 11 }, new[] { 1, 3, 14 }, new[] { 2, 4, 17 }, new[] { 3, 0, 5 }, new[] { 4, 6, 19 }, new[] { 5, 7, 21 },
                                      new[]    { 6, 8, 24 }, new[] { 7, 0, 9 }, new[] { 8, 10, 25 }, new[] { 9, 11, 28 }, new[] { 10, 1, 12 }, new[] { 11, 13, 29 }, new[] { 12, 14, 32 }, new[] { 13, 2, 15 },
                                      new[]    { 14, 16, 33 }, new[] { 15, 17, 36 }, new[] { 16, 3, 18 }, new[] { 17, 19, 37 }, new[] { 18, 5, 20 }, new[] { 19, 21, 39 }, new[] { 20, 6, 22 },
                                      new[]    { 21, 23, 41 }, new[] { 22, 24, 43 }, new[] { 23, 7, 25 }, new[] { 24, 9, 26 }, new[] { 25, 27, 44 }, new[] { 26, 28, 46 }, new[] { 27, 10, 29 },
                                      new[]    { 28, 12, 30 }, new[] { 29, 31, 47 }, new[] { 30, 32, 49 }, new[] { 31, 13, 33 }, new[] { 32, 15, 34 }, new[] { 33, 35, 50 }, new[] { 34, 36, 52 },
                                      new[]   { 35, 16, 37 }, new[] { 36, 18, 38 }, new[] { 37, 39, 53 }, new[] { 38, 20, 40 }, new[] { 39, 41, 54 }, new[] { 40, 22, 42 }, new[] { 41, 43, 56 },
                                      new[]   { 42, 23, 44 }, new[] { 43, 26, 45 }, new[] { 44, 46, 57 }, new[] { 45, 27, 47 }, new[] { 46, 30, 48 }, new[] { 47, 49, 58 }, new[] { 48, 31, 50 },
                                      new[]    { 49, 34, 51 }, new[] { 50, 52, 59 }, new[] { 51, 35, 53 }, new[] { 52, 38, 54 }, new[] { 53, 40, 55 }, new[] { 54, 56, 59 }, new[] { 55, 42, 57 },
                                      new[]    { 56, 45, 58 }, new[] { 57, 48, 59 }, new[] { 58, 51, 55 } };
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(g);

            int[][] isolated = search.Isolated();
            int[][] fused    = search.Fused();
            Assert.AreEqual(0, isolated.Length);
            Assert.AreEqual(1, fused.Length);
            Assert.AreEqual(g.Length, fused[0].Length);
        }
Exemplo n.º 20
0
        public virtual void TestAnd()
        {
            BitArray s = new BitArray(3);
            BitArray t = new BitArray(3);

            s.Set(0, true);
            s.Set(1, true);
            t.Set(1, true);
            t.Set(2, true);

            BitArray u = JumboCyclicVertexSearch.And(s, t);

            Assert.IsTrue(s[0]);
            Assert.IsTrue(s[1]);
            Assert.IsFalse(s[2]);

            Assert.IsFalse(t[0]);
            Assert.IsTrue(t[1]);
            Assert.IsTrue(t[2]);

            Assert.IsFalse(u[0]);
            Assert.IsTrue(u[1]);
            Assert.IsFalse(u[2]);
        }
Exemplo n.º 21
0
        public virtual void TestEmpty()
        {
            ICyclicVertexSearch search = new JumboCyclicVertexSearch(Array.Empty <int[]>());

            Assert.IsNotNull(search);
        }
Exemplo n.º 22
0
        public virtual void TestToArray_Empty()
        {
            BitArray empty = new BitArray(0);

            Assert.IsTrue(Compares.AreDeepEqual(Array.Empty <int>(), JumboCyclicVertexSearch.ToArray(empty)));
        }