Boa tarde!
Estou com esse código aqui, e não consigo entender exatamente o que ele faz, alguém consegue "decifrar" pra mim?
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
#define INFO 1e9
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
vi p;
int distancia[10];
vector<vii> AdjList;
int a, V, b, w, s, t, cas=1;
priority_queue<ii, vector<ii>, greater<ii> > porque;
void printPath(int t) {
if (t == s)
printf("%d", s+1);
else {
printPath(p[t]);
printf(" %d", t+1);
}
}
void inicia() {
for (int i=0 ; i<10 ; i++)
distancia = INFO;
}
int dijkstra() {
porque = priority_queue<ii, vector<ii>, greater<ii> >();
inicia();
porque.push(ii(0, s));
distancia = 0;
while (!porque.empty()) {
ii front = porque.top(); porque.pop();
int d=front.first, u=front.second;
if (u == t) return d;
if (distancia == d) {
for (int i=0 ; i<AdjList.size() ; i++) {
ii v = AdjList;
if (distancia + v.second < distancia[v.first]) {
distancia[v.first] = distancia + v.second;
p[v.first] = u;
porque.push(ii(distancia[v.first], v.first));
}
}
}
}
}
int main() {
while (scanf("%d", &V), V) {
AdjList.assign(V, vii());
for (int i=0 ; i<V ; i++) {
scanf("%d", &a);
while (a--) {
scanf("%d %d", &b, &w);
b--;
AdjList.push_back(ii(b, w));
}
}
p.assign(V, 0);
scanf("%d %d", &s, &t);
s--, t--;
dijkstra();
printf("Case %d: Path = ", cas++);
printPath(t);
printf("; %d second delay\n", distancia[t]);
}
}