graphalgori.cpp

来自「图论算法中dijkstra、Floy、和最小生成树算法的实现」· C++ 代码 · 共 49 行

CPP
49
字号
// GraphAlgori.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "CGraphAlgori.h"
int main(int argc, char* argv[])
{
//	printf("Hello World!\n");
//	return 0;

//	PathSE.resize(5);
//	PathSE.push_back(2);
//	PathSE.push_back(5);

	CGraphAlgori GraAlg;
	double dInf = INF;

	double R1[25] = {     0,   50, dInf, dInf, dInf,
					   dInf,    0, dInf, dInf,   80,
					   dInf,   30,    0,   20, dInf,
					   dInf, dInf, dInf,    0,   70,
					     65, dInf,  100, dInf,    0
					};
	double* pdMinDist = new double[5*5];
	int* path = new int[5*5];
	GraAlg.MinDist_Floy(5, R1, pdMinDist, path);
	PATH PathSE;
//	PathSE.push_back(5);
	GraAlg.GetPath(0, 2, 5, path, PathSE);

	double R[36] = {dInf,    6,    1,    5, dInf, dInf,
					   6, dInf,    5, dInf,    3, dInf,
					   1,    5, dInf,    5,    6,    4,
					   5, dInf,    5, dInf, dInf,    2,
					dInf,    3,    6, dInf, dInf,    6,
					dInf, dInf,    4,    2,    6, dInf};

	int* piMT = new int[6];
	double dMinFee = 0;
	GraAlg.MinSpanTree_Prim(6, R, piMT, dMinFee);

	delete[] piMT;
	delete[] pdMinDist;
	delete[] path;

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?