Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================
- // Name : Graf.cpp
- // Author : Alexa Lukac
- // Version :
- // Copyright :
- // Description : Hello World in C++, Ansi-style
- //============================================================================
- #include <iostream>
- using namespace std;
- int n,m; //n-broj cvorova, m-broj grana
- int time1=0;
- bool connected[6000][6000];
- struct cvor
- {
- cvor() : visited(false), disctime1(-1), endtime1(-1), low(-1) {}
- bool visited;
- int disctime1; //vreme pronalaska
- int endtime1; //vreme zavrsetka sa ovim cvorom
- int low; //najvise sto mozemo da odemo
- };
- cvor niz[5000];
- void dfs(int a)
- {
- if(niz[a].visited==false)
- {
- bool art=true;
- cvor &t=niz[a];
- t.visited=true;
- t.low=t.disctime1=++time1;
- for(int i=0;i<n;i++)
- {
- if(connected[a][i]&&!niz[i].visited){
- art=false;
- bool most=true;
- dfs(i);
- if(niz[i].low>=t.disctime1)
- {
- t.low=niz[i].low;
- most=false;
- }else
- {
- art=true;
- }
- if(most)
- cout << endl << "Most: " << a << "-" << i;
- }
- }
- if(art)
- cout << endl << "Artikulacioni cvor: " << a;
- t.endtime1=++time1;
- }
- }
- int main() {
- for(int i=0;i<5005;i++)
- for(int j=0;j<5005;j++)
- connected[i][j]=false;
- cin >> n >> m;
- for(int i=0;i<m;i++)
- {
- int a,b;
- cin >> a >> b;
- connected[a][b]=connected[b][a]=true;
- }
- return 0;
- }
- /*
- * 4 4
- 0 1
- 1 2
- 1 3
- 0 3
- 9 10
- 0 2
- 2 5
- 2 3
- 3 1
- 3 4
- 4 7
- 3 7
- 5 6
- 5 7
- 7 8
- *
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement