#include<iostream> using namespace std; int bridge[N][2]; int col[N],low[N],dep[N],iscut[N],nb; int dfs(int u,int fa,int depth) { col[u]=1; dep[u]=low[u]=depth; int tol=0; int tofa=0;//判断u,v之间是否有两条以上边 int i,v; for(i=0;i<list[u].size();i++) { v=list[u][i]; if(col[v]==0) { tol++; dfs(v,u,depth+1); low[u]=min(low[u],low[v]); /*求割点 if(u==root&&col>1||x!=root&&low[v]>=dep[u]) iscut[u]=1; */ /*求桥 if(low[v]>dep[u]) { bridge[++nb][0]=u; bridge[nb][1]=v; } */ } else { if(v!=fa||tofa) low[u]=min(low[u],dep[v]); else tofa=1; } } return 0; } int main() {  root=1; dfs(root,-1,1);  }
|