From b19bd8d8a41664328f33c9b459b2b0100f0b303f Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Fri, 9 Nov 2012 12:17:46 +1100 Subject: Add an MCF operator to the separate solver For the solver utility it'd be good to have MCF problems, so here they are! Format is: MCF(cost*) Supplies is a [int,int,int,...], where each int represents a new node Arcs is [int:int, int:int, int:int, ...] where each int:int pair represents an edge from the first to the second (1 indexed from the "supplies" array). Costs is the argument to the function. There must be as many costs as arcs, and they are set from left to right, in order. --- impl/Complete.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'impl/Complete.hpp') diff --git a/impl/Complete.hpp b/impl/Complete.hpp index e3ec15a..664d71f 100644 --- a/impl/Complete.hpp +++ b/impl/Complete.hpp @@ -99,6 +99,16 @@ struct Complete { template friend std::ostream& operator<<(std::ostream&, const Complete&); + template + S as() const { + if (_infinity) { + if (_value > 0) + return infinity(); + return -infinity(); + } + return (S) _value; + } + private: T _value; bool _infinity; -- cgit v1.2.3