示例#1
0
        public virtual void SubSetOfBasis()
        {
            var c1 = new Mock <Cycle>((InitialCycles)null, (ShortestPaths)null, (int[])null);
            var c2 = new Mock <Cycle>((InitialCycles)null, (ShortestPaths)null, (int[])null);
            var c3 = new Mock <Cycle>((InitialCycles)null, (ShortestPaths)null, (int[])null);

            c1.SetupGet(c => c.EdgeVector).Returns(BitArrays.FromString("111000000000"));
            c2.SetupGet(c => c.EdgeVector).Returns(BitArrays.FromString("000111000000"));
            c3.SetupGet(c => c.EdgeVector).Returns(BitArrays.FromString("011110000000"));
            c1.SetupGet(c => c.Length).Returns(3);
            c2.SetupGet(c => c.Length).Returns(3);
            c3.SetupGet(c => c.Length).Returns(4);
            var basis = new GreedyBasis(3, 12);

            Assert.IsFalse(basis.IsSubsetOfBasis(c3.Object));
            basis.Add(c1.Object);
            Assert.IsFalse(basis.IsSubsetOfBasis(c3.Object));
            basis.Add(c2.Object);
            Assert.IsTrue(basis.IsSubsetOfBasis(c3.Object));
        }
示例#2
0
        public virtual void IndexOf()
        {
            BitMatrix m  = new BitMatrix(9, 3);
            BitArray  r1 = BitArrays.FromString("010000000");
            BitArray  r2 = BitArrays.FromString("100001000");
            BitArray  r3 = BitArrays.FromString("010000000");

            m.Add(r1);
            m.Add(r2);
            m.Add(r3);
            Assert.AreEqual(1, m.IndexOf(0, 0));
            Assert.AreEqual(1, m.IndexOf(0, 1));
            Assert.AreEqual(-1, m.IndexOf(0, 2));
            Assert.AreEqual(0, m.IndexOf(1, 0));
            Assert.AreEqual(2, m.IndexOf(1, 1));
            Assert.AreEqual(2, m.IndexOf(1, 2));
            Assert.AreEqual(-1, m.IndexOf(2, 0));
            Assert.AreEqual(-1, m.IndexOf(2, 1));
            Assert.AreEqual(-1, m.IndexOf(2, 2));
        }
示例#3
0
        public virtual void Clear()
        {
            BitMatrix m  = new BitMatrix(9, 3);
            BitArray  r1 = BitArrays.FromString("110000000");
            BitArray  r2 = BitArrays.FromString("100000000");
            BitArray  r3 = BitArrays.FromString("010000000");

            m.Add(r1);
            m.Add(r2);
            m.Add(r3);
            Assert.AreSame(r1, m.Row(0));
            Assert.AreSame(r2, m.Row(1));
            Assert.AreSame(r3, m.Row(2));
            m.Clear();
            m.Add(r3);
            m.Add(r2);
            m.Add(r1);
            Assert.AreSame(r3, m.Row(0));
            Assert.AreSame(r2, m.Row(1));
            Assert.AreSame(r1, m.Row(2));
        }