Clustering Algorithm With And Without Overlapping Code Size Less than 80 Lines
#include<stdio.h>
typedef struct cluster{
int total,cr;
int element[10];
}cluster;
void main()
{
int i,j,k,l,n,ch,flag,count;
float c[10][10],th;
cluster c1[10];
count=0;
flag=0;
printf("\n Enter choice 1.Overlaping 2.Non-overlaping");
scanf("%d",&ch);
printf("\n Enter the number of documents");
scanf("%d",&n);
printf("\n Enter the threshold");
scanf("%f",&th);
printf("\n Enter the elements");
for(i=0;i<10;i++)
{
c[i][i]=1;
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
printf("\n Enter document:%d and document:%d",i,j);
scanf("%f",&c[i][j]);
}
}
c1[count].element[1]=1;
c1[count].total=1;
c1[count++].cr=1;
for(i=2;i<=n;i++)
{ flag=0;
for(j=0;j<count;j++)
{
k=c1[j].cr;
if(c[k][i]>=th)
{
c1[j].total++;
l=c1[j].total;
c1[j].element[l]=i;
flag=1;
if(ch==2)
{
break;
}
else if(ch==1)
{
}
}
}
if(flag==0)
{
c1[count].total=1;
c1[count].element[1]=i;
c1[count++].cr=i;
}
}
for(i=0;i<count;i++)
{
printf("\n Number of clsuters:%d",c1[i].total);
printf("\n Clusters cr:%d",c1[i].cr);
printf("\n The elements of the clsuter");
for(j=1;j<=c1[i].total;j++)
{
printf("\t%d",c1[i].element[j]);
}
printf("\n");
}
}
No comments:
Post a Comment