求最小割边集

这篇博客介绍了如何求解最小割边集,通过首先运行最大流算法,然后在残余流量网络中进行DFS搜索,标记从源点可达的节点,找出连接起点为1,终点为0的边集,这些边集构成了一组最小割边集。
摘要由CSDN通过智能技术生成

改f上一篇文章的时候顺便学会了求最小割边集的方法,虽然用到上一题上是错的,但是把这个方法也先总结一下;


先跑一遍最大流,在残余流量里从s开始dfs凡事能从s开始能流到的点标记为1,其他的标记为0,起点为1终点为0的边集是一组最小割边集。


cpp:

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;
#define maxn 10010
#define INF 1e9
struct Edge{
	int from,to,cap,flow;
};
struct Dinic{
	int n,m,s,t;
	vector<Edge> edges;
	vector<int> G[maxn],g[maxn];
	vector<Edge> ed;
	bool vis[maxn] ;
	int d[maxn];
	int cur[maxn];
	int un[maxn];
	void add(int a,int b){
		edges.push_back((Edge){a,b,1,0});
		edges.push_back((Edge){b,a,0,0});
		m=edges.size();
		G[a].push_back(m-2);
		G[b].push_back(m-1);
	}
	bool bfs(){
		memset(vis,0,sizeof(vis));
		queue
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值