Re: find subsets

• To: mathgroup at smc.vnet.net
• Subject: [mg104725] Re: [mg104694] find subsets
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sun, 8 Nov 2009 06:43:38 -0500 (EST)

```Ns = Subsets[{a, b, c, d, e}, {3}];

Needs["Combinatorica`"]

Ns == KSubsets[{a, b, c, d, e}, 3]

True

Cases[Ns, {___, b, ___}]

{{a, b, c}, {a, b, d}, {a, b, e}, {b, c, d}, {b, c, e}, {b, d, e}}

% == Cases[Ns, _?(! FreeQ[#, b] &)]

True

%% == Select[Ns, ! FreeQ[#, b] &]

True

Cases[Ns, {___, b, c, ___}]

{{a, b, c}, {b, c, d}, {b, c, e}}

% == Cases[Ns, {___, b, ___, c, ___}]

True

%% == Cases[Ns, _?(! FreeQ[#, b] && ! FreeQ[#, c] &)]

True

Bob Hanlon

---- r_poetic <radford.schantz at mms.gov> wrote:

=============
Hello,
here is a quick question from a novice.

First, generate a list of subsets using Subsets or KSubsets
functions.

Ns = KSubsets[{a,b,c,d,e},3] = {{a,b,c},{a,b,d},{a,b,e},{a,c,d}, etc.}

How can one infer from that list a list of its members that contain
given elements, e.g. a list of members that contain b, or those that
contain both b and c? For illustration:

Some_function[Ns, b and c] = { {a,b,c},{b,c,d},{b,c,e}}

I keep thinking there must be a direct way to do this using Select or
some other function?

```

• Prev by Date: Re: Finding Clusters
• Next by Date: Re: What is going on!?!
• Previous by thread: Re: find subsets
• Next by thread: Re: find subsets