Advertisement

最大流的 Ford-Fulkerson 标号法

阅读量:
复制代码
    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    using namespace std;
    const int maxn=1000,inf=1000010;//顶点个数最大值
    struct ArcType//弧结构
    {
    	int c,f;
    };
    ArcType edge[maxn][maxn];//邻接矩阵
    int n;//顶点个数
    int flag[maxn];//顶点状态 -1未标号 0已标号未检查 1标号已检查
    int pre[maxn];//标号的第一个分量 指明标号从哪个顶点得到 以便找出可改进量
    int alpha[maxn];//标号的第二个分量 可改进两a
    int queue[maxn];//相当于bfs算法的队列
    int v;//从队列里取出来的队列头元素
    int qs,qe;//队列头位置 队列尾位置
    int i,j;//循环变量
    void ford()
    {
    	while(1)//标号直至不存在可改进路 
    	{
    		memset(flag,-1,sizeof flag);//标号前对顶点状态数组初始化

全部评论 (0)

还没有任何评论哟~