An undirected graph is given to find the point connectivity of the graph.
Point connectivity: The number of vertices in the minimum cut point set.
0<=n=50.
Minimum cut.
The edge connectivity is very good, just need to arbitrarily fixed source point enumeration meeting point for Minimum cut min can be.
Point connectivity uses the idea of point-and-edge transformation, where each point is split, in and out, the information on the point is reflected on the edge.
The in point of each point points to the out point with a 1-capacity edge.
Each edge is split into two forward edges, and a positive infinity edge is attached to the point at which the forward Edge (U,V) is to V from the out point of U.
N2 enumeration of source and sink points, the minimum cut min is the answer.
Cutting off the edge of the out point is equivalent to deleting the point. The real side can not be deleted, set into a positive infinity anti-cutting.
Point connectivity cannot fix source points to enumerate sinks because the Yuanhui two point is not in the minimum cut point collection by default, so you must enumerate the Yuanhui.
1#include <iostream>2#include <cstring>3#include <cstdio>4#include <algorithm>5#include <queue>6 using namespacestd;7 Const intdian= the;8 Const intbian=20005;9 Const intinf=0x3f3f3f3f;Ten Const intinf=100000; One intH[dian],ver[bian],val[bian],nxt[bian],ch[dian],cr[dian]; A intN,m,tot,aa,bb,ans; - ints,t; - voidAddintAintBintc) { thetot++;ver[tot]=b;val[tot]=c;nxt[tot]=h[a];h[a]=tot; -tot++;ver[tot]=a;val[tot]=0; nxt[tot]=h[b];h[b]=tot; - } - BOOLTell () { +memset (ch,-1,sizeof(CH)); -queue<int>Q; + Q.push (S); Ach[s]=0; at while(!Q.empty ()) { - intt=Q.front (); - Q.pop (); - for(intI=h[t];i;i=Nxt[i]) - if(ch[ver[i]]==-1&&Val[i]) { -ch[ver[i]]=ch[t]+1; in Q.push (Ver[i]); - } to } + returnch[t]!=-1; - } the intZengintAintb) { * if(a==T) $ returnb;Panax Notoginseng intR=0; - for(intI=cr[a];i&&b>r;i=Nxt[i]) the if(ch[ver[i]]==ch[a]+1&&Val[i]) { + intT=zeng (Ver[i],min (b-r,val[i])); Aval[i]-=t,r+=t,val[i^1]+=T; the if(Val[i]) +cr[a]=i; - } $ if(!R) $ch[a]=-1; - returnR; - } the intDinic () { - intR=0, T;Wuyi while(Tell ()) { the for(intI=1; i<=n+n;i++) -cr[i]=H[i]; Wu while(t=Zeng (S,inf)) -r+=T; About } $ returnR; - } - intMain () { - while(SCANF ("%d%d", &n,&m)! =EOF) { Amemset (H,0,sizeof(h)); +memset (NXT,0,sizeof(NXT)); thetot=1; -ans=INF; $ for(intI=1; i<=n;i++) theAdd (I,i+n,1); the for(intI=1; i<=m;i++){ thescanf"(%d,%d)",&aa,&BB); theAdd (aa+n+1, bb+1, INF); -Add (bb+n+1, aa+1, INF); in } the for(intI=1; i<=n;i++) the for(intj=1; j<=n;j++){ About if(i==j) the Continue; thes=i+n,t=J; theans=min (Ans,dinic ()); + for(intk=2; k<=tot;k+=2){ -val[k]+=val[k^1]; theval[k^1]=0;Bayi } the } the if(ans>=inf) -ans=N; -printf"%d\n", ans); the } the return 0; the}
POJ 1966 Cable TV Network