思路一:
DFS,遇到终点之后进行记录
辅助存储:
std::vector<int> tempPath;
std::vector<std::vector<int>> totalPath;
实现:
//查找无向图的所有最短路径,直接dfs就可以解决了
//记录保存这里用 vector<vector<int>> 插入失败,重新搞一下 OK
// 时间复杂度 O(N + E)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <set>
#define MAX 10
#define INF 999999
int graph[MAX + 1][MAX + 1];
int N, M; //node, edge
int nodeBook[MAX + 1];
int minPath = INF;
std::vector<int> pathNodeVec;
std::vector<std::vector<int>> allShortVec;