OpenTTD Source: LinkGraph::BaseEdge Struct Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields | Friends
LinkGraph::BaseEdge Struct Reference

An edge in the link graph. More...

`#include <linkgraph.h>`

## Public Member Functions
| BaseEdge (NodeID dest_node=INVALID_NODE)
| Create an edge.
uint32_t | TravelTime () const
| Get edge's average travel time.
TimerGameEconomy::Date | LastUpdate () const
| Get the date of the last update to any part of the edge's capacity.
void | Update (uint capacity, uint usage, uint32_t time, EdgeUpdateModes modes)
| Update an edge.
void | Restrict ()
void | Release ()
bool | operator< (const BaseEdge &rhs) const
| Comparison operator based on `dest_node`.
bool | operator< (NodeID rhs) const

## Data Fields
uint | capacity = 0
| Capacity of the link.
uint | usage = 0
| Usage of the link.
uint64_t | travel_time_sum = 0
| Sum of the travel times of the link, in ticks.
TimerGameEconomy::Date | last_unrestricted_update {}
| When the unrestricted part of the link was last updated.
TimerGameEconomy::Date | last_restricted_update {}
| When the restricted part of the link was last updated.
NodeID | dest_node = INVALID_NODE
| Destination of the edge.

## Friends
bool | operator< (NodeID lhs, const LinkGraph::BaseEdge &rhs)

## Detailed Description

An edge in the link graph.

Corresponds to a link between two stations.

Definition at line 42 of file linkgraph.h.

## Constructor & Destructor Documentation

## ◆ BaseEdge()

LinkGraph::BaseEdge::BaseEdge | ( | NodeID | dest_node = `INVALID_NODE` | ) |

Create an edge.

Definition at line 38 of file linkgraph.cpp.

References capacity, dest_node, TimerGameConst< struct Economy >::INVALID_DATE, last_restricted_update, last_unrestricted_update, travel_time_sum, and usage.

## Member Function Documentation

## ◆ LastUpdate()

TimerGameEconomy::Date LinkGraph::BaseEdge::LastUpdate | ( |  | ) | const
| inline

Get the date of the last update to any part of the edge's capacity.

Returns
  Last update.

Definition at line 62 of file linkgraph.h.

References last_restricted_update, and last_unrestricted_update.

## ◆ operator<() [1/2]

bool LinkGraph::BaseEdge::operator< | ( | const BaseEdge & | rhs | ) | const
| inline

Comparison operator based on `dest_node`.

Definition at line 69 of file linkgraph.h.

References dest_node.

## ◆ operator<() [2/2]

bool LinkGraph::BaseEdge::operator< | ( | NodeID | rhs | ) | const
| inline

Definition at line 74 of file linkgraph.h.

## ◆ Release()

void LinkGraph::BaseEdge::Release | ( |  | ) |
| inline

Definition at line 66 of file linkgraph.h.

## ◆ Restrict()

void LinkGraph::BaseEdge::Restrict | ( |  | ) |
| inline

Definition at line 65 of file linkgraph.h.

## ◆ TravelTime()

uint32_t LinkGraph::BaseEdge::TravelTime | ( |  | ) | const
| inline

Get edge's average travel time.

Returns
  Travel time, in ticks.

Definition at line 56 of file linkgraph.h.

References capacity.

Referenced by LinkGraphOverlay::AddLinks(), and MultiCommodityFlow::Dijkstra().

## ◆ Update()

void LinkGraph::BaseEdge::Update | ( | uint | capacity,
|  | uint | usage,
|  | uint32_t | travel_time,
|  | EdgeUpdateModes | modes
| ) |  |

Update an edge.

If mode contains UM_REFRESH refresh the edge to have at least the given capacity and usage, otherwise add the capacity, usage and travel time. In any case set the respective update timestamp(s), according to the given mode.

Parameters

  capacity | Capacity to be added/updated.
  usage | Usage to be added.
  travel_time | Travel time to be added, in ticks.
  mode | Update mode to be applied.

Definition at line 217 of file linkgraph.cpp.

References TimerGameEconomy::date, Increase, Refresh, Restricted, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Unrestricted.

## Friends And Related Symbol Documentation

## ◆ operator<

bool operator< | ( | NodeID | lhs,
|  | const LinkGraph::BaseEdge & | rhs
| ) |  |
| friend

Definition at line 79 of file linkgraph.h.

## Field Documentation

## ◆ capacity

uint LinkGraph::BaseEdge::capacity = 0

Capacity of the link.

Definition at line 43 of file linkgraph.h.

Referenced by LinkGraph::BaseNode::AddEdge(), Path::AddFlow(), LinkGraphOverlay::AddLinks(), BaseEdge(), MultiCommodityFlow::Dijkstra(), LinkGraph::Merge(), and TravelTime().

## ◆ dest_node

NodeID LinkGraph::BaseEdge::dest_node = INVALID_NODE

Destination of the edge.

Definition at line 48 of file linkgraph.h.

Referenced by BaseEdge(), operator<(), LinkGraphJob::NodeAnnotation::operator[](), and LinkGraphJob::NodeAnnotation::operator[]().

## ◆ last_restricted_update

TimerGameEconomy::Date LinkGraph::BaseEdge::last_restricted_update {}

When the restricted part of the link was last updated.

Definition at line 47 of file linkgraph.h.

Referenced by LinkGraph::BaseNode::AddEdge(), BaseEdge(), and LastUpdate().

## ◆ last_unrestricted_update

TimerGameEconomy::Date LinkGraph::BaseEdge::last_unrestricted_update {}

When the unrestricted part of the link was last updated.

Definition at line 46 of file linkgraph.h.

Referenced by LinkGraph::BaseNode::AddEdge(), BaseEdge(), and LastUpdate().

## ◆ travel_time_sum

uint64_t LinkGraph::BaseEdge::travel_time_sum = 0

Sum of the travel times of the link, in ticks.

Definition at line 45 of file linkgraph.h.

Referenced by LinkGraph::BaseNode::AddEdge(), BaseEdge(), and LinkGraph::Merge().

## ◆ usage

uint LinkGraph::BaseEdge::usage = 0

Usage of the link.

Definition at line 44 of file linkgraph.h.

Referenced by LinkGraph::BaseNode::AddEdge(), LinkGraphOverlay::AddLinks(), BaseEdge(), and LinkGraph::Merge().

The documentation for this struct was generated from the following files:

- src/linkgraph/linkgraph.h
- src/linkgraph/linkgraph.cpp