本文整理汇总了C++中Digraph::AcyclicCheck方法的典型用法代码示例。如果您正苦于以下问题:C++ Digraph::AcyclicCheck方法的具体用法?C++ Digraph::AcyclicCheck怎么用?C++ Digraph::AcyclicCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Digraph
的用法示例。
在下文中一共展示了Digraph::AcyclicCheck方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
cout << endl << endl;
cout << "test print adjacency list (should have three edges on 2): \n";
digraph->PrintAdjacencyList();
cout << endl << endl;
cout << "\tREMOVE EDGE TESTING\n";
cout << "Attempting valid removal (existing edge in middle of list): \n";
digraph->RemoveEdge(2, 4);
cout << "\nAttempting valid removal (existing edge at end of list): \n";
digraph->RemoveEdge(2, 1);
cout << "\nAttempting valid removal (existing edge head): \n";
digraph->RemoveEdge(2, 3);
cout << "\nAttempting invalid removal (edge between 2 and 2): \n";
digraph->RemoveEdge(2, 2);
cout << "\nAttempting invalid removal (task one doesn't exist): \n";
digraph->RemoveEdge(4, 1);
cout << "\nAttempting invalid removal (no edges on task 1): \n";
digraph->RemoveEdge(3, 1);
cout << "\nAttempting invalid removal (specific edge doesn't exist): \n";
digraph->RemoveEdge(2, 5);
cout << endl << endl;
cout << "test print adjacency list (should have no edges): \n";
digraph->PrintAdjacencyList();
cout << endl << endl;
cout << "\n==========> TEST ACYCLIC CHECK\n" << endl;
cout << endl << endl;
cout << "current adjacency list (no edges): \n";
digraph->PrintAdjacencyList();
cout << "Running Acyclic Check...\n";
cout << "\tAcyclic Check Finished: no edges, expect true: " << boolToString(digraph->AcyclicCheck()) << endl << endl;
cout << "\nAdd cycle on purpose: \n";
digraph->AddEdge(1, 2);
digraph->AddEdge(2, 3);
digraph->AddEdge(3, 1);
cout << "result print: \n";
digraph->PrintAdjacencyList();
cout << "Running Acyclic Check...\n";
cout << "\tAcyclic Check Finished: expect false: " << boolToString(digraph->AcyclicCheck()) << endl << endl;
cout << "\nTest a more complex cycle... Reconfigure list to be harder to detect: \n";
digraph->RemoveEdge(3, 1);
digraph->RemoveEdge(1, 2);
digraph->AddHeader("task name-8");
digraph->AddHeader("task name-9");
digraph->AddEdge(4, 1);
digraph->AddEdge(2, 4);
digraph->AddEdge(2, 5);
digraph->AddEdge(5, 3);
digraph->AddEdge(3, 6);
digraph->AddEdge(6, 4);
digraph->AddEdge(6, 1);
digraph->AddEdge(4, 3);// should be the cause of cycle
cout << "result print: \n";
digraph->PrintAdjacencyList();
cout << "Running Acyclic Check...\n";
cout << "\tAcyclic Check Finished: expect false: " << boolToString(digraph->AcyclicCheck()) << endl << endl;
cout << "\nFix complex graph (remove cycle):\n";
digraph->RemoveEdge(4, 3);// should remove the cycle