• 大小: 147KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: 其他
  • 标签:

资源简介

基于正域的属性约简算法实现,想要就拿去吧。。。

资源截图

代码片段和文件信息

#include 
#include 
#include 
using namespace std;
const int max_line = 505max_attribute = 7;

struct LNode
{
string obj[max_attribute];
LNode *lnodeptr;
};
struct IndClassEle
{
int num;
LNode *firstptr;
};

//void FiletoMatrix(string string );
void FiletoMatrix(string inFileNamestring DeMatrix[max_line][max_attribute]){
ifstream infile(inFileName.c_str()ios::in);
for(int i = 0;i {
for(int j = 0;j {
infile>>DeMatrix[i][j];
}
}
}//此函数用于把输入的决策表转化为对应的矩阵
//此函数为算法一求等价类
void computeIND(string DeMatrix[max_line][max_attribute]
int attributeB[]IndClassEle *IndClass)
{
int ijmflag;
LNode *Lptr=0;//有序表头指针
LNode *tempptr*tempptr1;//tempptr1为第一步中tempptr的前指针,放便插入tempptr的前面

for(i=0;i {
//LNode *newptr = new LNode;newptr->obj = DeMatrix[i];
LNode *TempNode = new LNode;
j=0;
while (j {
TempNode->obj[j] = DeMatrix[i][j];
TempNode->lnodeptr=0;
j++;


}
if( Lptr==0)
{
TempNode->lnodeptr=Lptr;
Lptr = TempNode;
}
else
{
tempptr=Lptr;
tempptr1=Lptr;
//m=1;
flag=0;
while(tempptr!=0 && flag==0 )
{
flag=0;
m=1;
while(m < max_attribute - 1)
{
if(attributeB[m]==1 && TempNode->obj[m] == tempptr->obj[m] || attributeB[m]==0)
m++;
else 
break;
}
if (m==max_attribute-1)
flag=1;
else
{
tempptr1 = tempptr;
tempptr=tempptr->lnodeptr;
}

if(tempptr==Lptr)
{
TempNode->lnodeptr = Lptr;
Lptr = TempNode;
}
else
{
TempNode->lnodeptr = tempptr1->lnodeptr;
tempptr1->lnodeptr = TempNode;
}
}//把结点大的放前面。
//cout<<“test to here“< }//此循环为对 对象进行排续
//测试排续后的数据
/*cout<<“测试排续后的数据:“< tempptr=Lptr;
for(i=0;i {
cout<obj[0]<<“  “;
tempptr=tempptr->lnodeptr;
}
cout<<“测试排续后的数据结束:“<
    ////////////////////////////
/*tempptr = Lptr;
for(i=0;i {
cout<obj[0]< tempptr=tempptr->lnodeptr;
}
cout<    //////////////////////////此循环为显视排续后的节点号



for(i=0;i {
IndClass[i].num = 0;
IndClass[i].firstptr = 0;
}
j=0;
tempptr = Lptr->lnodeptr;
Lptr->lnodeptr=IndClass[0].firstptr;
IndClass[0].firstptr = Lptr;
IndClass[0].num = 1;

//Lptr->lnodeptr=0;
for(i=1;i {
m=1;
while(m < max_attribute-1&&attributeB[m]==1&&tempptr->obj[m]==IndClass[j].firstptr->obj[m]||attributeB[m]==0&& m  m++;
if(m==max_attribute - 1)
{
IndClass[j].num =  IndClass[j].num + 1;
tempptr1=tempptr;
tempptr = tempptr->lnodeptr;
tempptr1->lnodeptr = IndClass[j].firstptr;
IndClass[j].firstptr = tempptr1;
}
else
{
j++;
IndClass[j].num=1;
tempptr1=te

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      11947  2010-12-01 22:51  基于正域的属性约简\posreduction.cpp

     文件     485888  2011-07-13 20:29  基于正域的属性约简\posreduction.exe

     文件        768  2010-10-30 21:47  基于正域的属性约简\table7_1.txt

     文件        767  2010-10-30 00:13  基于正域的属性约简\table7_2.txt

     目录          0  2011-07-16 20:33  基于正域的属性约简

----------- ---------  ---------- -----  ----

               499370                    5


评论

共有 条评论

相关资源