// dfs.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <stack>
#include <map>
#include <vector>
using namespace std;
#define NotFound -1
#define StartNode 0
#define EndNode 4
map<int,map<int,int>> visited;
map<int,vector<int>> ajdTable;
int isInStack[5];
//不在栈中且路径没有访问过
int getNextPoint(int point){
vector<int>::iterator it;
for ( it=ajdTable[point].begin() ; it != ajdTable[point].end(); it++ ){
if ((visited[point][*it]!=1) && (isInStack[*it]!=1))
return *it;
}
return NotFound;
}
void setNoVisted(int point){
vector<int>::iterator it;
for ( it=ajdTable[point].begin() ; it != ajdTable[point].end(); it++ ){
visited[point][*it] = 0;
}
}
void dfs_stack(int start, int end, int n){
int s_top,n_point;
for(int i = 0;i < n; i++){
i
深搜(非递归)实现获取两点之间的路径(起点和终点不重合)
最新推荐文章于 2022-07-14 17:44:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)