Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /*
- Se da un graf neorientat. Sa se verifice daca contine sau nu un ciclu.
- */
- bool AmCiclu = false;
- void DFS(int x,int t[], bool viz[])
- {
- int i;
- viz[x] = true;
- t[x] = prec;
- for(i=1;i<=n;++i)
- if(a[x][i] == true)
- {
- if(!viz[i])
- {
- t[i] = x;
- DFS(i,t, viz);
- }
- else
- if( i!=prec )
- {
- AmCiclu = true;
- NodDinCiclu = i;
- VecinNodDinCiclu = x;
- }
- }
- }
- int main()
- {
- int n,m;
- cin>>n>>m;
- bool a[n+1][n+1], viz[n+1];
- int t[n+1];
- cin>>n>>m;
- for(i=1;i<=m;i++)
- {
- xin>>x>>y;
- a[x][y] = a[y][x] = true;
- }
- //vedem daca are ciclu
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement