40#ifndef ANTHOCNET_CORE_SHORTEST_PATH_H
41#define ANTHOCNET_CORE_SHORTEST_PATH_H
55 static double unreachable() {
return std::numeric_limits<double>::infinity(); }
60 int nodeCount()
const {
return static_cast<int>(m_adj.size()); }
71 void addEdge(
int from,
int to,
double weight = 1.0);
80 int source()
const {
return m_source; }
98 std::vector<std::vector<Edge> > m_adj;
99 std::vector<double> m_dist;
100 std::vector<int> m_firstHop;
int source() const
The source of the last computeFrom(), or kNoNode before the first.
static const int kNoNode
Returned by firstHopTo() when there is no path (and for the source).
void computeFrom(int source)
Run Dijkstra from source. Results are readable until the next call.
double distanceTo(int node) const
Cost of the shortest path source -> node, or unreachable().
void addEdge(int from, int to, double weight=1.0)
Add a DIRECTED edge.
ShortestPathGraph(int nodeCount)
A graph over node ids [0, nodeCount).
int firstHopTo(int node) const
The node after source on the chosen shortest path to node: kNoNode when unreachable,...
std::size_t edgeCount() const
Number of directed edges added (the oracle reports it as a diagnostic).
static double unreachable()
Returned by distanceTo() when there is no path.
AntHistoryTracker: (src, seqNum) duplicate detection.