1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once


#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.


#include "graph/internal/bfs.hpp"
#include "graph/internal/01bfs.hpp"
#include "graph/internal/dijkstra.hpp"

#include "adaptor/vector.hpp"


namespace uni {


template<class Node, class Prev, class Res>
void restore_path(Node back, const Prev& prev, Res *const res) {
    res->clear();
    while(back >= 0) {
        res->emplace_back(back);
        back = prev[back];
    }

    std::ranges::reverse(*res);
}


template<class Node, class Prev, class Res = uni::vector<Node>>
uni::vector<Node> restore_path(Node back, const Prev& prev) {
    uni::vector<Node> res;
    restore_path(back, prev, &res);
    return res;
}


}