图论
文章平均质量分 77
cjliux
这个作者很懒,什么都没留下…
展开
-
poj 3259 wormholes AC代码(负权环判断, Bellmanford)
#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 10001;struct Edge { int from; int to; int w原创 2015-06-17 14:34:30 · 588 阅读 · 0 评论 -
Kuhn_Munkres最大权匹配算法C++模板
#include #include #include // 使用其中的 min 函数using namespace std;const int MAX = 1024;int n; // X 的大小int weight [MAX] [MAX]; // X 到 Y 的映射(权重)int lx [MAX], ly [MAX]; // 标号bool sx [MAX], sy [MAX转载 2015-08-20 20:38:48 · 1100 阅读 · 0 评论 -
matlab实现基于DFS的Ford_Fulkerson最大流最小割算法
function [F, maxf, V, S] = Ford_Fulkerson(C, src, sink)n = size(C, 1);F = zeros(n);maxf = 0;V = [];S = [];while true % in: ResNet. ResNet = C - F + F'; % residual network. % ou原创 2015-08-15 11:21:55 · 4325 阅读 · 12 评论 -
C++ 实现MST kruskal's algorithm
#include#include#include#include#includeusing namespace std;enum{ INF = INT_MAX };struct Edge{ int from; int to; int Wgt; Edge(int _from, int _to, int _Wgt = INF) : from(_from), to(_原创 2015-06-27 10:41:27 · 1170 阅读 · 0 评论 -
C++实现floyd-warshall算法
#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 100000000;void ch_status(vector > & W, int nNodes) { //DP,原创 2015-06-06 21:22:14 · 1380 阅读 · 0 评论 -
C++实现Bellmanford算法
#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 100000000;struct Node{ int dist; int pre; Node() : dist(原创 2015-06-06 20:17:57 · 513 阅读 · 0 评论 -
C++实现带路径记录的Floyd-Warshall算法
#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = 100000000;void ch_status(vector > & W, vector > & P, int nNo原创 2015-06-06 21:41:02 · 1018 阅读 · 0 评论 -
C++ 最大流(push-relable)算法
// The push-relable algorithm code due to CLRS chapter 26#include#includeusing namespace std;const int N = 100;int n; // vertex numberint e[N]; // residual flow of the vertexint h[N]; // height转载 2015-06-20 11:26:54 · 929 阅读 · 0 评论 -
C++ 基于Dijkstra最短路搜索的Ford Fulkson最大流算法
#include#include#include#include#includeusing namespace std;const int MAXN = 120;const int INF = INT_MAX;int G[MAXN][MAXN], N;int dist[MAXN], Pre[MAXN];bool visited[MAXN];int times = 0原创 2015-06-20 08:32:04 · 1086 阅读 · 0 评论 -
C++ 基于Dijkstra算法和基于BFS算法的Ford Fulkson算法比较
#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = INT_MAX;//Edmond Karp.bool EK_bfs(vector > &G, int src, int dest, vector &Pr原创 2015-06-20 09:25:47 · 981 阅读 · 0 评论 -
C++实现Dijkstra算法
#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = INT_MAX;struct Node{ int pre; int d原创 2015-06-17 16:35:52 · 1423 阅读 · 0 评论 -
C++实现图的十字链表表示及相关各算法
/* * OLGraph.h * * Created on: Oct 19, 2015 * Author: chris */#ifndef OLGRAPH_H_#define OLGRAPH_H_#include#include#define MAX_VERTEX_NUM 20#define INF INT_MAXstruct InfoType{ in原创 2015-10-31 19:45:45 · 965 阅读 · 1 评论