话不多说,直接上代码
//--+----+----+----+----+----+----+----+----+----+----+----+----
// 没什么可说的, 除了:
// (1) 网上的代码几乎都是转来转去, 没有调试运行就直接粘过来
// (2) 以下代码结构基于电工出版社的教材(那本书读起来很难受)
// (3) 代码在Code::Blocks上测试通过, 而Ms Visual C++ 6.0无法通过
//--+----+----+----+----+----+----+----+----+----+----+----+----
#include <iostream>
#include <Windows.h>
#include <fstream>
#include <string>
using namespace std;
template<class Type>
class Graph{
friend int main();
public:
void ShortesPaths(int);
private:
int n,
*prev;
Type **c,
*dist;
};
template<class Type>
class MinHeapNode{
friend Graph<Type>;
public:
operator int ()const{return length;}
private:
int i;
Type length;
};
template<class T>
class MinHeap{
template<class Type>
friend class Graph;
public:
MinHeap(int maxheapsize = 10);
~MinHeap(){delete []heap;}
int Size

本文介绍了如何运用分支限界法解决单源最短路径问题,通过算法设计与分析,深入探讨了该方法的有效性和实现细节。
617

被折叠的 条评论
为什么被折叠?



