对上面所构造的无向图,进行深度优先遍历和广度优先遍历,输出遍历序列
(2012-06-27 15:33:12)
标签:
无向图广度优先遍历深度优先遍历邻接矩阵深度优先搜索it |
#include <stdio.h>
#include <stdlib.h>
#define n 4
#define e 5
#define maxsize 10
typedef struct{
char data[maxsize];
int front,rear;
}sequeue;
typedef char vextype;
typedef int adjtype;
typedef struct
{vextype vexs[n];
}graph;
graph *p;
sequeue *q;
int visited[n]={0,0,0,0};
//无向图的邻接矩阵建立
void creatgraph()
{
}
//深度优先遍历无向图
void DFS(int i)
{
}
//对列入队
void
{if(sq->front==(sq->rear+1)%maxsize)
{printf("queue is full"); }
else
{sq->rear=sq->rear+1%maxsize;
}
}
//对列出队
char dequeue(sequeue *q)
{if(q->rear==q->front)
{printf("queue is empty");return NULL;}
else
{q->front=(q->front+1)%maxsize;
}
}
//广度优先遍历无向图
void BFS(int k)
{
}
void main()
{p=(graph*)malloc(sizeof(graph));
}