#include <stdio.h>
#include <stdlib.h>
//定义图的最多有20个顶点
#define MAX_VERTEX_NUM 20
/*******定义图的顶点**************/
struct node{
char data;
int flag;//标志位(1:访问过 0:未访问 )
struct arcNode * firstArcNode;
};
struct arcNode{
int no;
struct arcNode * nextArcNode;
};
/*******定义队列的结构体**********/
struct qNode{
struct node * Node;
struct qNode * nextQNode;
};
struct queue{
struct qNode * front;
struct qNode * rear;
};
/**********方法声明*************/
//图
void createArcNode(struct node * Node);
void rangeTraverse(struct node arrayList[],int position);
//队列
struct queue * init();
void inQueue(struct queue * Queue,struct node * Node);
struct node * outQueue(struct queue * Queue);
int isEmpty(struct queue * Queue);
/**********Main函数***********/
int main(int argc, char *argv[])
{
struct node arrayList[MAX_VERTEX_NUM];
char ch;
int flag = 1;//标志位,0表示输入结束
c语言实现图的广度优先遍历
最新推荐文章于 2024-03-21 22:16:18 发布
本文介绍如何使用C语言实现图的广度优先遍历。通过定义图的顶点、弧点和队列结构体,以及相应的创建连接、遍历和队列操作函数,展示了完整的代码实现过程。

最低0.47元/天 解锁文章
5304

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



