数据结构学习笔记————图 :陈越数据结构编程作业:拯救007

这篇博客详细记录了学习陈越数据结构课程中关于图的部分,并通过一个名为'拯救007'的编程作业进行实战讲解。内容涵盖图的基本概念、图的存储结构(邻接矩阵和邻接表)以及深度优先搜索和广度优先搜索算法的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <iostream>
#include<cstdlib>
#include<math.h>
#include <string>
#include<cstdlib>
using namespace std;
class adj_node
{
public:
	int index;
	adj_node *next;
	inline adj_node()
	{
		next = NULL;
	}
	inline adj_node(adj_node * next_)
	{
		next = next_;
	}
	inline adj_node(int p, adj_node* next_ = NULL)
	{
		index = p;
		next = next_;
	}

};
class vex_node
{
public:
	int x;
	int y;
	adj_node *next;
	inline vex_node()
	{
		next = NULL;
	}
	inline vex_node(int x_, int y_, adj_node *next_ = NULL)
	{
		x = x_;
		y = y_;
		next = next_;
	}
};
class graph
{
public:
	vex_node * vex_table;
	int vex_num;
	int  distance;
	bool *tag;
	string answer;
	//按照顶点数和默认距离构造图
	inline graph(int vex_num_,int distance_)
	{
		tag = new bool[vex_num_];
		vex_num = vex_num_;
		distance = distance_;
		vex_table = new vex_node[vex_num_];
		for (int i = 0; i < vex_num; i++)
		{
			tag[i] = 0;
		}

	}

	//插入坐标为(x y)的顶点 并和该顶点周围距离小于dist
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值