Index: doc/groups.dox
===================================================================
--- doc/groups.dox	(revision 590)
+++ doc/groups.dox	(revision 609)
@@ -21,5 +21,5 @@
 /**
 @defgroup datas Data Structures
-This group contains the several data structures implemented in LEMON.
+This group describes the several data structures implemented in LEMON.
 */
 
@@ -143,5 +143,5 @@
 \brief Graph types between real graphs and graph adaptors.
 
-This group contains some graph types between real graphs and graph adaptors.
+This group describes some graph types between real graphs and graph adaptors.
 These classes wrap graphs to give new functionality as the adaptors do it.
 On the other hand they are not light-weight structures as the adaptors.
@@ -153,5 +153,5 @@
 \brief Map structures implemented in LEMON.
 
-This group contains the map structures implemented in LEMON.
+This group describes the map structures implemented in LEMON.
 
 LEMON provides several special purpose maps and map adaptors that e.g. combine
@@ -166,5 +166,5 @@
 \brief Special graph-related maps.
 
-This group contains maps that are specifically designed to assign
+This group describes maps that are specifically designed to assign
 values to the nodes and arcs/edges of graphs.
 
@@ -178,5 +178,5 @@
 \brief Tools to create new maps from existing ones
 
-This group contains map adaptors that are used to create "implicit"
+This group describes map adaptors that are used to create "implicit"
 maps from other maps.
 
@@ -241,5 +241,5 @@
 \brief Two dimensional data storages implemented in LEMON.
 
-This group contains two dimensional data storages implemented in LEMON.
+This group describes two dimensional data storages implemented in LEMON.
 */
 
@@ -249,5 +249,5 @@
 \brief %Path structures implemented in LEMON.
 
-This group contains the path structures implemented in LEMON.
+This group describes the path structures implemented in LEMON.
 
 LEMON provides flexible data structures to work with paths.
@@ -265,5 +265,5 @@
 \brief Auxiliary data structures implemented in LEMON.
 
-This group contains some data structures implemented in LEMON in
+This group describes some data structures implemented in LEMON in
 order to make it easier to implement combinatorial algorithms.
 */
@@ -271,8 +271,8 @@
 /**
 @defgroup algs Algorithms
-\brief This group contains the several algorithms
+\brief This group describes the several algorithms
 implemented in LEMON.
 
-This group contains the several algorithms
+This group describes the several algorithms
 implemented in LEMON.
 */
@@ -283,5 +283,5 @@
 \brief Common graph search algorithms.
 
-This group contains the common graph search algorithms, namely
+This group describes the common graph search algorithms, namely
 \e breadth-first \e search (BFS) and \e depth-first \e search (DFS).
 */
@@ -292,5 +292,5 @@
 \brief Algorithms for finding shortest paths.
 
-This group contains the algorithms for finding shortest paths in digraphs.
+This group describes the algorithms for finding shortest paths in digraphs.
 
  - \ref Dijkstra algorithm for finding shortest paths from a source node
@@ -313,18 +313,18 @@
 \brief Algorithms for finding maximum flows.
 
-This group contains the algorithms for finding maximum flows and
+This group describes the algorithms for finding maximum flows and
 feasible circulations.
 
 The \e maximum \e flow \e problem is to find a flow of maximum value between
 a single source and a single target. Formally, there is a \f$G=(V,A)\f$
-digraph, a \f$cap:A\rightarrow\mathbf{R}^+_0\f$ capacity function and
+digraph, a \f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function and
 \f$s, t \in V\f$ source and target nodes.
-A maximum flow is an \f$f:A\rightarrow\mathbf{R}^+_0\f$ solution of the
+A maximum flow is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ solution of the
 following optimization problem.
 
