///////////////////////////
// //
// 图功能函数 Graph.h //
// //
//////////////////////////
#include"Graph.h"
template<class NameType,class DisType>
void Graph_Creat(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.Creat();
}
template<class NameType,class DisType>
void Graph_DFS(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.DFS();
}
template<class NameType,class DisType>
void Graph_BFS(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.BFS();
}
template<class NameType,class DisType>
void Graph_PRINT(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.PrintNode();
}
void GRAPH()
{
Graph<char,int> GraphOPP;
do
{
cout<<"图的操作: "<<endl
<<" 1) 建立图"<<endl
<<" 2) 图的深度优先搜索"<<endl
<<" 3) 图的广度优先搜索"<<endl
<<" 4) 打印图中各结点"<<endl
<<" X) 退出排序操作"<<endl;
int item;
cin>>item;
switch(item)
{
case 1: Graph_Creat(GraphOPP); break;
case 2: Graph_DFS(GraphOPP); break;
case 3: Graph_BFS(GraphOPP); break;
case 4: Graph_PRINT(GraphOPP); break;
default: return ;
}
}while(true);
}
// //
// 图功能函数 Graph.h //
// //
//////////////////////////
#include"Graph.h"
template<class NameType,class DisType>
void Graph_Creat(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.Creat();
}
template<class NameType,class DisType>
void Graph_DFS(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.DFS();
}
template<class NameType,class DisType>
void Graph_BFS(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.BFS();
}
template<class NameType,class DisType>
void Graph_PRINT(Graph<NameType,DisType> &GraphOPP)
{
GraphOPP.PrintNode();
}
void GRAPH()
{
Graph<char,int> GraphOPP;
do
{
cout<<"图的操作: "<<endl
<<" 1) 建立图"<<endl
<<" 2) 图的深度优先搜索"<<endl
<<" 3) 图的广度优先搜索"<<endl
<<" 4) 打印图中各结点"<<endl
<<" X) 退出排序操作"<<endl;
int item;
cin>>item;
switch(item)
{
case 1: Graph_Creat(GraphOPP); break;
case 2: Graph_DFS(GraphOPP); break;
case 3: Graph_BFS(GraphOPP); break;
case 4: Graph_PRINT(GraphOPP); break;
default: return ;
}
}while(true);
}
这是一个关于图操作的博客,包括图的创建、深度优先搜索(DFS)、广度优先搜索(BFS)以及打印图中节点的功能。通过`Graph.h`头文件实现模板类`Graph<NameType, DisType>`的相关操作,并提供了`GRAPH()`函数用于交互式选择执行这些操作。"
120632640,340383,Qt自定义控件实现魔法小鱼MagicFish,"['Qt', '自定义控件', 'GUI开发', '软件开发']

被折叠的 条评论
为什么被折叠?



