-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathSP.h
37 lines (23 loc) · 842 Bytes
/
SP.h
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
#ifndef SP_H
#define SP_H
#include <limits>
#include <list>
#include <optional>
#include <vector>
#include "DirectedEdge.h"
#include "EdgeWeightedDigraph.h"
class SP {
protected:
std::vector<std::optional<DirectedEdge> > edgeTo;
std::vector<double> distTo_;
void relax(const EdgeWeightedDigraph &G, int v);
virtual void onRelaxationSuccess(const EdgeWeightedDigraph &G, int v, const DirectedEdge &e, int w) {}
virtual void afterRelaxation(const EdgeWeightedDigraph &G, int v, const DirectedEdge &e, int w) {}
public:
SP(const EdgeWeightedDigraph &G, int s);
virtual ~SP() = default;
double distTo(int v) const { return distTo_[v]; }
bool hasPathTo(int v) const { return distTo_[v] < std::numeric_limits<double>::infinity(); }
std::list<DirectedEdge> pathTo(int v) const;
};
#endif //SP_H