Network stream vertex connectivity poj 1966 zoj 2182

Source: Internet
Author: User

Vertex connectivity: Removes at least a few vertices to make the graph not connected.

Suppose two neighboring vertices u and v;

Two paths from u to V without common internal vertices are called independent tracks. The maximum number of independent paths from u to V is recorded as P (u, v)

Therefore, if the graph is not connected, you should remove a vertex on each independent track (not any). Therefore, the vertex connectivity is the minimum value of the maximum number of independent tracks.

Note: If the graph is a full graph, remove all vertices.

How can we find the maximum independent Rail P (A, B) between two points?

1. Split each point into two points, and connect an edge u '--- U "with a capacity of 1. E = (u, v) there are two arcs e '= <u ", V'> and E" = <v ", U'> in the new network. The two sides have an infinite capacity.

2. Set "A" as the Source Vertex and "B" as the sink vertex.

3. Find the maximum stream between two points

The sum of all the arc flows out of A is P (A, B), and all the arcs with flow 1 (the arc at this time is equivalent to a point) the corresponding vertex forms a cut-top set. After removing these vertices in the graph, A and B are disconnected.

I think twice, and after data verification, the book should be wrong. We need to enumerate the Source and Sink points in pairs.

Because if the enumerated source point is the point in the cut-top set, it will not work.

5 6)

The answer should be 1.

However, if there are no two-byte enumeration source points, the answer is 5.

Therefore, we still need to enumerate the two vertices.

View code

# Include <stdio. h>
# Include < String . H>
Const Int Max = 100005 ;
Const Int INF = 1000000000 ;

Struct
{
Int V, C, next;
} Edge [ 1000000 ];
Int E, head [Max];
Int Gap [Max], cur [Max];
Int Pre [Max], DIS [Max];
Void Add_edge ( Int S, Int T, Int C, Int CC)
{
/* When adding an edge, add two at the same time,
One is positive, one is opposite,
Generally, the reverse capacity is 0. */
Edge [e]. V = T; edge [e]. C = C;
Edge [e]. Next = head [s];
Head [s] = e ++;
Edge [e]. V = s; edge [e]. c = cc;
Edge [e]. Next = head [T];
Head [T] = e ++;
}
Int Min ( Int A, Int B ){ Return (A =- 1 | B <)? B: ;}
Int SAP ( Int S, Int T, Int N)
{}
Void Init ()
{
For ( Int I = 0 ; I <E; I + = 2 )
{
Edge [I]. C + = edge [I ^ 1 ]. C;
Edge [I ^ 1 ]. C = 0 ;
}
}
Int Main ()
{
Int I, J;
Int A, B, n, m;
While (Scanf ( " % D " , & N, & M )! = EOF)
{
Memset (Head ,- 1 , Sizeof (Head); E = 0 ;
For (I = 0 ; I <n; I ++)
{
Add_edge (I, I + N, 1 , 0 );
}
For (I = 0 ; I <m; I ++)
{
Scanf ( " (% D, % d) " , & A, & B );
Add_edge (a + N, B, INF, 0 );
Add_edge (B + N, A, INF, 0 );
}
Int Ans = inf;
For (I = 0 ; I <n; I ++)
{
For (J = 0 ; J <n; j ++)
{
If (J! = I ){
Int TMP = SAP (I + N, J, 2 * N); Init ();
Ans = TMP <ans? TMP: ans;
}
}
}
If (ANS> = inf) ans = N;
Printf ( " % D \ n " , ANS );
}
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.