1. Purpose
1) Obtain all paths from the specified start and end points according to the directed graph; 2) Directly solve the shortest path between two points.
2. Example effect
2.1 Raw data
The starting and ending points of the route are arranged as follows:
// 共计12个顶点,19条边。 (起点,终点,1)最后的1代表起点终点是连通的。
起点,终点,1:2 4 1
起点,终点,1:9 10 1
起点,终点,1:8 11 1
起点,终点,1:4 12 1
起点,终点,1:11 12 1
起点,终点,1:1 2 1
起点,终点,1:3 2 1
起点,终点,1:1 3 1
起点,终点,1:3 4 1
起点,终点,1:3 6 1
起点,终点,1:1 5 1
起点,终点,1:6 5 1
起点,终点,1:6 7 1
起点,终点,1:6 9 1
起点,终点,1:7 9 1
起点,终点,1:9 10 1
起点,终点,1:5 8 1
起点,终点,1:8 7 1
起点,终点,1:10 11 1
2.1 Program calculation effect
Enter start and end points: 1 and 12.
3. Source code
// GraphDFS.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include<stdio.h>
#include<math.h>
using namespace std;
int mapMatrix[1000][1000] = {
0 };///map[i][j]为0表示i, j两点之间不通,为1表示有一条路
int stack[200], markV[500] = {
0 };
int nTop = 0;
const