void ShowMainMenu()
{
cout<<"\n";
cout<<"
***************图的基本操作及应用******************\n";
cout<<"
*
1 无向图的基本操作及应用
*\n";
cout<<"
*
2 无向网的基本操作及应用
*\n";
cout<<"
*
3 有向图的基本操作及应用
*\n";
cout<<"
*
4 有向网的基本操作及应用
*\n";
cout<<"
*
5 退出
*\n";
cout<<"
***************************************************\n";
}
void UDG()
{
MGraph MG;
ALGraph ALG;
int n;
do
{
cout<<"\n";
cout<<"
***************无向图的基本操作及应用***************\n";
cout<<"
*
1 创建无向图的邻接矩阵
*\n";
cout<<"
*
2 创建无向图的邻接表
*\n";
cout<<"
*
3 无向图的深度优先遍历
*\n";
cout<<"
*
4 无向图的广度优先遍历
*\n";
cout<<"
*
5 退出
*\n";
cout<<"
****************************************************\n";
cin>>n;
switch(n){
case 1:
CreatUDG_M(MG);
break;
case 2:
CreatUDG_ALG(ALG);
dispgraph(ALG);
break;
case 3:
break;
case 4:
break;
default:
if (n!=5)
cout<<"错误,重新输入\n";
}
}while(n!=5);
}
void UDN()
{
MGraph MN;
ALGraph ALN;
int n;
do{
cout<<"\n";
cout<<"
***************无向网的基本操作及应用***************\n";
cout<<"
*
1 创建无向网的邻接矩阵
*\n";
cout<<"
*
2 创建无向网的邻接表
*\n";
cout<<"
*
3 prim算法求最小生成树
*\n";
cout<<"
*
4 kraskal算法求最小生成树
*\n";
cout<<"
*
5 退出
*\n";
cout<<"
****************************************************\n";
cin>>n;
switch(n){
case 1:
CreatUDN_M(MN);
break;
case 2:
CreatUDN_ALG(ALN);
dispgraph_N(ALN);
break;
case 3:
break;
case 4:
break;
default:
if (n!=5)
cout<<"错误,重新输入\n";
}
}while(n!=5);
}
void DG()
{
int n;
do
{
cout<<"\n";
cout<<"
***************有向图的基本操作及应用***************\n";
cout<<"
*
1 创建有向图的邻接矩阵
*\n";
cout<<"
*
2 创建有向图的邻接表
*\n";
cout<<"
*
3 拓扑排序
*\n";
cout<<"
*
4 退出
*\n";
cout<<"
****************************************************\n";
cin>>n;
switch(n){
case 1:
break;
case 2:
break;
case 3:
break;
default:
if (n!=4)
cout<<"错误,重新输入\n";
}
}while(n!=4);
}
void DN()
{
int n;
do{
cout<<"\n";
cout<<"
***************有向网的基本操作及应用***************\n";
cout<<"
*
1 创建有向网的邻接矩阵
*\n";
cout<<"
*
2 创建有向网的邻接表
*\n";
cout<<"
*
3 关键路径
*\n";
cout<<"
*
4 单源顶点最短路径问题
*\n";
cout<<"
*
5 每对顶点间最短路径问题
*\n";
cout<<"
*
6 退出
*\n";
cout<<"
****************************************************\n";
cin>>n;
switch(n){
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
if (n!=6)
cout<<"错误,重新输入\n";
}
}while(n!=6);
}
void main()
{
int n;
do{
ShowMainMenu();
cin>>n;
switch(n){
case 1:
UDG();
break;
case 2:
UDN();
break;
case 3:
DG();
break;
case 4:
DN();
break;
default:
if (n!=5)
cout<<"错误,重新输入\n";
}
}while(n!=5);
}