Beispiel #1
0
        public void SetWith4Items()
        {
            // Arrange
            var set = new Dictionary <int, HashSet <int> >
            {
                { 0, new HashSet <int> {
                      1, 2, 3
                  } },
                { 1, new HashSet <int> {
                      2, 4
                  } },
                { 2, new HashSet <int> {
                      3, 4
                  } },
                { 3, new HashSet <int> {
                      4, 5
                  } },
            };

            var universe = new HashSet <int> {
                1, 2, 3, 4, 5
            };

            // Act
            var covering = SetCovering.Run(set, universe);

            // Assert
            Assert.True(covering.SetEquals(new HashSet <int> {
                0, 3
            }));
        }
Beispiel #2
0
        public void SetWith2Items()
        {
            // Arrange
            var set = new Dictionary <int, HashSet <int> >
            {
                { 0, new HashSet <int> {
                      1, 2, 3
                  } },
                { 3, new HashSet <int> {
                      4, 5
                  } },
            };

            // Act
            var covering = SetCovering.CreatePowerSet(set);

            // Assert
            Assert.Equal(covering,
                         new List <HashSet <int> >
            {
                SetCovering.EmptySet,
                new HashSet <int> {
                    0
                },
                new HashSet <int> {
                    3
                },
                new HashSet <int> {
                    0, 3
                }
            });
        }
Beispiel #3
0
        public void EmptySet()
        {
            // Arrange
            var set = new Dictionary <int, HashSet <int> >();

            // Act
            var covering = SetCovering.CreatePowerSet(set);

            // Assert
            Assert.Equal(covering, new List <HashSet <int> > {
                SetCovering.EmptySet
            });
        }