本文整理汇总了C++中Digraph::AddHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ Digraph::AddHeader方法的具体用法?C++ Digraph::AddHeader怎么用?C++ Digraph::AddHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Digraph
的用法示例。
在下文中一共展示了Digraph::AddHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
cout << endl;
cout << "------------------------START TEST OF DIGRAPH CLASS------------------------" << endl;
cout << endl << endl;
// instantiate digraph to test
Digraph* digraph = new Digraph();
cout << "\n==========> TEST ADD / REMOVE HEADER ITEMS (tasks)\n" << endl;
digraph->AddHeader("task 1");
cout << "Adding a header item: " << endl << "\ttask name 'task 1': "
<< digraph->GetHead()->data << "\n\ttask number '1': " << digraph->GetHead()->taskNo;
cout << endl << endl;
digraph->RemoveHeader(1);
cout << "Removing the only header item: " << endl << "\thead == NULL 'true': "
<< boolToString(digraph->GetHead() == NULL);
cout << endl << endl;
digraph->AddHeader("task name-1");
digraph->AddHeader("task name-2");
digraph->AddHeader("task name-3");
digraph->AddHeader("task name-4");
digraph->AddHeader("task name-5");
cout << "Adding many header items, test print:" << endl;
digraph->PrintHeaders();
cout << endl << endl;
cout << "Removing the head" << endl << "result print:" << endl;
digraph->RemoveHeader(1);
digraph->PrintHeaders();
cout << endl << endl;
cout << "Removing a header in middle" << endl << "result print:" << endl;
digraph->RemoveHeader(2);
digraph->PrintHeaders();
cout << endl << endl;
cout << "Removing last header item" << endl << "result print:" << endl;
digraph->RemoveHeader(3);
digraph->PrintHeaders();
cout << endl << endl;
cout << "\n==========> TEST ADD / REMOVE EDGE ITEMS\n" << endl;
cout << "Adding two Headers\n";
digraph->AddHeader("task name-6");
digraph->AddHeader("task name-7");
digraph->PrintHeaders();
cout << endl << endl;
cout << "\tADD EDGE TESTING\n";
cout << "Attempting valid input 0 (shouldn't produce anything): \n";
digraph->AddEdge(2, 1);
cout << "\nAttempting valid input 1 (shouldn't produce anything): \n";
digraph->AddEdge(2, 4);
cout << "\nAttempting valid input 2 (shouldn't produce anything): \n";
digraph->AddEdge(2, 3);
cout << "\nAttempting invalid input (1 comes before 1): \n";
digraph->AddEdge(1, 1);
cout << "\nAttempting to add an Edge which already exists: \n";
digraph->AddEdge(2, 3);
cout << "\nAttempting invalid input (task two doesn't exist): \n";
digraph->AddEdge(1, 6);
cout << "\nAttempting invalid input (task one doesn't exist): \n";
digraph->AddEdge(5, 7);
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;
//.........这里部分代码省略.........