- 3
- 0
- 约9.84千字
- 约 11页
- 2017-02-15 发布于重庆
- 举报
数据结构-源程序
#includeiostream
#includestack
#includefstream
using namespace std;
const int MaxNum=100000;
class Graph
{private:
int *Adj;//保存邻接矩阵的一维数组j和k之间权值存储在Adj[j*Num+k]中
int Num;//当前顶点数
public:
Graph();//构造函数
~Graph();//析沟函数
void Dijkstra(int start);//单元最短路径算法
};
Graph::Graph()//构造函数
{
ifstream input(input.txt,ios::in);
if(input==NULL)coutopen error!\n;
if(input!=NULL)
{
inputNum;
Adj=new int[Num*Num];
if(Adj==NULL)exit(0);
for(int i=0;iNum;i++)
for(int j=0;jNum;j++)
{
inputAdj[i*Num+j];
if(Adj[i*Num+j]==-1)
Adj[i*Num+j]=MaxNum;
}
}
}
Graph::~Graph()//析构函数
{
delete[]Adj;
}
void Graph::Dijkstra(int star
原创力文档

文档评论(0)