diff --git a/Cycle_Detection_Graphs/dfs_directed_cycle.cpp b/Cycle_Detection_Graphs/dfs_directed_cycle.cpp new file mode 100644 index 0000000000..9cfd59ace7 --- /dev/null +++ b/Cycle_Detection_Graphs/dfs_directed_cycle.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; +int N=4; +vector vis(5); +vector > G(N+1); +bool temp; +bool dfs(int root){ + vis[root]=1; + for(int i=0;i v; + for(int i=1;i<=N;i++){ + if(!vis[i]){ + v.push_back(dfs(i)); + } + } + int i; + for(i=0;i +using namespace std; +int N=6; +vector vis(N+1); +vector > G(N+1); +bool dfs(int root,int p){ + vis[root]=1; + bool temp=false; + for(int i=0;i