Tarjan algorithm and undirected graph connectivity

Source: Internet
Author: User

One, the cut point and the bridge of the non-direction graph

For g= (v,e)

1. Cut point: xξv If you delete X and the edge with X, the graph is split into multiple unicom diagrams, then X is the cut point of the graph.

2. Bridge (cut edge): eξe If you delete the E-map, the graph is split into multiple unicom diagrams, then E is the cut point of the graph.

How to find the cutting point and cutting edge

Tarjan algorithm

It's him.

First we introduce the concept of time stamp

Set Dfsn[x] Indicates the first access to the source node Y

That is to say we assume dfsn[y]=1, then we use the depth-first search tree to access the graph

Mark the order in which the graphs are accessed sequentially

The red number in the figure left represents the low[x] value and the right represents the dfsn[x] value

What is low[x], the value?

We define LOW[X] to represent the number of the earliest numbered nodes that x can reach through its subtree

How do I update the low[x] value?

We are in the DFS process, first let Low[x]=dfsn[x]

It is defined that Y is the X child node, then Low[x]=min (Low[x],low[y]);

, we find that node 5 can reach node 1 without its parent node

So, the same low[x]=min (Low[x],dfsn[y])

How to tell if a point is a cut point?

DFSN[X]<=LOW[X]

How to tell if the edge is cutting edge?

Dfsn[x]<low[y]

(x, y) for cutting edges

Cut Point Code

Tarjan algorithm and undirected graph connectivity

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.