-\f[ \max\sum_{a\in\delta_{out}(s)}f(a) - \sum_{a\in\delta_{in}(s)}f(a) \f]
-\f[ \sum_{a\in\delta_{out}(v)} f(a) = \sum_{a\in\delta_{in}(v)} f(a)
-    \qquad \forall v\in V\setminus\{s,t\} \f]
-\f[ 0 \leq f(a) \leq cap(a) \qquad \forall a\in A \f]
+\f[ \max\sum_{sv\in A} f(sv) - \sum_{vs\in A} f(vs) \f]
+\f[ \sum_{uv\in A} f(uv) = \sum_{vu\in A} f(vu)
+    \quad \forall u\in V\setminus\{s,t\} \f]
+\f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f]
 
 LEMON contains several algorithms for solving maximum flow problems:
@@ -351,28 +351,96 @@
 The \e minimum \e cost \e flow \e problem is to find a feasible flow of
 minimum total cost from a set of supply nodes to a set of demand nodes
-in a network with capacity constraints and arc costs.
+in a network with capacity constraints (lower and upper bounds)
+and arc costs.
 Formally, let \f$G=(V,A)\f$ be a digraph,
 \f$lower, upper: A\rightarrow\mathbf{Z}^+_0\f$ denote the lower and
-upper bounds for the flow values on the arcs,
+upper bounds for the flow values on the arcs, for which
+\f$0 \leq lower(uv) \leq upper(uv)\f$ holds for all \f$uv\in A\f$.
 \f$cost: A\rightarrow\mathbf{Z}^+_0\f$ denotes the cost per unit flow
-on the arcs, and
-\f$supply: V\rightarrow\mathbf{Z}\f$ denotes the supply/demand values
-of the nodes.
-A minimum cost flow is an \f$f:A\rightarrow\mathbf{R}^+_0\f$ solution of
-the following optimization problem.
-
-\f[ \min\sum_{a\in A} f(a) cost(a) \f]
-\f[ \sum_{a\in\delta_{out}(v)} f(a) - \sum_{a\in\delta_{in}(v)} f(a) =
-    supply(v) \qquad \forall v\in V \f]
-\f[ lower(a) \leq f(a) \leq upper(a) \qquad \forall a\in A \f]
-
-LEMON contains several algorithms for solving minimum cost flow problems:
- - \ref CycleCanceling Cycle-canceling algorithms.
- - \ref CapacityScaling Successive shortest path algorithm with optional
+on the arcs, and \f$sup: V\rightarrow\mathbf{Z}\f$ denotes the
+signed supply values of the nodes.
+If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$
+supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with
+\f$-sup(u)\f$ demand.
+A minimum cost flow is an \f$f: A\rightarrow\mathbf{Z}^+_0\f$ solution
+of the following optimization problem.
+
+\f[ \min\sum_{uv\in A} f(uv) \cdot cost(uv) \f]
+\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \geq
+    sup(u) \quad \forall u\in V \f]
+\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f]
+
+The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be
+zero or negative in order to have a feasible solution (since the sum
+of the expressions on the left-hand side of the inequalities is zero).
+It means that the total demand must be greater or equal to the total
+supply and all the supplies have to be carried out from the supply nodes,
+but there could be demands that are not satisfied.
+If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand
+constraints have to be satisfied with equality, i.e. all demands
+have to be satisfied and all supplies have to be used.
+
+If you need the opposite inequalities in the supply/demand constraints
+(i.e. the total demand is less than the total supply and all the demands
+have to be satisfied while there could be supplies that are not used),
+then you could easily transform the problem to the above form by reversing
+the direction of the arcs and taking the negative of the supply values
+(e.g. using \ref ReverseDigraph and \ref NegMap adaptors).
+However \ref NetworkSimplex algorithm also supports this form directly
+for the sake of convenience.
+
+A feasible solution for this problem can be found using \ref Circulation.
+
+Note that the above formulation is actually more general than the usual
+definition of the minimum cost flow problem, in which strict equalities
+are required in the supply/demand contraints, i.e.
+
+\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) =
+    sup(u) \quad \forall u\in V. \f]
+
+However if the sum of the supply values is zero, then these two problems
+are equivalent. So if you need the equality form, you have to ensure this
+additional contraint for the algorithms.
+
+The dual solution of the minimum cost flow problem is represented by node 
+potentials \f$\pi: V\rightarrow\mathbf{Z}\f$.
+An \f$f: A\rightarrow\mathbf{Z}^+_0\f$ feasible solution of the problem
+is optimal if and only if for some \f$\pi: V\rightarrow\mathbf{Z}\f$
+node potentials the following \e complementary \e slackness optimality
+conditions hold.
+
+ - For all \f$uv\in A\f$ arcs:
+   - if \f$cost^\pi(uv)>0\f$, then \f$f(uv)=lower(uv)\f$;
+   - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$;
+   - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$.
+ - For all \f$u\in V\f$:
+   - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$,
+     then \f$\pi(u)=0\f$.
+ 
+Here \f$cost^\pi(uv)\f$ denotes the \e reduced \e cost of the arc
+\f$uv\in A\f$ with respect to the node potentials \f$\pi\f$, i.e.
+\f[ cost^\pi(uv) = cost(uv) + \pi(u) - \pi(v).\f]
+
+All algorithms provide dual solution (node potentials) as well
+if an optimal flow is found.
+
+LEMON contains several algorithms for solving minimum cost flow problems.
+ - \ref NetworkSimplex Primal Network Simplex algorithm with various
+   pivot strategies.
+ - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on
+   cost scaling.
+ - \ref CapacityScaling Successive Shortest %Path algorithm with optional
    capacity scaling.
