POJ1966. Point connectivity of Cable TV network--undirected graphs

Source: Internet
Author: User

http://poj.org/problem?id=1966

Title Description:
In cable TV networks, repeaters are connected in two directions. If there is at least one route between any two repeaters in the network, the repeater network is called connected, or the repeater network is not connected. An empty network, and a network with only one repeater, are considered to be connected. The safety factor F of a network with n repeaters is defined as:
(1) F is n, the remaining network is still connected, regardless of the number of repeaters removed;
(2) F is to delete the least number of vertices, so that the remaining network is not connected.

Analysis:
The safety factor F in the subject is actually the vertex connectivity of the undirected graph κ (G).

Split Build Edge Cap (u,u ') =1
(u,v), Cap (U ', v) =inf,cap (v ', u) =inf

Fix a source point, enumerate meeting points, solve the maximum flow multiple times
When maxflow=0, indicates that source and sink are not connected
When Maxflow=inf, indicates that source is adjacent to sink
Otherwise, maxflow=p (Source,sink), P (u,v) is the number of independent rails

//248k 16MS C + +#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <cstdlib>#define REP (i,n) for (int i=0;i< (n); ++i)#define REP1 (I,A,B) for (int i= (a);i< (b); ++i)#define CLR (A, B) memset (A,b,sizeof (a) )#define MIN (A, b) (A<B?A:B)Const intMAXN = the;Const intMAXM =10010;Const intINF =0x3f3f3f3f;using namespace STD;intMAZE[MAXN][MAXN];intGAP[MAXN],DIS[MAXN],PRE[MAXN],CUR[MAXN];intFLOW[MAXN][MAXN];intSapintSourceintSinkintN) {clr (cur,0); CLR (DIS,0); The CLR (Gap,0); The CLR (flow,0);intu=pre[source]=source,maxflow=0, aug=-1; gap[0]=n; while(dis[source]<n) {intok=0; for(intV=CUR[U];V&LT;N;++V) {if(maze[u][v]-flow[u][v]&&dis[u]==dis[v]+1){if(aug==-1||                AUG&GT;MAZE[U][V]-FLOW[U][V]) aug=maze[u][v]-flow[u][v];                Pre[v]=u;                U=cur[u]=v; ok=1;if(V==sink) {Maxflow+=aug; for(U=pre[u];v!=source;v=u,u=pre[u])                        {Flow[u][v]+=aug;                    Flow[v][u]-=aug; } aug=-1; } Break; }        }if(OK)Continue;intmindis=n-1; for(intv=0; v<n;++v) {if(Maze[u][v]-flow[u][v]&&mindis>dis[v])                {cur[u]=v;            MINDIS=DIS[V]; }        }if((--gap[dis[u]) = =0) Break; gap[dis[u]=mindis+1]++;    U=pre[u]; }returnMaxflow;}intMain () {#ifndef Online_judgeFreopen ("In.cpp","R", stdin);#endif //Online_judge     intN,m,u,v; while(scanf("%d%d", &n,&m) = =2) {CLR (Maze,0); Rep (I,n) maze[i][i+n]=1; Rep (i,m) {scanf("(%d,%d)", &u,&v);            Maze[u+n][v]=inf;        Maze[v+n][u]=inf; }intAns=inf; REP1 (I,1, N) {intTMP=SAP (0+n,i,n<<1);        Ans=min (ANS,TMP); }if(Ans==inf)printf("%d\n", n);Else printf("%d\n", ans); }return 0;}

POJ1966. Point connectivity of Cable TV network--undirected graphs

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.