AntHocNet 2.0.0
Paper-faithful ant-colony ad hoc routing: the shared core and its adapters
Loading...
Searching...
No Matches
anthocnet::core::ShortestPathGraph Class Reference

#include <anthocnet/core/shortest_path.h>

Public Member Functions

 ShortestPathGraph (int nodeCount)
 A graph over node ids [0, nodeCount).
 
int nodeCount () const
 
void addEdge (int from, int to, double weight=1.0)
 Add a DIRECTED edge.
 
std::size_t edgeCount () const
 Number of directed edges added (the oracle reports it as a diagnostic).
 
void computeFrom (int source)
 Run Dijkstra from source. Results are readable until the next call.
 
int source () const
 The source of the last computeFrom(), or kNoNode before the first.
 
double distanceTo (int node) const
 Cost of the shortest path source -> node, or unreachable().
 
int firstHopTo (int node) const
 The node after source on the chosen shortest path to node: kNoNode when unreachable, and kNoNode for the source itself (a node needs no first hop to reach itself).
 

Static Public Member Functions

static double unreachable ()
 Returned by distanceTo() when there is no path.
 

Static Public Attributes

static const int kNoNode = -1
 Returned by firstHopTo() when there is no path (and for the source).
 

Detailed Description

Definition at line 50 of file shortest_path.h.

Constructor & Destructor Documentation

◆ ShortestPathGraph()

anthocnet::core::ShortestPathGraph::ShortestPathGraph ( int  nodeCount)
explicit

A graph over node ids [0, nodeCount).

Member Function Documentation

◆ unreachable()

static double anthocnet::core::ShortestPathGraph::unreachable ( )
inlinestatic

Returned by distanceTo() when there is no path.

Definition at line 55 of file shortest_path.h.

◆ nodeCount()

int anthocnet::core::ShortestPathGraph::nodeCount ( ) const
inline

Definition at line 60 of file shortest_path.h.

◆ addEdge()

void anthocnet::core::ShortestPathGraph::addEdge ( int  from,
int  to,
double  weight = 1.0 
)

Add a DIRECTED edge.

Callers modelling a bidirectional radio/ISL link add both directions; the oracle does, because a one-way link is not a usable route.

Throws std::invalid_argument on an out-of-range endpoint or a negative weight — both are caller bugs that would otherwise surface as a wrong route rather than as a failure.

◆ edgeCount()

std::size_t anthocnet::core::ShortestPathGraph::edgeCount ( ) const
inline

Number of directed edges added (the oracle reports it as a diagnostic).

Definition at line 74 of file shortest_path.h.

◆ computeFrom()

void anthocnet::core::ShortestPathGraph::computeFrom ( int  source)

Run Dijkstra from source. Results are readable until the next call.

◆ source()

int anthocnet::core::ShortestPathGraph::source ( ) const
inline

The source of the last computeFrom(), or kNoNode before the first.

Definition at line 80 of file shortest_path.h.

◆ distanceTo()

double anthocnet::core::ShortestPathGraph::distanceTo ( int  node) const

Cost of the shortest path source -> node, or unreachable().

◆ firstHopTo()

int anthocnet::core::ShortestPathGraph::firstHopTo ( int  node) const

The node after source on the chosen shortest path to node: kNoNode when unreachable, and kNoNode for the source itself (a node needs no first hop to reach itself).

Member Data Documentation

◆ kNoNode

const int anthocnet::core::ShortestPathGraph::kNoNode = -1
static

Returned by firstHopTo() when there is no path (and for the source).

Definition at line 53 of file shortest_path.h.


The documentation for this class was generated from the following file: