当前位置: 首页>>代码示例>>C++>>正文


C++ Digraph::AcyclicCheck方法代码示例

本文整理汇总了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
开发者ID:kmfarley11,项目名称:EECE4040_2015FS,代码行数:67,代码来源:object-tester.cpp


注:本文中的Digraph::AcyclicCheck方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。