mirror of
https://github.com/guilhermewerner/paa
synced 2025-06-16 13:34:18 +00:00
New tests
This commit is contained in:
53
Article.txt
Normal file
53
Article.txt
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
M1:
|
||||||
|
1 1 1 0 0 0 0 0 -1 0
|
||||||
|
-1 0 0 1 1 1 0 0 0 0
|
||||||
|
0 -1 0 -1 0 0 1 0 0 -1
|
||||||
|
0 0 -1 0 -1 0 -1 1 0 0
|
||||||
|
0 0 0 0 0 0 0 0 1 1
|
||||||
|
0 0 0 0 0 -1 0 -1 0 0
|
||||||
|
|
||||||
|
0 1 1 1 0 0
|
||||||
|
0 0 1 1 0 1
|
||||||
|
0 0 0 1 0 0
|
||||||
|
0 0 0 0 0 1
|
||||||
|
1 0 1 0 0 0
|
||||||
|
0 0 0 0 0 0
|
||||||
|
|
||||||
|
TC:
|
||||||
|
1 1 1 1 0 1
|
||||||
|
0 1 1 1 0 1
|
||||||
|
0 0 1 1 0 1
|
||||||
|
0 0 0 1 0 1
|
||||||
|
1 1 1 1 1 1
|
||||||
|
0 0 0 0 0 1
|
||||||
|
|
||||||
|
M2:
|
||||||
|
-1 1 1 1 1 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0
|
||||||
|
0 -1 0 0 0 -1 1 1 1 0 0 0 0 0 0 -1 0 0 0 0 0
|
||||||
|
0 0 -1 0 0 0 -1 0 0 -1 1 1 0 0 0 0 -1 0 0 0 0
|
||||||
|
0 0 0 -1 0 0 0 -1 0 0 -1 0 -1 1 0 0 0 -1 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 -1 1 0
|
||||||
|
0 0 0 0 -1 0 0 0 -1 0 0 -1 0 -1 0 0 0 0 0 -1 -1
|
||||||
|
|
||||||
|
0 1 1 1 0 1
|
||||||
|
0 0 1 1 0 1
|
||||||
|
0 0 0 1 0 1
|
||||||
|
0 0 0 0 0 1
|
||||||
|
1 1 1 1 0 1
|
||||||
|
0 0 0 0 0 0
|
||||||
|
|
||||||
|
M3:
|
||||||
|
-1 0 0 1 1 -1 0 1 1 -1 1 1 0 0 -1 -1 -1 0 0 0 0
|
||||||
|
1 -1 -1 -2 -2 0 0 -1 -1 0 -1 -1 -1 0 2 1 1 0 -1 0 -1
|
||||||
|
0 1 0 1 0 1 -1 0 -1 0 1 0 1 -1 0 1 0 1 0 0 0
|
||||||
|
0 0 1 0 0 0 1 0 0 1 -1 -1 0 0 -1 -1 0 -1 1 -1 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1
|
||||||
|
|
||||||
|
0 1 0 0 0 0
|
||||||
|
1 0 0 0 0 0
|
||||||
|
1 1 0 1 0 0
|
||||||
|
1 1 1 0 0 0
|
||||||
|
0 0 0 0 0 0
|
||||||
|
0 1 1 1 0 0
|
||||||
|
|
32
Permutation.txt
Normal file
32
Permutation.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
G1:
|
||||||
|
0 1 1 1 0 0
|
||||||
|
0 0 1 1 0 1
|
||||||
|
0 0 0 1 0 0
|
||||||
|
0 0 0 0 0 1
|
||||||
|
1 0 1 0 0 0
|
||||||
|
0 0 0 0 0 0
|
||||||
|
|
||||||
|
TC:
|
||||||
|
1 1 1 1 0 1
|
||||||
|
0 1 1 1 0 1
|
||||||
|
0 0 1 1 0 1
|
||||||
|
0 0 0 1 0 1
|
||||||
|
1 1 1 1 1 1
|
||||||
|
0 0 0 0 0 1
|
||||||
|
|
||||||
|
G2:
|
||||||
|
0 1 0 0 0 0
|
||||||
|
0 0 1 0 0 1
|
||||||
|
0 0 0 1 0 0
|
||||||
|
0 0 0 0 0 1
|
||||||
|
1 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0
|
||||||
|
|
||||||
|
TC:
|
||||||
|
1 1 1 1 0 1
|
||||||
|
0 1 1 1 0 1
|
||||||
|
0 0 1 1 0 1
|
||||||
|
0 0 0 1 0 1
|
||||||
|
1 1 1 1 1 1
|
||||||
|
0 0 0 0 0 1
|
||||||
|
|
@ -116,6 +116,78 @@ Graph *Graph::ToTransitiveClosure()
|
|||||||
return new Graph(closure, closure.size());
|
return new Graph(closure, closure.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Graph::TransitiveReduction()
|
||||||
|
{
|
||||||
|
auto closure = this->GetAdjacencyMatrix();
|
||||||
|
|
||||||
|
cout << "G1:" << endl;
|
||||||
|
Graph::_PrintAdjacencyMatrix(closure);
|
||||||
|
|
||||||
|
for (auto k = 0; k < this->nodes; k++)
|
||||||
|
{
|
||||||
|
for (auto i = 0; i < this->nodes; i++)
|
||||||
|
{
|
||||||
|
for (auto j = 0; j < this->nodes; j++)
|
||||||
|
{
|
||||||
|
if (i == j)
|
||||||
|
{
|
||||||
|
closure[i][j] = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
closure[i][j] = closure[i][j] || (closure[i][k] && closure[k][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "TC:" << endl;
|
||||||
|
Graph::_PrintAdjacencyMatrix(closure);
|
||||||
|
|
||||||
|
auto reduction = this->GetAdjacencyMatrix();
|
||||||
|
|
||||||
|
for (auto j = 0; j < this->nodes; j++)
|
||||||
|
{
|
||||||
|
for (auto i = 0; i < this->nodes; i++)
|
||||||
|
{
|
||||||
|
if (reduction[i][j] == 1)
|
||||||
|
{
|
||||||
|
for (auto k = 0; k < this->nodes; k++)
|
||||||
|
{
|
||||||
|
if (reduction[j][k] == 1)
|
||||||
|
{
|
||||||
|
reduction[i][k] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "G2:" << endl;
|
||||||
|
Graph::_PrintAdjacencyMatrix(reduction);
|
||||||
|
|
||||||
|
for (auto k = 0; k < this->nodes; k++)
|
||||||
|
{
|
||||||
|
for (auto i = 0; i < this->nodes; i++)
|
||||||
|
{
|
||||||
|
for (auto j = 0; j < this->nodes; j++)
|
||||||
|
{
|
||||||
|
if (i == j)
|
||||||
|
{
|
||||||
|
reduction[i][j] = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reduction[i][j] = reduction[i][j] || (reduction[i][k] && reduction[k][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "TC:" << endl;
|
||||||
|
Graph::_PrintAdjacencyMatrix(reduction);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void Graph::TransitiveClosure()
|
void Graph::TransitiveClosure()
|
||||||
{
|
{
|
||||||
|
@ -87,6 +87,8 @@ public:
|
|||||||
|
|
||||||
Graph *ToTransitiveClosure();
|
Graph *ToTransitiveClosure();
|
||||||
|
|
||||||
|
void TransitiveReduction();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static vector<vector<int>> MultiplyIncidenceMatrix(const vector<vector<int>> &matrix1, const vector<vector<int>> &matrix2)
|
static vector<vector<int>> MultiplyIncidenceMatrix(const vector<vector<int>> &matrix1, const vector<vector<int>> &matrix2)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,6 @@ int main()
|
|||||||
int nodes = 6;
|
int nodes = 6;
|
||||||
Graph *g1 = new Graph(nodes);
|
Graph *g1 = new Graph(nodes);
|
||||||
|
|
||||||
g1->AddEdge(0, 0);
|
|
||||||
g1->AddEdge(0, 1);
|
g1->AddEdge(0, 1);
|
||||||
g1->AddEdge(0, 2);
|
g1->AddEdge(0, 2);
|
||||||
g1->AddEdge(0, 3);
|
g1->AddEdge(0, 3);
|
||||||
@ -17,22 +16,24 @@ int main()
|
|||||||
g1->AddEdge(4, 0);
|
g1->AddEdge(4, 0);
|
||||||
g1->AddEdge(4, 2);
|
g1->AddEdge(4, 2);
|
||||||
|
|
||||||
cout << "M1:" << endl;
|
g1->TransitiveReduction();
|
||||||
g1->PrintIncidenceMatrix();
|
|
||||||
g1->PrintAdjacencyMatrix();
|
|
||||||
auto m1 = g1->GetIncidenceMatrix();
|
|
||||||
|
|
||||||
Graph *g2 = g1->ToTransitiveClosure();
|
// cout << "M1:" << endl;
|
||||||
cout << "M2:" << endl;
|
// g1->PrintIncidenceMatrix();
|
||||||
g2->PrintIncidenceMatrix();
|
// g1->PrintAdjacencyMatrix();
|
||||||
g2->PrintAdjacencyMatrix();
|
// auto m1 = g1->GetIncidenceMatrix();
|
||||||
auto m2 = g2->GetIncidenceMatrix();
|
|
||||||
|
|
||||||
auto m3 = Graph::MultiplyIncidenceMatrix(m1, m2);
|
// Graph *g2 = g1->ToTransitiveClosure();
|
||||||
Graph *g3 = new Graph(m3);
|
// cout << "M2:" << endl;
|
||||||
cout << "M3:" << endl;
|
// g2->PrintIncidenceMatrix();
|
||||||
g3->PrintIncidenceMatrix();
|
// g2->PrintAdjacencyMatrix();
|
||||||
g3->PrintAdjacencyMatrix();
|
// auto m2 = g2->GetIncidenceMatrix();
|
||||||
|
|
||||||
|
// auto m3 = Graph::MultiplyIncidenceMatrix(m1, m2);
|
||||||
|
// Graph *g3 = new Graph(m3);
|
||||||
|
// cout << "M3:" << endl;
|
||||||
|
// g3->PrintIncidenceMatrix();
|
||||||
|
// g3->PrintAdjacencyMatrix();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user