Beispiel #1
0
        public void ImperfectArbitaryMatching()
        {
            Matching matching = Matching.WithCapacity(5);
            BitArray subset   = new BitArray(5);

            BitArrays.Flip(subset, 0, 5);
            Assert.IsFalse(matching.ArbitaryMatching(new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3 } }, subset));
        }
Beispiel #2
0
        public void PerfectArbitaryMatching()
        {
            Matching matching = Matching.WithCapacity(4);
            BitArray subset   = new BitArray(4);

            BitArrays.Flip(subset, 0, 4);
            Assert.IsTrue(matching.ArbitaryMatching(new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2 } }, subset));
        }
Beispiel #3
0
        public void Fulvelene1()
        {
            int[][]  graph  = GraphUtil.ToAdjList(smipar.ParseSmiles("c1cccc1c1cccc1"));
            Matching m      = Matching.WithCapacity(graph.Length);
            BitArray subset = new BitArray(graph.Length);

            BitArrays.Flip(subset, 0, graph.Length);
            // arbitary matching will assign a perfect matching here
            Assert.IsTrue(m.ArbitaryMatching(graph, subset));
        }
Beispiel #4
0
 /// <summary>
 /// Create a new multiple stereo encoder from a single list of encoders
 /// </summary>
 public MultiStereoEncoder(IList <IStereoEncoder> encoders)
 {
     if (encoders.Count == 0)
     {
         throw new ArgumentException("no stereo encoders provided");
     }
     this.encoders     = new List <IStereoEncoder>(encoders);
     this.unconfigured = new BitArray(encoders.Count);
     BitArrays.Flip(unconfigured, encoders.Count);
 }
Beispiel #5
0
        public void Fulvelene2()
        {
            int[][]  graph  = GraphUtil.ToAdjList(smipar.ParseSmiles("c1cccc1c1cccc1"));
            Matching m      = Matching.WithCapacity(graph.Length);
            BitArray subset = new BitArray(graph.Length);

            BitArrays.Flip(subset, 0, graph.Length);

            // induced match - can't be perfected without removing this match
            m.Match(1, 2);

            // arbitary matching will not be able assign a perfect matching
            Assert.IsFalse(m.ArbitaryMatching(graph, subset));

            // but Perfect() will
            Assert.IsTrue(m.Perfect(graph, subset));
        }
        private Matching CreateMatching(IAtomContainer container, params int[] xs)
        {
            BitArray subset = new BitArray(container.Atoms.Count);

            if (xs.Length == 0)
            {
                BitArrays.Flip(subset, 0, container.Atoms.Count);
            }
            else
            {
                foreach (var x in xs)
                {
                    subset.Set(x, true);
                }
            }
            Matching m = Matching.WithCapacity(container.Atoms.Count);

            return(EdmondsMaximumMatching.Maxamise(m, GraphUtil.ToAdjList(container), subset));
        }