# HG changeset patch # User jacint # Date 1131112402 0 # Node ID 3915867b6975357bd7a900a433db75884502c39a # Parent 896464fe9fbb16785e3cb26beab7bc6b28a66560 throwing an exception if s=t diff -r 896464fe9fbb -r 3915867b6975 lemon/preflow.h --- a/lemon/preflow.h Fri Nov 04 13:20:24 2005 +0000 +++ b/lemon/preflow.h Fri Nov 04 13:53:22 2005 +0000 @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -88,10 +89,21 @@ static const int H0=20; static const int H1=1; + public: + + ///\ref Exception for the case when s=t. + + ///\ref Exception for the case when the source equals the target. + class InvalidArgument : public lemon::LogicError { public: - + virtual const char* exceptionName() const { + return "lemon::Preflow::InvalidArgument"; + } + }; + + ///Indicates the property of the starting flow map. - + ///Indicates the property of the starting flow map. ///The meanings are as follows: ///- \c ZERO_FLOW: constant zero flow @@ -126,8 +138,8 @@ AFTER_PREFLOW_PHASE_2 }; - protected: - FlowEnum flow_prop; + protected: + FlowEnum flow_prop; StatusEnum status; // Do not needle this flag only if necessary. public: @@ -146,8 +158,11 @@ const CapacityMap& _cap, FlowMap& _f) : _g(&_gr), _source(_s), _target(_t), _capacity(&_cap), _flow(&_f), _node_num(countNodes(_gr)), level(_gr), excess(_gr,0), - flow_prop(NO_FLOW), status(AFTER_NOTHING) { } - + flow_prop(NO_FLOW), status(AFTER_NOTHING) { + if ( _source==_target ) + throw InvalidArgument(); + } + ///Runs the preflow algorithm.