"Shortest circuit"
BOOLSPFA () {memset (Vis,0,sizeof(VIS)); memset (d,0x3f,sizeof(d)); intHead=0, tail=1; q[0]=s;vis[s]=1;d [s]=0; while(head!=tail) { intX=q[head++];if(head> the) head=0; for(intI=first[x];i;i=e[i]. from) if(d[x]+e[i].w<D[E[I].V]) { inty=e[i].v; D[y]=d[x]+E[I].W; if(!Vis[y]) { if(D[y]<d[q[head]]) {head--;if(head<0) head= the; q[head]=y;} Else{q[tail++]=y;if(tail> the) tail=0;} Vis[y]=1; }} Vis[x]=0; } returnd[t];}SPFA+SLF Optimization
"Strongly connected components"
https://www.byvoid.com/blog/scc-tarjan/
Http://www.cnblogs.com/saltless/archive/2010/11/08/1871430.html
voidTarjan (intx) {Dfn[x]=low[x]=++Mark; s[++top]=x;lack[x]=top; for(intI=first[x];i;i=e[i]. from) { inty=e[i].v; if(!Dfn[y]) {Tarjan (y); LOW[X]=min (low[x],low[y]); } Else if(!col[y]) low[x]=min (low[x],dfn[y]); } if(dfn[x]==Low[x]) {Color++; for(inti=lack[x];i<=top;i++) col[s[i]]=color; Num[color]=top-lack[x]+1; Top=lack[x]-1; }} for(intI=1; i<=n;i++)if(!dfn[i]) Tarjan (i);View Code
"Bzoj" 1051 [HAOI2006] Popular cows (templates)
"Bzoj" 2208 [Jsoi2010] connectivity number (classic)
"Edge Dual connected components"
The cut-top judgment of the graph:
#include <cstdio>#include<algorithm>using namespacestd;Const intmaxn=100000, maxm=100000;structedge{intU,v, from;} e[maxm*3];intfirst[maxn],mark,dfn[maxn],low[maxn],iscut[maxn],tot,n,m;voidInsertintUintv) {Tot++;e[tot].v=v;e[tot].u=u;e[tot]. from=first[u];first[u]=tot;}voidDfsintXintFA) {Dfn[x]=low[x]=++Mark; intChild=0; for(intI=first[x];i;i=e[i]. from) if(e[i].v!=a) { inty=e[i].v; if(!Dfn[y]) { Child++;//ImportantDFS (Y,X); LOW[X]=min (low[x],low[y]); if(Low[y]>=dfn[x]) iscut[x]=1; } Else /*if (dfn[y]<dfn[x])*/low[x]=min (low[x],dfn[y]); } if(fa<0&&child<=1) iscut[x]=0;}intMain () {scanf ("%d%d",&n,&m); for(intI=1; i<=m;i++) { intu,v; scanf ("%d%d",&u,&v); Insert (u,v); insert (v,u); } for(intI=1; i<=n;i++)if(!dfn[i]) DFS (i,-1); for(intI=1; i<=n;i++)if(Iscut[i]) printf ("%d", i);p rintf ("\ n"); return 0;}View Code
"POJ" 3177 redundant Paths
"Point two connected components"
There seems to be some unclear questions, usually with the use of the side of the dual-connected component-based.
"LA" 5135 Mining Your Own Business
The theory of "algorithm" graph