資源簡介
基于正域的屬性約簡算法實現,想要就拿去吧。。。

代碼片段和文件信息
#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? {
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?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
- 上一篇:基于分辨矩陣的屬性約簡算法
- 下一篇:基于單片機的黑白棋課程設計
評論
共有 條評論