hi, i hav a qs

hi , i and my frnd have been trying to implement apriori through set container class..

can some one plz tell me what is wrong with this code??

#include<set>
#include<iostream>
#include<conio.h>
#include<algorithm>
#include<vector>
using namespace std;
static const char filename[]="sample.txt";
FILE * fp=fopen(filename,"r");
typedef set<int> sample;
sample f[10][10];
sample c[10][10];
int a[10][10],t[10][10];
int i,j,k,count1[10],setcount[10];
float alpha,minsup[10];
vector<int> v(20);
vector<int>::iterator vit;
set<int> ::iterator it;
sample::iterator k1,k2,s1,s2;

void gen()
{ cout<<"in gen function"<<endl;
for(k=2;;k++)
if(!f[k-1][10].empty())
{ //cout<<"empty workin"<<endl;
for(i=1;i<=4;i++)
s1 = f[k-1][i].begin();//has to take the first element of first set of f[k-1]
while(s1!=f[k-1][i].end())
for(j = i+1 ;j<=5;j++)
{ //cout<<"within for"<<endl;
s2=f[k-1][j].begin();//take the next few elemts
k1=f[k-1][i].end();
k2=f[k-1][j].end();
//printf(" %d\t%d\n",*s1,*k1);
vit = set_intersection(s1,k1,s2,k2,v.begin());// find intersection
int elements=(int)(vit-v.begin());// find no of elemnets of intersection
printf("elements=%d\n",elements);
if(elements =(k-2))
{
vit=set_union(s1,k1,s2,k2,v.begin());
for(vit=v.begin();vit!=v.end();vit++)
{
//printf("%d\n",*vit);
c[k][j].insert(*vit);
}
}
}
}
for(k=2;f[k-1]!=NULL;k++)
{
sample ::iterator s;
for(j=1;j<=k;j++)
{
for(s=c[k][j].begin();s!=c[k][j].end();s++)
{
for(i=1;i<=5;i++)
{
s1=c[k][i].begin();
s2=c[k][j+1].begin();
k1=c[k][j].end();
k2=c[k][j+1].end();
vit=set_difference(s1,k1,s2,k2,v.begin());// repeat the above steps agn bt jus find the difference of two sets in ck tats al
for(vit=v.begin();vit!=v.end();vit++)
{
sample::iterator pt;
pt=search(f[k-1][j].begin(),f[k-1][j].end(),v.begin(),v.end());// search for the set if its present in f[k]
if(*pt<0)// if nt present erase tat set
{
c[k][j].erase(s);// pruning
setcount[*s]=0;
}
}
}
}
}
}
}
void read_calculate()
{

printf("in read_claculate\n");
if(fp!=NULL)
{
printf("file opened for reading\n");
for(i=1;i<=6;i++)
{
for(j=1;j<=5;j++)
{
fscanf(fp,"%d\t",&a[i][j]);
printf("%d\t",a[i][j]);
}
printf("\n");
}
}

else
printf("cannot open file");

printf("calculating value for t[i][j]\n");
for(i=1;i<=5;i++)
{
for(j=1;j<=6;j++)
{
t[i][j]=a[j][i];
printf("%d\t",t[i][j]);
}
printf("\n");
}
for(i=1;i<=6;i++)
{
count1[i]=0;
j=i;
for(k=1;k<=5;k++)
{
if(t[k][j]==1)
count1[i]++;
}
printf("count[%d]=%d\t",i,count1[i]);
//printf("%d\t",i);
minsup[i]=(float)count1[i]/5;
printf("minsup[%d]=%f\t",i,minsup[i]);
if(minsup[i]>=alpha)
{
f[1][i].insert(i);
setcount[1]++;
}

/*it=f[1][i].end();
while(it!=f[1][i].begin())
{cout<<*it++;
}
++it;
}
//printf("%d\n",setcount[1]);*/
gen();
}

}
void main()
{
printf("starting...............\n");
printf("enter the value for min sup(alpha):");
scanf("%f",&alpha);
//printf("calling initialisation().......\n");
//initialisation();
//printf("returned to main function\n");
printf("calling read_calculate()...............\n");
read_calculate();
getch();
}


-----------------------------------------------------------------------
sample.txt

1 0 0 1 1 1
0 1 1 0 0 1
1 1 0 0 1 1
1 0 0 0 0 0
--------------------------------------------------------------------------

it wud be a gr8 help!thanks
can some one plz tell me what is wrong with this code??
What's the code supposed to do?

This way your code is nearly unreadable. Place code tags around like so: [code]Your code[/code]
Topic archived. No new replies allowed.