目录
1.Dijkstra算法
1.1邻接矩阵
1.2邻接表
1.3路径
1.4新增边权
1.5新增点权
1.6最短路径数
1.7Emergency
1.8配合DFS
1.8.1找出路径
1.8.2DFS遍历
1.8.3 Travel Plan
const int maxv=1000;
const int inf = 100000000;
int n,g[maxv][maxv];
int d[maxv];
bool vis[maxv] = {false};
void dijkstra(int s){
fill(d,d+maxv,inf);
d[s] = 0;
for(int i=0;i
const int maxv=1000;
const int inf = 100000000;
struct node{//目标顶点,边权
int v,dis;
};
vector adj[maxv];
int n;
int d[maxv];
bool vis[maxv] = {false};
void dijkstra(int s){
fill(d,d+maxv,inf);
d[s] = 0;
for(int i=0;i
void dfs(int s,int v){
if(v==s){
printf("%d\n",s);
return;
}
dfs(s,pre[v]);
printf("%d\n",v);
}
for(int v=0;v
for(int v=0;vw[v]){
w[v] = w[u] + weight[v];
}
}
}
for(int v=0;v
#include
#include
#include
#include
const int maxv = 510;
const int inf = 1000000000;
vector pre[maxv];
void dijkstra(int s){
fill(d,d+maxv,inf);
d[s] = 0;
for(int i=0;i
int optvalue;
vector pre[maxv];
vector path,temppath;
void dfs(int v){
if(v==st){
temppath.push_back(v);
int value;
计算value;
if(value优于optvalue){
optvalue = value;
path = temppath;
}
temppath.pop_back();
return;
}
temppath.push_back(v);
for(int i=0;i
1.8.3 Travel Plan
#include
#include
#include
#include
#include
#include
#include
#include