Uvalive 3031 Cable TV Network

Source: Internet
Author: User
Tags gcd

Test instructions: Seeking the degree of connectivity

First look at the other person's problem or do not know only the reason for enumerating the meeting point is not feasible

On the mapping method of the degree of seeking the point of connection transfer from http://hi.baidu.com/lerroy312/item/5a5f36f2f5bba61bcf9f322e

the definition of point connectivity: a graph G with N points, after removing any k-1 vertices (1<=k<=n), the resulting sub-graph is still connected, minus k vertices are not connected, then said G is a K-connected graph, K is called graph G connectivity, recorded as K (g).

Independent Rails: A A, B is the two vertices of the graph G (to the direction of the non-direction), we call the 22 without the public inner top of the rail as a separate rail, the largest number of bars is recorded as P (A, A, a, a, a).



There is a connected graph with 7 fixed points, from Vertex 1 to Vertex 3 with 3 independent rails, p (1,3) = 3;

1-7-3, 1-6-5-4-3

If each rail is drawn from each of the 3 independent rails, one inner point is removed from the G-map, the graph is not connected. If the maximum number of independent orbits between the 22 nonadjacent vertices of the connected graph G is the smallest, the value of P (A, B) is K (G). If G is a full figure (22 points), then

K (G) =n-1, which completely deletes all the edges of a point before it is disconnected. Since the independent track is only a single edge, the network flow model can be constructed, where each edge has a capacity of 1 and can be limited only once.

To build a network flow model:

if G for the graph without direction:

(1) Each vertex v in the original G-diagram becomes the two vertices in the N net v ' and V ', the vertex v ' to V ' has an arc capacity of 1;

(2) The original g of each edge e=uv, in the N network has two arc e ' =u ' V ', E ' =v ' U ' corresponds to, e ' and E ' capacity are infinite;

(3) A "is the source point, B ' is the sink point, the maximum flow."

if G for a graph of direction

(1) Each vertex v in the original G-diagram becomes the two vertices v ' and V ' in the N net, and the vertex v ' to V ' has an arc with a capacity of 1;

(2) The original G diagram of each arc e=uv into a forward rail u ' u ' V ' V ', where the orbital arc u ' V ' capacity is infinite;

(3) A ' is the source point, B ' is the maximum flow for the meeting point.

The above model only found that a is the source point B for the maximum flow Max_flow, equivalent to in G as long as the removal of Max_flow points will make a and B is not connected. And the graph of connectivity is required to remove the least points so that the entire graph is not connected, the practice is to fix a point for the source point, enumeration and the source point is not adjacent to the point is the sink point, to find the maximum flow. The smallest max_flow value in all the enumeration results is the required K (G). Note If the maximum flow of a meeting point of an enumeration is infinite, the source point of this enumeration is strongly connected to the sink point. If all the enumeration results are infinite, then the entire graph G is strongly connected, and n-1 points need to be removed to disrupt their connectivity.

all with a flow of 1 The arc ( v ', V ' ) corresponds to the V vertices make up a cut-top set

A conclusion can be obtained by finding the connectivity: G is a connected graph of K, and k>=2, then any k vertex is a common circle.

Summary of Edge-finding connectivity:

The same concept of the introduction of independent rails, just here called the weak independent orbit, also in each weak independent track only to remove a certain edge can make the starting point to the end of the non-connected, now the entire graph G of the edge connectivity is to find any two points of the minimum value of the weak independent orbit. If Figure G is a full graph, then K ' (g) is n-1.

Building a network N

if G for the graph without direction:

1. The original G-diagram of each edge e=uv into two-side e ' =uv,e ' =vu, the capacity is 1;

2. Fixed a point as the source point, enumeration and the source point is not adjacent to the sink point, the maximum flow max_flow, preserving the minimum max_flow is the edge connectivity of the graph.

if G for a graph of direction:

1. The original G chart has a forward edge capacity of 1;

2. This step is the same as step 2 of the no-show diagram.

In the residual network, the flow is 1 arc e ' = (u,v), then E ' is the bridge.

The following conclusions can be obtained from the edge connectivity of graphs:

1. A is a vertex of a direction graph G, if the minimum value between a and all other points of the G is k, there is a tree of k without a common edge in G that has a root;

2. Set G is a direction graph, 0<k<=k ' (G), L is any integer between 0 and K, for any pair of vertices of figure G (U,V), there is a weak independent of the L Bar of U to V, and the existence of the l-k from V to U is weakly independent of the direction of the orbit.

#include <map>#include<Set>#include<list>#include<cmath>#include<ctime>#include<deque>#include<stack>#include<queue>#include<cctype>#include<cstdio>#include<string>#include<vector>#include<climits>#include<cstdlib>#include<cstring>#include<iostream>#include<algorithm>#defineLL Long Long#definePI 3.1415926535897932626using namespacestd;intgcdintAintb) {returnA% b = =0? B:GCD (b, a%b);}#defineMAXN 110Const intINF =0x3f3f3f3f;intP[MAXN];intCAP[MAXN][MAXN],FLOW[MAXN][MAXN];intA[MAXN];intn,m;intEdmonds_karp (intSintt) {memset (flow,0,sizeof(flow)); Queue<int>Q; intF =0;  while(true) {memset (A,0,sizeof(a)); A[s]=INF;        Q.push (s);  while(!Q.empty ()) {            intU =Q.front (); Q.pop ();  for(inti =1; I <=2N i++)              if(!a[i] && cap[u][i] >Flow[u][i]) {A[i]= Min (A[u],cap[u][i]-Flow[u][i]); P[i]=u;              Q.push (i); }        }        if(A[t] = =0) Break;  for(intu = t; U! = S; U =P[u]) {Flow[p[u]][u]+=A[t]; Flow[u][p[u]]-=A[t]; } F+=A[t]; }    returnF;}intMain () {//freopen ("Sample.txt", "R", stdin);     while(SCANF ("%d%d", &n,&m)! =EOF) {memset (Cap,0,sizeof(CAP));  for(inti =1; I <= N; i++) Cap[i][i + N] =1;  while(m--)        {            intu,v; scanf ("(%d,%d)",&u,&v); V++;u++; Cap[u+ N][v] =INF; Cap[v+ N][u] =INF; }        intAns =INF;  for(inti =1; I <= N; i++)             for(intj =1; J <= N; J + +)        {            if(i = = j)Continue; Ans= Min (Ans,edmonds_karp (i +N, J)); }        if(ans = = INF) ans =N; printf ("%d\n", ans); }    return 0;}

Uvalive 3031 Cable TV Network

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.