#include<string> 
#include "LinkQueue.h"
#include "ALGraph.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;
	ALGraph<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;
					InsertArc(G,u,v);
					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;
					break;
			}//case
		}while(choice!=0);
}//main
