//编程建立有向图的邻接矩阵存储结构,实现图的深度优先搜索算法。
//(1)采用邻接矩阵存储结构创建一个有向图。
//(2)图的深度优先搜索算法的实现。
//
//输入以下测试数据:
//测试数据: 有向图:
//4 4
//A B C D
//A B 1
//A C 1
//D B 1
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#include"stdio.h"
#include"stdlib.h"
#define MaxInt 32767
#define MAX_VEX 20 //最大顶点个数
typedef enum{FALSE,TRUE} boolean;
typedef char VertexType;
typedef struct{ //图的邻接矩阵存储结构
VertexType vexs[MAX_VEX]; //顶点向量
int arcs[MAX_VEX][MAX_VEX]; //邻接矩阵
int vexnum,arcnum; //图的当前顶点数和弧数
}MGraph;
boolean visited[MAX_VEX]; //访问标志数组
//图 G 中查找元素 c 的位置
int Locate(MGraph G,char c){
for(int i=0;i<G.vexnum;i++)
if(G.vexs[i]==c) return i;
return -1;
}
//创建有向网的邻接矩阵存储结构
void CreateUDN(MGraph &G){
int i,j,w,s1,s2;
char a,b,c,