本文整理汇总了C++中Digraph::calculate_linear_upper_bounds方法的典型用法代码示例。如果您正苦于以下问题:C++ Digraph::calculate_linear_upper_bounds方法的具体用法?C++ Digraph::calculate_linear_upper_bounds怎么用?C++ Digraph::calculate_linear_upper_bounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Digraph
的用法示例。
在下文中一共展示了Digraph::calculate_linear_upper_bounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* Test karp's algorithm for calculating the maximum cycle mean
*/
TEST(DigraphTest, Digraph2)
{
Digraph* digraph = DigraphExample::generateDigraph2();
digraph->generate_strongly_connected_components();
vector<Digraph*> sccs = digraph->sccs;
EXPECT_EQ(sccs.size(),1);
if (output) {
for (vector<Digraph*>::iterator iter = sccs.begin(); iter != sccs.end(); iter++) {
(*iter)->write_graphviz(std::cout);
}
}
digraph->check_strongly_connected();
EXPECT_EQ(digraph->strongly_connected,true);
digraph->calculate_period_gcd();
digraph->calculate_all_gcd();
EXPECT_EQ(digraph->pGCD,1);
digraph->calculate_linear_factor();
EXPECT_EQ(digraph->linear_factor,2.0/3);
digraph->calculate_csum();
digraph->calculate_linear_upper_bounds();
EXPECT_EQ(digraph->c_sum,5);
EXPECT_EQ((int)(digraph->c_rbf*1000), 2000);
EXPECT_EQ((int)(digraph->c_ibf*1000), 666);
EXPECT_EQ((int)(digraph->c_dbf*1000), 666);
digraph->tf = 100;
digraph->prepare_rbf_calculation(false);
double matrix[9][9] = {{0,2,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY},
{NEG_INFINITY,0,0,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY},
{0,NEG_INFINITY,0,0,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY},
{NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,0,0,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY},
{NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,0,2,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY},
{NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,0,0,NEG_INFINITY,NEG_INFINITY},
{NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,0,0,NEG_INFINITY},
{NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,0,1},
{0,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,0,NEG_INFINITY,NEG_INFINITY,NEG_INFINITY,0}};
double** matrix2 = new double*[9];
for (int i=0; i<9; i++) matrix2[i] = new double[9];
for (int i=0; i<9; i++) for (int j=0; j<9; j++) matrix2[i][j] = matrix[i][j];
bool test = Utility::compare_two_matrices(matrix2,digraph->unit_digraph->matrix,9);
if (output) Utility::output_matrix(digraph->unit_digraph->matrix, digraph->unit_digraph->n_size, digraph->unit_digraph->n_size);
EXPECT_EQ(test, true);
EXPECT_EQ(digraph->unit_digraph->lper, 3);
//cout<<"linear defect = " << digraph->unit_digraph->ldef<<endl;
// test (ldef,ldef+10]
map<int,double**> matrices;
matrices[1] = digraph->unit_digraph->matrix;
int ldef = MaxPlusAlgebra::calculate_linear_defect(matrices,9,2.0/3,3,100);
EXPECT_EQ(digraph->unit_digraph->ldef, ldef);
for (int t=2; t<=100; t++) {
matrices[t] = MaxPlusAlgebra::multiply_maxplus_matrix(matrices[(t-1)],matrices[1],9);
}
for (int t=digraph->unit_digraph->ldef+1; t<=50; t++) {
//cout<<"=================="<<t<<"====================="<<endl;
double** temp = MaxPlusAlgebra::periodicly_calculate_maxplus_matrix_power(matrices[t],9,digraph->linear_factor,digraph->unit_digraph->lper);
double** temp2 = matrices[t+digraph->unit_digraph->lper];
EXPECT_EQ(Utility::compare_two_matrices(temp,temp2,9), true);
}
// test rbf
double rbf[16] = {0,2,2,3,4,4,5,6,6,7,8,8,9,10,10,11};
for (int i=0; i<16;i++)
EXPECT_EQ(digraph->rbf(i),rbf[i]);
digraph->prepare_ibf_calculation(false);
EXPECT_EQ(digraph->unit_digraph->lper,digraph->gran_digraph->lper);
EXPECT_EQ(digraph->unit_digraph->ldef,digraph->gran_digraph->ldef);
// test ibf
// Output maximum element
if (false) {
for ( int i=0; i<20; i++)
cout<<digraph->gran_digraph->maximum_element_map[i]<<endl;
}
double ibf[16] = {0,1,2,2,3,4,4,5,6,6,7,8,8,9,10,10};
for (int i=0; i<16;i++)
EXPECT_EQ(digraph->ibf(i),ibf[i]);
//.........这里部分代码省略.........