Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. /*
  6. Se da un graf neorientat. Sa se verifice daca contine sau nu un ciclu.
  7. */
  8.  
  9. bool AmCiclu = false;
  10.  
  11. void DFS(int x,int t[], bool viz[])
  12. {
  13. int i;
  14. viz[x] = true;
  15. t[x] = prec;
  16.  
  17. for(i=1;i<=n;++i)
  18. if(a[x][i] == true)
  19. {
  20. if(!viz[i])
  21. {
  22. t[i] = x;
  23. DFS(i,t, viz);
  24. }
  25. else
  26. if( i!=prec )
  27. {
  28. AmCiclu = true;
  29. NodDinCiclu = i;
  30. VecinNodDinCiclu = x;
  31.  
  32. }
  33. }
  34. }
  35.  
  36.  
  37. int main()
  38. {
  39.  
  40. int n,m;
  41.  
  42. cin>>n>>m;
  43. bool a[n+1][n+1], viz[n+1];
  44. int t[n+1];
  45.  
  46. cin>>n>>m;
  47. for(i=1;i<=m;i++)
  48. {
  49. xin>>x>>y;
  50. a[x][y] = a[y][x] = true;
  51. }
  52.  
  53. //vedem daca are ciclu
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement