C++实现图的邻接矩阵的创建以及其深度优先遍历和广度优先遍历

#include
using namespace std;
typedef char vertextype;
typedef int edgetype;
#define maxvex 100
#define infinity 1000
#include
int visited[100];

class MGraph{
	
public:
	vertextype vexs[maxvex];
	edgetype arc[maxvex][maxvex];
	int numvertexs,numedges;//图的顶点数目和图的边的数目
	MGraph(const int &v,const int &e):numvertexs(v),numedges(e){}
	void creategraph();//创建图结构
	void displaygraph();//显示图的结构
	void DFS(int i);//深度优先遍历的子函数
	void DFSTraverse();
	void BFSTraverse();//定义广度遍历算法



};
void MGraph::creategraph()
{  cout<<"下面请输入顶点的元素类型值,输入的个数为"<>vexs[i];
	}
	cin.clear();
	cout<<"下面请为邻接矩阵赋值,矩阵的大小为:"<>arc[i][j];
		}
	}
	

}
void MGraph::displaygraph()
{   cout<<"下面输出的是顶点中的元素"< q;
	for(i=0;i

你可能感兴趣的:(数据结构)