diff --git a/PT07Y.cpp b/PT07Y.cpp new file mode 100644 index 0000000..461ddb5 --- /dev/null +++ b/PT07Y.cpp @@ -0,0 +1,54 @@ +#include +using namespace std; +vectorgraph[10000]; +long int n,m,i,j; +bool iscycle(long int s,bool visited[],long int parent) +{ + visited[s]=true; + vector::iterator it; + for(it=graph[s].begin();it!=graph[s].end();it++) + { + if(visited[*it]==false) + { + if(iscycle(*it,visited,s)) + return true; + } + else if(*it!=parent) + return true; + } + return false; +} +bool istree(long int s) +{ + bool visited[n]; + memset(visited,false,sizeof(visited)); + //cout<<"here"; + if(iscycle(i,visited,-1)) + return false; + for(long int i=0;i>n>>m; + //long int i,j; + while(m--) + { + cin>>i>>j; + i--,j--; + addedge(i,j); + } + //cout<