To calculate subset of a set of variables.

Bonjour

Is there any method available in Boost graph liberary to calculate subsets of length N of a SET? if no please guide me how i can calculate it.
e.g.

vector type set = { a, b, c, d, e, f, g, h, i, j }

subsets of size n=2

{a, b}, {a, c} .....{b, c}.........................

subsets of size n=3

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

susets of size n=4

...............
............

I tried to solve it but it is not giving all subsets

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

vector<char> vars;
vars.push_back('b');
vars.push_back('c');
vars.push_back('d');
vars.push_back('e');
vars.push_back('f');
vars.push_back('g');
vars.push_back('h');

int counter = 0, n=3 ; // n = {0 ,1,2,3 ....} size of the subset

cout << " \n Y = " << vars.at(0)<<"\n";

for (int i = 1; i < vars.size(); i++)
{
	counter++;
	cout<<" \n i = "<<i<<" counter = "<<counter;
	if (i >= 1 && counter <= n){
			cout << " \n ........................cond variables = " << vars.at(i);
			continue;
	}
	if ( counter == n+1)
	{
		counter = 0;
		i = i - n;
	}

}


Thanks in advance
Topic archived. No new replies allowed.