#include<string> 
#include "LinkQueue.h"
#include "Mgraph.h"
#include <iostream>
using namespace std;

// 有向网

void DispMenu()
{
	cout<<"\n 请选择你要的操作"<<endl;
	cout<<" 1. 建立有向网"<<endl;
	cout<<" 2. 返回顶点在网中的位序"<<endl;
	cout<<" 3. 返回某位序的顶点"<<endl;
	cout<<" 4. 修改顶点"<<endl;
	cout<<" 5. 增加新顶点"<<endl;
	cout<<" 6. 删除顶点弧"<<endl;
	cout<<" 7. 增添边"<<endl;
	cout<<" 8. 删除边"<<endl;
	cout<<" 9. 从第一个顶点出发深度优先遍历网"<<endl;
	cout<<"10. 从第一个顶点广度优先遍历网"<<endl;
    cout<<"11. 显示网"<<endl;
	cout<<" 0. 退出"<<endl;
}

bool visited[MAX_VEXNUM]={false};

void main()
{
	char u,v;
	int k,weight;
	MGraph<char> G;
	int choice;
	do
	{
		DispMenu();
		cin>>choice;
		switch(choice)
		{
			case 1:														// 创建无向网
					CreateDN(G);
					cout<<endl;
					cout<<"创建的网为："<<endl;
					DispG(G);
					break;
			case 2:														// 查询顶点位序
					cout<<"请输入您要的所要查询位序的顶点:  ";
					cin>>u;
					k=LocateVex(G,u);
					if(k!=-1)
						cout<<"顶点"<<u<<"在网中的位序为: "<<k<<endl;
					else
						cout<<"顶点"<<u<<"不存在！"<<endl;
					cout<<endl;
					break;
			case 3:														// 按位序查找顶点值
					int index;
					cout<<"请输入您要的所要查询顶点的位序: ";
					cin>>index;
					if(GetVex(G,index,v))
						cout<<"位置为"<<index<<"的顶点为: "<<v<<endl;
					else
						cout<<"第"<<index<<"顶点不存在！"<<endl;
					cout<<endl;
					break;
			case 4:														// 修改顶点
					cout<<"请输入要更改的顶点: ";
					cin>>u;
					cout<<"请输入更改后顶点: ";
					cin>>v;
					PutVex(G,u,v);
					cout<<"顶点值修后的网为“"<<endl;
					DispG(G);
					cout<<endl;
					break;
			case 5:														// 增加顶点
					cout<<"请输入要增加的顶点: ";
					cin>>v;
					InsertVex(G,v);
					cout<<"插入顶点和相应边后的网为“"<<endl;
					DispG(G);
					cout<<endl;
					break;
			case 6:														// 删除顶点
					cout<<"请输入要删除的顶点:";
					cin>>v;
					DeleteVex(G,v);
					cout<<"顶点删除后的网为“"<<endl;
					DispG(G);
					cout<<endl;
					break;
			case 7:														// 增加边
					cout<<"请输入要增添边的顶相邻两顶点和权值";
					cin>>u>>v>>weight;
					if(InsertArc(G,u,v,weight))
						cout<<"插入边后的网为“"<<endl;
					DispG(G);
					cout<<endl;
					break;
			case 8:														// 删除边
					cout<<"请输入删除的边相邻两顶点: ";
					cin>>u>>v;
					DeleteArc(G,u,v);
					cout<<"顶点边后的网为“"<<endl;
					DispG(G);
					cout<<endl;
					break;
			case 9:														// 深度优先遍历
					cout<<"从第一个顶点出发深度优先遍历网的序列为: "<<endl;
					DFSTraverse(G);
					cout<<endl;
					break;
			case 10:													// 广度优先遍历
					cout<<"从第一个顶点出发广度优先遍历网的序列为: "<<endl;
					BFSTraverse(G);
					cout<<endl;
					break;
			case 11:													// 显示网
					DispG(G);
					cout<<endl;
					break;
			case 0:
					cout<<"结束运行，Bye-Bye!"<<endl;
					break;
					default:
					cout<<"选择不合理，请重选!"<<endl;
			}//case
		}while(choice!=0);
}//main
		 