- - \ref CostScaling Push-relabel and augment-relabel algorithms based on
-   cost scaling.
- - \ref NetworkSimplex Primal network simplex algorithm with various
-   pivot strategies.
+ - \ref CancelAndTighten The Cancel and Tighten algorithm.
+ - \ref CycleCanceling Cycle-Canceling algorithms.
+
+Most of these implementations support the general inequality form of the
+minimum cost flow problem, but CancelAndTighten and CycleCanceling
+only support the equality form due to the primal method they use.
+
+In general NetworkSimplex is the most efficient implementation,
+but in special cases other algorithms could be faster.
+For example, if the total supply and/or capacities are rather small,
+CapacityScaling is usually the fastest algorithm (without effective scaling).
 */
 
@@ -383,5 +451,5 @@
 \brief Algorithms for finding minimum cut in graphs.
 
-This group contains the algorithms for finding minimum cut in graphs.
+This group describes the algorithms for finding minimum cut in graphs.
 
 The \e minimum \e cut \e problem is to find a non-empty and non-complete
@@ -400,5 +468,5 @@
 - \ref NagamochiIbaraki "Nagamochi-Ibaraki algorithm" for
   calculating minimum cut in undirected graphs.
-- \ref GomoryHu "Gomory-Hu tree computation" for calculating
+- \ref GomoryHuTree "Gomory-Hu tree computation" for calculating
   all-pairs minimum cut in undirected graphs.
 
@@ -408,9 +476,9 @@
 
 /**
-@defgroup graph_properties Connectivity and Other Graph Properties
+@defgroup graph_prop Connectivity and Other Graph Properties
 @ingroup algs
 \brief Algorithms for discovering the graph properties
 
-This group contains the algorithms for discovering the graph properties
+This group describes the algorithms for discovering the graph properties
 like connectivity, bipartiteness, euler property, simplicity etc.
 
@@ -424,5 +492,5 @@
 \brief Algorithms for planarity checking, embedding and drawing
 
-This group contains the algorithms for planarity checking,
+This group describes the algorithms for planarity checking,
 embedding and drawing.
 
@@ -436,8 +504,7 @@
 \brief Algorithms for finding matchings in graphs and bipartite graphs.
 
-This group contains the algorithms for calculating
+This group contains algorithm objects and functions to calculate
 matchings in graphs and bipartite graphs. The general matching problem is
-finding a subset of the edges for which each node has at most one incident
-edge.
+finding a subset of the arcs which does not shares common endpoints.
 
 There are several different algorithms for calculate matchings in
@@ -476,5 +543,5 @@
 \brief Algorithms for finding a minimum cost spanning tree in a graph.
 
-This group contains the algorithms for finding a minimum cost spanning
+This group describes the algorithms for finding a minimum cost spanning
 tree in a graph.
 */
