• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            ArcTan

            dfs
            隨筆 - 16, 文章 - 117, 評論 - 6, 引用 - 0
            數據加載中……

            連通圖--頂點連通度的求解 POJ 1966

            有向圖G中求頂點連通度:
                  1、獨立軌P(A,B)
                  2、Menger定理:無向圖G的頂點連通度
                           k(G)=V|G|-1 G是完全圖,min <A,B>! in E(P(A,B))else
                  3、用最大流法求P(A,B)。
                  4、建圖:e=(u,v)分成e'=(u'',v')和e''=(u',v'');e'=e''=inf。
                 

            得好好研究研究這些圖論的原理,搞明白。《圖論》這本書,講得不行?。。。?!還是得好好學習《算法導論》

            最大流,好要好好學!
            10485949wangsouc1966Accepted248K16MSC++1967B2012-07-19 17:00:20
            #include<stdio.h>
            #include
            <string.h>
            #include
            <math.h>
            #include
            <algorithm>
            #define maxn 105
            #define inf 105
            #define min(x,y) (x<y?x:y)
            #define max(x,y) (x>y?x:y)
            using namespace std;
            int map[maxn][maxn];
            int N,M;
            int max_flow(int num,int map[][maxn],int source,int sink)
            {
                
            int que[maxn],head,tail;
                
            int pre[maxn],min_flow[maxn];

                
            int flow[maxn][maxn];
                
            int ans=0;
                memset(flow,
            0,sizeof(flow));
                
            while (1)
                {
                    head
            =0;tail=1;
                    que[
            1]=source;
                    memset(pre,
            -1,sizeof(pre));
                    min_flow[source]
            =inf;
                    pre[source]
            =-2;
                    
            while (head<tail)
                    {
                        
            int temp=que[++head];
                        
            for (int i=0;i<num;i++)
                        {
                            
            if (pre[i]==-1 && flow[temp][i]<map[temp][i])
                            {
                                que[
            ++tail]=i;
                                pre[i]
            =temp;
                                min_flow[i]
            =min(min_flow[temp],(map[temp][i]-flow[temp][i]));
                            }
                        }
                        
            if (pre[sink]!=-1)
                        {
                            
            int k=sink;
                            
            while (pre[k]>=0)
                            {
                                flow[pre[k]][k]
            +=min_flow[sink];
                                flow[k][pre[k]]
            =-flow[pre[k]][k];
                                k
            =pre[k];
                            }
                            
            break;
                        }
                    }
                    
            if (pre[sink]==-1)
                        
            return ans;
                    
            else
                        ans
            +=min_flow[sink];
                }
            }
            int main()
            {
                
            while (scanf("%d%d",&N,&M)==2)
                {
                    
            int u,v,ans;
                    
            int i;
                    memset(map,
            0,sizeof(map));
                    
            for (i=0;i<N;i++)
                        map[i][i
            +N]=1;
                    
            for (i=0;i<M;i++)
                    {
                        scanf(
            " (%d,%d)",&u,&v);
                        map[u
            +N][v]=map[v+N][u]=inf;
                    }
                    ans
            =inf;
                    
            for (i=1;i<N;i++)
                    {
                        ans
            =min(ans,max_flow(N*2,map,0+N,i));   //這里沒有搞明白怎么是<N , i>呢???
                    }
                    
            if (ans==inf)
                        ans
            =N;
                    printf(
            "%d\n",ans);
                }
                
            return 0;
            }

            圖論。



            posted on 2012-07-19 17:09 wangs 閱讀(514) 評論(0)  編輯 收藏 引用 所屬分類: ACM-圖論

            精品久久久久久久中文字幕| 亚洲&#228;v永久无码精品天堂久久| 亚洲国产综合久久天堂| 亚洲国产精品成人AV无码久久综合影院 | 99久久综合狠狠综合久久止| 亚洲va久久久噜噜噜久久男同 | 国产精品成人99久久久久| 国产成人精品综合久久久| 一本久久a久久精品综合香蕉| 蜜臀av性久久久久蜜臀aⅴ| 欧美一区二区精品久久| 日日狠狠久久偷偷色综合0| 久久国产热精品波多野结衣AV| 国产毛片久久久久久国产毛片 | 狠狠色丁香婷婷综合久久来| 久久综合伊人77777| 久久无码av三级| 亚洲国产精品无码久久久不卡| 久久精品无码一区二区三区日韩| 久久香蕉超碰97国产精品| 伊人热热久久原色播放www| 女人香蕉久久**毛片精品| 欧美黑人又粗又大久久久| 人妻系列无码专区久久五月天| 久久精品国产影库免费看| 人妻精品久久久久中文字幕69| 久久精品国产男包| 久久综合精品国产一区二区三区| 久久免费视频网站| 亚洲国产精品久久久久婷婷老年 | 无码人妻久久久一区二区三区| 国产伊人久久| 久久91这里精品国产2020| 亚洲国产精品久久久久婷婷软件 | 久久99国产精品久久99| 久久久久久国产精品免费无码 | 性欧美丰满熟妇XXXX性久久久| 亚洲欧美国产精品专区久久 | 国产精品久久久久久吹潮| 久久久噜噜噜久久熟女AA片| 伊人久久综合无码成人网 |