/*
* File name : graph.cpp
* Function : 图的学习, 邻接矩阵 深度优先遍历和广度优先遍历 C++实现
* Created on : 2016年5月26日
* Author : beijiwei@qq.com
* Copyright : 欢迎大家和我一起交流学习,转载请保持源文件的完整性。
任何单位和个人不经本人允许不得用于商业用途
*/
#include <cstdio>
#include <iostream>
#pragma warning(disable:4996)
using namespace std;
typedef char Vertex_t;
typedef int Edge_t;
#define MAX 10
#define MVALUE 65535
typedef struct
{
Vertex_t vertex[MAX];
int vertex_mark[MAX];
Edge_t edge[MAX][MAX];
int vertex_num;
int edge_num;
}Graph;
/*************************************************************************************************/
typedef struct {
int store[MAX * MAX];
int head;
int tail;
}Squeue;
void queue_init(Squeue & Q)
{
Q.head=0;
Q.tail=0;
}
void queue_in(Squeue & Q, Vertex_t V)
{
if( Q.tail == MAX * MAX )
cout<<"out of index"<<endl;
Q.st
图的邻接矩阵表示 DFS 和BFS C++实现
最新推荐文章于 2024-05-24 01:41:01 发布
这篇博客介绍了如何使用C++实现图的邻接矩阵表示,并提供了深度优先搜索(DFS)和广度优先搜索(BFS)的遍历算法。代码包括创建图、显示图、以及进行DFS和BFS操作。
摘要由CSDN通过智能技术生成