最大流Edmonds-Karp算法头文件C++

  用了类模板,不知是不是多此一举,反正练习为主.

//	graphRepresentAsAdjacentMatrix.h --	graph header file.

//	Purpose:
//	A graph represent as a adjacent matrix, this graph can't storage 
//	weight value instead of true or false means m_matrix[i][j] is on or off.
#ifndef GRAPH_H_
#define GRAPH_H_

#include <iostream>
#include <vector>
#include <queue>

using std ::vector ;
using std ::queue ;

template<class T>
class Graph
{
private:
	enum Color{Color_White, Color_Gray, Color_Black} ;
	static const T Infinity = 99999999 ;
	unsigned int HasNotAParent ;							//	Set it when ctor is calling.
private:
	T * * m_selectedFlow ;											//	Store selected flow between any two vertexes.
	T * * m_residualFlow ;											//	Store residual flow between any two vertexes.
	unsigned int * m_currentVertexAdjoinsTo ;		//	Store vertexes current vertex adjoins to in a increasing sequence order by residual flow.
	Color * m_color ;													//	Store color of every vertex.
	unsigned int * m_parent ;									//	Store each parent in the breadth first search parth.
	unsigned int m_currentNumOfVertexes ;
	unsigned int m_totalNumOfVertexes ;
	unsigned int m_startIndex ;									//	It must be 0.
	unsigned int m_endIndex ;									//	It must be m_totalNumOfVertexes - 1.
	void getIncreasingOrder (unsigned int currentIndex) ;
	bool m_existsAAugmentingPath (T * const pMinFlows) ;
	Graph (const Graph & graph) ;
	Graph & operator = (const Graph & graph) ;
public:
	Graph (unsigned int numOfVertexes) ;
	bool importAVertex (const vector<T> & indexAdjoinsTo, const vector<T> & residualFlowAdjoinsTo) ;
	void calculateMaxFlow (void) ;
	T maxFlow (void) const ;
	void printEveryFlow (void) const ;
	void printGraph (void) const ;
} ;

#include "Graph.cpp"

#endif
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值