1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7
8 using namespacestd;9
10 #define max 50//定义结点最大数量
11 typedef char vertype;//定义结点值域为字符类型
12 char buf[1024];//定义读文件内容时,程序缓冲数组
13 int num;//记录有穷字母表元素的个数
14 int length;//记录States数组的长度
15
16 typedef struct arcnode//图的边信息
17 {18 intadjvex;19 int weight;//边所对应的权值
20 struct arcnode *next;21 }arcnode;22
23 typedef struct vnode//图的结点类型定义
24 {25 vertype data;26 arcnode *next;27 }vnode,adjlist[max];28
29 typedef struct//图的定义
30 {31 adjlist a;32 intvexnum,arcnum;33 }algraph;34
35 typedef struct state//状态的定义
36 {37 setSet;38 charname;39 }state;40
41 state States[max];42
43 int change(algraph g,char p)//将图中结点转化为对应下标
44 {45 inti;46 for(i=0;i
54 void creatp