Function
bool isAcyclic();
Returns whether this graph is a acyclic graph or not.
None
Return true if the graph is a acyclic graph, false otherwise.
Example
#include "HKUAL_graph.h" #include <iostream> using namespace std; using namespace HKUAL; int main(){ DirectedGraph<string> g; g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addVertex("E"); g.addEdge("A","B"); g.addEdge("A","C"); g.addEdge("B","C"); g.addEdge("B","D"); g.addEdge("C","D"); g.addEdge("E","A"); if (g.isAcyclic()) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
Output
Time Complexity
, for is number of edges and is total number of vertives