示例#1
0
        Coverage RemoveRedundant(Coverage groups)
        {
            // A group is redundant if it covers "ones" already covered by other
            // essential groups
            var redundant = new Coverage();
            var essential = new Coverage(groups.Where(g => g.IsEssential.Value));

            foreach (var g in groups)
            {
                if (g.IsEssential.Value)
                {
                    continue;
                }

                var remaining_terms = new Group(g);
                foreach (var e in essential)
                {
                    remaining_terms.ExceptWith(e);
                }
                if (remaining_terms.Count == 0)
                {
                    redundant.Add(g);
                }
            }

            return(new Coverage(groups.Except(redundant)));
        }
示例#2
0
        HashSet <Coverage> GetCoverages(Coverage groups)
        {
            // Navigate the graph of (possible) solutions, each including or excluding one particular group
            // Each if each solution is valid (i.e. it covers all 'ones')
            var essential             = new Coverage(groups.Where(g => g.IsEssential.Value));
            var available_groups_list = groups.Except(essential).OrderBy(g => g.Count);

            return(new HashSet <Coverage>(NavigateCoverages(essential, available_groups_list, true)));
        }