急!!!!!!哪位高手帮忙写main()函数。写成后送200分表示感谢

来源:百度知道 编辑:UC知道 时间:2024/06/03 12:29:56
#include <iostream>
using namespace std;
const int MaxSize=10;
template <class T>
class ALGraph
{
public:
ALGraph(T a[],int n,int e);
~ALGraph;
T GetVex(int i);
void DFSTraverse(int v);
void BFSTraverse(int v);
private:
VertexNode adjlist[MaxSize];
int vertexNum,arcNum;
};
template <class T>
ALGraph::ALGraph(T a[],int n,int e)
{
vertexNum=n;arcNum=e;
for (i=0;i<certexNum;i++)
{
adjlist[i].vertex=a[i];
adjlist[i].firstedge=NULL;
}
for (K=0;K<arcNum;k++)
{
cin>>i>>j;
s=new ArcNode;s->adjvex=j;
s->next=adjlist[i].firstedge;
adjlist[i].firstedge=s;
}
}
template <class T>
void ALGragh::DFSTraverse(int v)
{
cout<<adjlist[v].vertex; visited[v]=1;
p=adjlist[v].firstedge;
while(p)
{
j=p->adjvex;
if(visi

不光main函数,你前面的代码就不全,给你个,不明白hi我,pur_e

#include<iostream>
#include<string>
using namespace std;
#ifndef GRAPH_H //定义头文件
#define GRAPH_H
//using namespace std;
const int MaxSize=12;
struct ArcNode //定义边表结点
{
int adjvex; //邻接点域
ArcNode *next; //指向下一个边结点的指针
};
template <class T>
struct VertexNode //定义顶点表结点
{
T vertex; //顶点的名称
int in;
ArcNode *firstedge; //边表的头指针
};
template <class T>
class ALGraph
{
public:
ALGraph(T a[ ],int b[], int n, int e); //构造函数,初始化一个有n个顶点e条边的图
~ALGraph(); //析构函数,释放邻接表中各边表结点的存储空间
void TopSort( );
private:
VertexNode<T> adjlist[MaxSize]; //存放顶点表的数组
int vertexNum, arcNum; //图的顶点数和边数
};
#endif

template <class T>