资源简介
求两点直接所有路径代码,有注释
花了很长时间搞懂做好的。。。。。
代码片段和文件信息
// DFS.cpp : Defines the entry point for the console application.
//
// bfs.cpp : Defines the entry point for the console application.
//
#include “stdafx.h“
#include
#include
#include
#include
using namespace std;
stack not_explored;
int *discovered;
class EdgeNode;
typedef EdgeNode * EdgeList;
//边链表
class EdgeNode
{
public:
int vertexNum; //边界点在定点表中的下标
int weight; //权值
EdgeNode * nextEdgeNode; //指针字段,指向下一个链结点
};
//顶点表
class Vertex
{
public:
char vertex; //顶点信息
EdgeList edgeList; //边链表头指针
};
class GraphList
{
public:
int n; //图中定点个数
Vertex *vertexes; //顶点表
};
int DFS_Search(int nGraphList gl)
{
if (n <= 1)
{
return 0;
}
else
{
int node_to_explore;
bool flag ;
EdgeNode *p = new EdgeNode();
not_explored.push(0);
discovered[0] = 1;
while(!not_explored.empty())
{
flag = false;
node_to_explore = not_explored.top();
//not_explored.push();注意不要从栈内删除;因为回溯时候要用到此步为关键点
//p = new EdgeNode();
p = gl.vertexes[node_to_explore].edgeList;
if (p)
{
while (p)
{
if (discovered[p->vertexNum] =
相关资源
- C++语言实现一些基本算法(两点距离
- Boost Graph Library:The User Guide and Referen
- 求图中任意两点的最短路径和全部路
- MATLAB图论工具箱,matlabBGL
- 八数码问题数字华容道,九宫格深度
- MFC实现迷宫搜索——Easy参考
- 图的邻接矩阵表示,深度优先遍历,
- 已知两点经纬度,求距离和方位
- 无向图 破圈法求最小生成树
- 八数码 -深度优先算法
- Floyd算法求任意两点间的最短路径
- 求解无向图中任意两点之间的所有路
- ACM竞赛常用算法及代码
- 求长方体上任意两点间的最短表面距
- 高效!!求两点之间的所有路径
- 两点式求点到直线的距离
- 定义采用邻接矩阵存储的图结构封装
- 根据经纬度坐标计算实际两点距离
评论
共有 条评论