1
2void dfs(int k,int father,int deep)
3{
4 //printf("%d ",k);
5 c[k]=1;
6 Ancestor[k]=deep;
7 dep[k]=deep;
8 int tot=0;
9 for(int i=1;i<=N;i++){
10 if( graph[k][i] && i!=father && c[i]==1){
11 Ancestor[k]=min(Ancestor[k],dep[i]);
12 }
13 if( graph[k][i] && c[i]==0){
14 dfs(i,k,deep+1);
15 Ancestor[k]=min(Ancestor[k],Ancestor[i]);
16
17 if( (k==Root && ++tot>=2)
18 || ( k!=Root && Ancestor[i]>=dep[k]) )
19 Cut[k]=1;
20 }
21 }
22
23 c[k]=2;
24}
1#define MAXN 100
2struct SNode
3{
4 int to;
5 SNode *next;
6}node[MAXN];
7int N;
8int Root;
9int c[MAXN];
10int Ancestor[MAXN];
11int dep[MAXN];
12int Cut[MAXN];
13int graph[MAXN];
14void dfs(int k,int father,int deep)
15{
16 c[k]=1;
17 dep[k]=deep;
18 Ancestor[k]=deep;
19 int tot=0;
20 SNode *p=node[k].next ;
21 while(p){
22 int v=p->to ;p=p->next;
23 if( c[v]==1&& v!=father )
24 Ancestor[k]=min(Ancestor[k],dep[v]);
25 if(c[v]==0){
26 dfs(v,k,deep+1);
27 Ancestor[k]=min(Ancestor[k],Ancestor[v]);
28 if( (k==Root && ++tot>=2 )
29 || (k!=Root && Ancestor[v]>=dep[k]) )
30 Cut[k]=1;
31 }
32 }
33 c[k]=2;
34}
35
posted on 2009-07-20 19:21
iyixiang 阅读(244)
评论(0) 编辑 收藏 引用 所属分类:
acm