歡迎您光臨本站 註冊首頁

C++簡單實現Dijkstra算法

←手機掃碼閱讀     lousu-xi @ 2020-06-01 , reply:0

本文實例為大家分享了C++簡單實現Dijkstra算法的具體代碼,供大家參考,具體內容如下

 // Dijkstra.cpp : 定義控制檯應用程序的入口點。 // #include "stdafx.h" #include#include#define MAX_VALUE 1000 using namespace std; struct MGraph { int *edges[MAX_VALUE]; int iVertexCount, iEdageCount; }; void ReadDate(MGraph *mGraph, int *iBegin, int *iEnd); void Dijkstra(MGraph *mGraph, int *pArrDis, int *pArrPath, int iBegin); void PrintResult(int *pArrDis, int *pArrPath, int iBegin, int iEnd); int main() { int iBegin, iEnd; int *pArrPath = new int[MAX_VALUE]; int *pArrDis = new int[MAX_VALUE]; MGraph mGraph; for (int i = 0; i<MAX_VALUE; i++){ mGraph.edges[i] = new int[MAX_VALUE]; } ReadDate(&mGraph, &iBegin, &iEnd); Dijkstra(&mGraph, pArrDis, pArrPath, iBegin); PrintResult(pArrDis,pArrPath, iBegin, iEnd); system("pause"); return 0; } void ReadDate(MGraph *mGraph, int *iBegin, int *iEnd){ cout <" <<stackVertices.top(); stackVertices.pop(); } cout <" <<iEnd <<endl; }

 


[lousu-xi ] C++簡單實現Dijkstra算法已經有241次圍觀

http://coctec.com/docs/c/language/show-post-236492.html