Linkgraph: Add asymmetric: equal and nearest demand distribution modes

This commit is contained in:
Jonathan G Rennison
2019-04-29 18:36:51 +01:00
parent 79e49cf4a9
commit e7a916d2ce
8 changed files with 178 additions and 41 deletions

View File

@@ -48,6 +48,7 @@ private:
*/
struct NodeAnnotation {
uint undelivered_supply; ///< Amount of supply that hasn't been distributed yet.
uint received_demand; ///< Received demand towards this node.
PathList paths; ///< Paths through this node, sorted so that those with flow == 0 are in the back.
FlowStatMap flows; ///< Planned flows to other nodes.
void Init(uint supply);
@@ -237,6 +238,12 @@ public:
*/
uint UndeliveredSupply() const { return this->node_anno.undelivered_supply; }
/**
* Get amount of supply that hasn't been delivered, yet.
* @return Undelivered supply.
*/
uint ReceivedDemand() const { return this->node_anno.received_demand; }
/**
* Get the flows running through this node.
* @return Flows.
@@ -272,6 +279,15 @@ public:
this->node_anno.undelivered_supply -= amount;
(*this)[to].AddDemand(amount);
}
/**
* Receive some demand, adding demand to the respective edge.
* @param amount Amount of demand to be received.
*/
void ReceiveDemand(uint amount)
{
this->node_anno.received_demand += amount;
}
};
/**