@@ -485,5 +552,5 @@
 \brief Auxiliary algorithms implemented in LEMON.
 
-This group contains some algorithms implemented in LEMON
+This group describes some algorithms implemented in LEMON
 in order to make it easier to implement complex algorithms.
 */
@@ -494,5 +561,5 @@
 \brief Approximation algorithms.
 
-This group contains the approximation and heuristic algorithms
+This group describes the approximation and heuristic algorithms
 implemented in LEMON.
 */
@@ -500,8 +567,8 @@
 /**
 @defgroup gen_opt_group General Optimization Tools
-\brief This group contains some general optimization frameworks
+\brief This group describes some general optimization frameworks
 implemented in LEMON.
 
-This group contains some general optimization frameworks
+This group describes some general optimization frameworks
 implemented in LEMON.
 */
@@ -512,5 +579,5 @@
 \brief Lp and Mip solver interfaces for LEMON.
 
-This group contains Lp and Mip solver interfaces for LEMON. The
+This group describes Lp and Mip solver interfaces for LEMON. The
 various LP solvers could be used in the same manner with this
 interface.
@@ -531,5 +598,5 @@
 \brief Metaheuristics for LEMON library.
 
-This group contains some metaheuristic optimization tools.
+This group describes some metaheuristic optimization tools.
 */
 
@@ -546,5 +613,5 @@
 \brief Simple basic graph utilities.
 
-This group contains some simple basic graph utilities.
+This group describes some simple basic graph utilities.
 */
 
@@ -554,5 +621,5 @@
 \brief Tools for development, debugging and testing.
 
-This group contains several useful tools for development,
+This group describes several useful tools for development,
 debugging and testing.
 */
@@ -563,5 +630,5 @@
 \brief Simple tools for measuring the performance of algorithms.
 
-This group contains simple tools for measuring the performance
+This group describes simple tools for measuring the performance
 of algorithms.
 */
@@ -572,5 +639,5 @@
 \brief Exceptions defined in LEMON.
 
-This group contains the exceptions defined in LEMON.
+This group describes the exceptions defined in LEMON.
 */
 
@@ -579,5 +646,5 @@
 \brief Graph Input-Output methods
 
-This group contains the tools for importing and exporting graphs
+This group describes the tools for importing and exporting graphs
 and graph related data. Now it supports the \ref lgf-format
 "LEMON Graph Format", the \c DIMACS format and the encapsulated
@@ -590,5 +657,5 @@
 \brief Reading and writing LEMON Graph Format.
 
-This group contains methods for reading and writing
+This group describes methods for reading and writing
 \ref lgf-format "LEMON Graph Format".
 */
@@ -599,5 +666,5 @@
 \brief General \c EPS drawer and graph exporter
 
-This group contains general \c EPS drawing methods and special
+This group describes general \c EPS drawing methods and special
 graph exporting tools.
 */
@@ -623,5 +690,5 @@
 \brief Skeleton classes and concept checking classes
 
-This group contains the data/algorithm skeletons and concept checking
+This group describes the data/algorithm skeletons and concept checking
 classes implemented in LEMON.
 
@@ -653,5 +720,5 @@
 \brief Skeleton and concept checking classes for graph structures
 
-This group contains the skeletons and concept checking classes of LEMON's
+This group describes the skeletons and concept checking classes of LEMON's
 graph structures and helper classes used to implement these.
 */
@@ -662,5 +729,5 @@
 \brief Skeleton and concept checking classes for maps
 
-This group contains the skeletons and concept checking classes of maps.
+This group describes the skeletons and concept checking classes of maps.
 */
 
@@ -673,6 +740,6 @@
 the \c demo subdirectory of the source tree.
 
-In order to compile them, use the <tt>make demo</tt> or the
-<tt>make check</tt> commands.
+It order to compile them, use <tt>--enable-demo</tt> configure option when
+build the library.
 */
 
