The cutting edge of the picture _ figure

Source: Internet
Author: User
The definition of the cut edge of the graph is similar to the cut point of the graph, that is, after removing an edge, the remaining vertices can not be reached between each other, the essence of which is to remove the equal sign of the low[v]>=num[u in the formula, because the "=" means to
Parent node, and the parent node is removed (not included in the remaining points), so even if "=" also set up, and cutting edge is even the parent node can not, so changed to Low[v]>num[u]
Also noteworthy is that in the cut point, there is a special case is the root node only a child node, so it is not cut point, but it belongs to cut edge, so do not need to classify the discussion ~ ~
#include <stdio.h>
int a[101][101];
int n;
int num[101];
int low[101];
int index;
int min (int a,int b)
{
Return a<b?a:b;
}
int dfs (int cur,int father)
{

int i;
index++;
Num[cur]=index;
Low[cur]=index;
for (i=1;i<=n;i++)
{


if (a[i][cur]==1)
{

if (num[i]==0)//If it has not been accessed, it is a cur child node
{

DFS (i,cur);
Low[cur]=min (Low[i],low[cur])//If the low of the child node is small, the child node is also connected to other ancestor nodes
if (Low[i]>num[cur])
printf ("%d-%d\n", cur,i);

}
else if (i!=father)
Low[cur]=min (Low[cur],num[i]);//If it is an ancestor node, then update num
}
}

Return
}
int main ()
{
int i,m,j,x,y;
scanf ("%d%d", &n,&m);
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
a[i][j]=0;
for (i=1;i<=m;i++)
{
scanf ("%d%d", &x,&y);
A[x][y]=1;
A[y][x]=1;
}
DFS (1,1);
return 0;



}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.