[Lemon-commits] [lemon_svn] alpar: r1030 - in hugo/branches/hugo++: . doc src/benchmark src/hugo src/work src/work/jacint src/work/johanna src/work/marci src/work/marci/lp
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:50 CET 2006
Author: alpar
Date: Thu Aug 19 13:44:00 2004
New Revision: 1030
Added:
hugo/branches/hugo++/src/work/jacint/max_flow_bug.cc
- copied unchanged from r1029, /hugo/trunk/src/work/jacint/max_flow_bug.cc
hugo/branches/hugo++/src/work/marci/augmenting_flow.h
- copied unchanged from r1029, /hugo/trunk/src/work/marci/augmenting_flow.h
hugo/branches/hugo++/src/work/marci/lp/
- copied from r1029, /hugo/trunk/src/work/marci/lp/
hugo/branches/hugo++/src/work/marci/lp/lp_solver_wrapper.h
- copied unchanged from r1029, /hugo/trunk/src/work/marci/lp/lp_solver_wrapper.h
hugo/branches/hugo++/src/work/marci/lp/makefile
- copied unchanged from r1029, /hugo/trunk/src/work/marci/lp/makefile
hugo/branches/hugo++/src/work/marci/lp/max_flow_by_lp.cc
- copied unchanged from r1029, /hugo/trunk/src/work/marci/lp/max_flow_by_lp.cc
hugo/branches/hugo++/src/work/marci/preflow_bug.cc
- copied unchanged from r1029, /hugo/trunk/src/work/marci/preflow_bug.cc
hugo/branches/hugo++/src/work/marci/preflow_bug_8
- copied unchanged from r1029, /hugo/trunk/src/work/marci/preflow_bug_8
Modified:
hugo/branches/hugo++/AUTHORS
hugo/branches/hugo++/COPYING
hugo/branches/hugo++/LICENSE
hugo/branches/hugo++/doc/graphs.dox
hugo/branches/hugo++/doc/groups.dox
hugo/branches/hugo++/src/benchmark/bench_tools.h
hugo/branches/hugo++/src/benchmark/benchmark
hugo/branches/hugo++/src/benchmark/bfs-bench.cc
hugo/branches/hugo++/src/hugo/dijkstra.h
hugo/branches/hugo++/src/hugo/full_graph.h
hugo/branches/hugo++/src/hugo/max_flow.h
hugo/branches/hugo++/src/hugo/mincostflows.h
hugo/branches/hugo++/src/hugo/minlengthpaths.h
hugo/branches/hugo++/src/hugo/smart_graph.h
hugo/branches/hugo++/src/hugo/template.h
hugo/branches/hugo++/src/work/Doxyfile
hugo/branches/hugo++/src/work/jacint/makefile
hugo/branches/hugo++/src/work/jacint/max_flow_test.cc
hugo/branches/hugo++/src/work/johanna/kruskal.h
hugo/branches/hugo++/src/work/makefile
hugo/branches/hugo++/src/work/marci/bfs_dfs_misc.h
hugo/branches/hugo++/src/work/marci/bfsit_vs_byhand.cc
hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper.h
hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper_test.cc
hugo/branches/hugo++/src/work/marci/bipartite_matching_try.cc
hugo/branches/hugo++/src/work/marci/bipartite_matching_try_3.cc
hugo/branches/hugo++/src/work/marci/lg_vs_sg_vs_sg.cc
hugo/branches/hugo++/src/work/marci/macro_test.cc
hugo/branches/hugo++/src/work/marci/makefile
hugo/branches/hugo++/src/work/marci/max_bipartite_matching.h
hugo/branches/hugo++/src/work/marci/max_flow_1.cc
hugo/branches/hugo++/src/work/marci/max_flow_demo.cc
hugo/branches/hugo++/src/work/marci/top_sort_test.cc
Log:
branches/hugo++: ported -r1003:1029 from trunk.
Modified: hugo/branches/hugo++/AUTHORS
==============================================================================
--- hugo/branches/hugo++/AUTHORS (original)
+++ hugo/branches/hugo++/AUTHORS Thu Aug 19 13:44:00 2004
@@ -1,17 +1,17 @@
+HUGOlib was started as an inter-university project from two
+universities: BME (Budapest University of Technology and Economics,
+Hungary) and ELTE (Eotvos Lorand University, Budapest, Hungary) and
+supported by ETIK (Inter-University Centre for Telecommunications and
+Informatics).
-HUGOlib was started as an inter-university project from two universities:
-BME (Budapest University of Technology and Economics) and ELTE (Eotvos
-Lorand University) and supported by ETIK (Inter-University Centre for
-Telecommunications and Informatics).
-
-Many of this core team members are alse members of and supported by
+Many of this core team members are also members of and supported by
Egervary Research Group on Combinatorial Optimization (EGRES,
http://www.cs.elte.hu/egres/).
Other supporters of this project are:
-High-Speed Network Lab (HSN, ???)
-CNL
-Ericsson
+High Speed Network Lab (HSN, ???)
+Communication Network Laboratory,
+Ericsson Hungary
For every contributor we list the supporters who supported his or her
work.
@@ -22,7 +22,6 @@
address (A), Subversion commit name (C), and the list of supporters (S)
-
===========================================================================
N: Mihaly Barasz
@@ -44,4 +43,4 @@
A: Cegled
S: ETIK, ELTE
-...
+...
\ No newline at end of file
Modified: hugo/branches/hugo++/COPYING
==============================================================================
--- hugo/branches/hugo++/COPYING (original)
+++ hugo/branches/hugo++/COPYING Thu Aug 19 13:44:00 2004
@@ -1,17 +1,17 @@
-
-HUGOlib project was started by a team of university students from ELTE and
-BME supported by ETIK. This core team coordinates the development but many
-others have contributed since. See the AUTHORS file for details.
+HUGOlib as a whole is copyrighted by Egerváry Jenõ Kombinatorikus
+Optimalizálási Kutatócsoport (Egervary Combinatorial Optimization
+Research Group, EGRES).
You are free to use, modify and distribute HUGOlib under the terms
described in the LICENSE file.
-HUGOlib as a whole is copyrighted by the HUGO team. Individual copyright
-notices can be found in the file headers. Furthermore, HUGOlib includes code
-from several external sources:
+This project is supported by
+
+* Egyetemközi Távközlési és Informatikai Központ (Inter-University
+ Centre for Telecommunications and Informatics, Hungary)
+
+* Traffic Analysis and Network Performance Laboratory,
+ Ericsson Research, Hungary
-Name: Boost
-Version: 1.31.0
-Homepage: http://www.boost.org/
-Files: none
-License: Boost Software License - Version 1.0
+* Department of Operations Research, Eötvös Loránd University,
+ Budapest
Modified: hugo/branches/hugo++/LICENSE
==============================================================================
--- hugo/branches/hugo++/LICENSE (original)
+++ hugo/branches/hugo++/LICENSE Thu Aug 19 13:44:00 2004
@@ -1,18 +1,9 @@
-This license applies to all portions of HUGOlib which are not
-externally-maintained libraries (e.g. megnincsilyen/, eseleg majd a glay...).
-Such libraries have their own licenses; we recommend you read them, as
-their terms may differ from the terms below.
-
-This is version 1 of this license. It is also available online at
-http://hugo.cs.elte.hu/license-1.html. If newer versions of
-this license are posted there (the same URL, but with the version
-number incremented: .../license-2.html, .../license-3.html, and so
-on), you may use a newer version instead, at your option.
+HUGOlib code without an explicit copyright is covered by the following
+copyright/license:
-This license is a verbatim copy of the Boost Software License, Version 1.0.
-(Kene kerni toluk engedelyt.)
-
-===========================================================================
+Copyright (C) 2003-2004 Egervary Jeno Kombinatorikus Optimalizalasi
+Kutatocsoport (Egervary Combinatorial Optimization Research Group,
+EGRES).
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
@@ -35,3 +26,8 @@
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
+
+===========================================================================
+This license is a verbatim copy of the Boost Software License, Version 1.0.
+
+
Modified: hugo/branches/hugo++/doc/graphs.dox
==============================================================================
--- hugo/branches/hugo++/doc/graphs.dox (original)
+++ hugo/branches/hugo++/doc/graphs.dox Thu Aug 19 13:44:00 2004
@@ -2,6 +2,65 @@
\page graphs How to use graphs
+The primary data structures of HugoLib are the graph classes. They all
+provide a node list - edge list interface, i.e. they have
+functionalities to list the nodes and the edges of the graph as well
+as in incoming and outgoing edges of a given node.
+
+
+Each graph should meet the \ref ConstGraph concept. This concept does
+makes it possible to change the graph (i.e. it is not possible to add
+or delete edges or nodes). Most of the graph algorithms will run on
+these graphs.
+
+The graphs meeting the \ref ExtendableGraph concept allow node and
+edge addition. You can also "clear" (i.e. erase all edges and nodes)
+such a graph.
+
+In case of graphs meeting the full feature \ref ErasableGraph concept
+you can also erase individual edges and node in arbitrary order.
+
+The implemented graph structures are the following.
+\li \ref hugo::ListGraph "ListGraph" is the most versatile graph class. It meets
+the ErasableGraph concept and it also have some convenience features.
+\li \ref hugo::SmartGraph "SmartGraph" is a more memory
+efficient version of \ref hugo::ListGraph "ListGraph". The
+price of it is that it only meets the \ref ExtendableGraph concept,
+so you cannot delete individual edges or nodes.
+\li \ref hugo::SymListGraph "SymListGraph" and
+\ref hugo::SymSmartGraph "SymSmartGraph" classes are very similar to
+\ref hugo::ListGraph "ListGraph" and \ref hugo::SmartGraph "SmartGraph".
+The difference is that whenever you add a
+new edge to the graph, it actually adds a pair of oppositely directed edges.
+They are linked together so it is possible to access the counterpart of an
+edge. An even more important feature is that using these classes you can also
+attach data to the edges in such a way that the stored data
+are shared by the edge pairs.
+\li \ref hugo::FullGraph "FullGraph"
+implements a full graph. It is a \ref ConstGraph, so you cannot
+change the number of nodes once it is constructed. It is extremely memory
+efficient: it uses constant amount of memory independently from the number of
+the nodes of the graph. Of course, the size of the \ref maps "NodeMap"'s and
+\ref maps "EdgeMap"'s will depend on the number of nodes.
+
+\li \ref hugo::NodeSet "NodeSet" implements a graph with no edges. This class
+can be used as a base class of \ref hugo::EdgeSet "EdgeSet".
+\li \ref hugo::EdgeSet "EdgeSet" can be used to create a new graph on
+the edge set of another graph. The base graph can be an arbitrary graph and it
+is possible to attach several \ref hugo::EdgeSet "EdgeSet"'s to a base graph.
+
+\todo Don't we need SmartNodeSet and SmartEdgeSet?
+\todo Some cross-refs are wrong.
+
+
+The graph structures itself can not store data attached
+to the edges and nodes. However they all provide
+\ref maps "map classes"
+to dynamically attach data the to graph components.
+
+
+
+
The following program demonstrates the basic features of HugoLib's graph
structures.
Modified: hugo/branches/hugo++/doc/groups.dox
==============================================================================
--- hugo/branches/hugo++/doc/groups.dox (original)
+++ hugo/branches/hugo++/doc/groups.dox Thu Aug 19 13:44:00 2004
@@ -45,10 +45,10 @@
*/
/**
- at defgroup spantree Minimum Cost Spanning Tree Algorithms
-\brief This group containes the algorithms for finding a minimum cost spanning
-tree in a graph
+ at defgroup flowalgs Path and Flow Algorithms
@ingroup galgs
+\brief This group describes the algorithms
+for finding paths and flows in graphs.
*/
/**
Modified: hugo/branches/hugo++/src/benchmark/bench_tools.h
==============================================================================
--- hugo/branches/hugo++/src/benchmark/bench_tools.h (original)
+++ hugo/branches/hugo++/src/benchmark/bench_tools.h Thu Aug 19 13:44:00 2004
@@ -10,7 +10,7 @@
///An experimental typedef factory
#define GRAPH_TYPEDEF_FACTORY(Graph) \
typedef typename Graph:: Node Node;\
- typedef typename Graph:: NodeIt NodeIn;\
+ typedef typename Graph:: NodeIt NodeIt;\
typedef typename Graph:: Edge Edge;\
typedef typename Graph:: EdgeIt EdgeIt;\
typedef typename Graph:: InEdgeIt InEdgeIt;\
@@ -18,7 +18,7 @@
#define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \
typedef Graph:: Node Node;\
- typedef Graph:: NodeIt NodeIn;\
+ typedef Graph:: NodeIt NodeIt;\
typedef Graph:: Edge Edge;\
typedef Graph:: EdgeIt EdgeIt;\
typedef Graph:: InEdgeIt InEdgeIt;\
Modified: hugo/branches/hugo++/src/benchmark/benchmark
==============================================================================
--- hugo/branches/hugo++/src/benchmark/benchmark (original)
+++ hugo/branches/hugo++/src/benchmark/benchmark Thu Aug 19 13:44:00 2004
@@ -3,8 +3,8 @@
function runtest () # prefix, prog, args
{
echo $1 1>&2
- $2 $3 $4 $5 $6 $7 $8 $9;
- for ((i=1;i<=5;i++))
+ $2 $3 $4 $5 $6 $7 $8 $9 >/dev/null;
+ for ((i=1;i<=3;i++))
do
$2 $3 $4 $5 $6 $7 $8 $9;
done |
@@ -18,6 +18,8 @@
make CXX="$2" CXXFLAGS="$3" >/dev/null
{
runtest HCUBE19 hcube 19
+ runtest BFS13-5000 hcube 13 5000
+ runtest BFS10-50000 hcube 10 50000
runtest GRBENCH graph-bench
} | awk "{print \$0, \"$1\"}"
}
@@ -31,4 +33,9 @@
runalltest "gcc-3.4 -O2-march=pentium-m" g++-3.4 "-O2 -march=pentium-m"
runalltest "gcc-3.4 -O3" g++-3.4 "-O3"
runalltest "gcc-3.4 -O3-march=pentium-m" g++-3.4 "-O3 -march=pentium-m"
+
+runalltest "icc -O2" icc "-O2"
+runalltest "icc -O2-march=pentium-m" icc "-O2 -march=pentium-m"
+runalltest "icc -O3" icc "-O3"
+runalltest "icc -O3-march=pentium-m" icc "-O3 -march=pentium-m"
Modified: hugo/branches/hugo++/src/benchmark/bfs-bench.cc
==============================================================================
--- hugo/branches/hugo++/src/benchmark/bfs-bench.cc (original)
+++ hugo/branches/hugo++/src/benchmark/bfs-bench.cc Thu Aug 19 13:44:00 2004
@@ -38,7 +38,7 @@
using namespace std;
- typename Graph::NodeMap<bool> visited(G,false);
+ typename Graph::template NodeMap<bool> visited(G,false);
queue<typename Graph::Node> Q;
@@ -63,7 +63,7 @@
using namespace std;
- typename Graph::NodeMap<bool> visited(G,false);
+ typename Graph::template NodeMap<bool> visited(G,false);
int N=G.nodeNum();
vector<typename Graph::Node> Q(N);
@@ -84,6 +84,18 @@
} while(Qt!=Qh);
}
+template<class Graph>
+void iteratorBench(Graph &G)
+{
+ GRAPH_TYPEDEF_FACTORY(Graph);
+
+ int i=0;
+
+ for(NodeIt n(G);G.valid(n);G.next(n))
+ for(OutEdgeIt e(G,n);G.valid(e);G.next(e))
+ i++;
+}
+
int main(int argc, char *argv[])
{
// typedef ListGraph Graph;
@@ -96,12 +108,13 @@
Timer T;
- if(argc!=2) {
- cout << "Usage: " << argv[0] << " dim\n";
+ if(argc!=3) {
+ cout << "Usage: " << argv[0] << " dim mul\n";
return 1;
}
int dim=atoi(argv[1]);
+ int mul=atoi(argv[2]);
// cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
// << dim*(1<<dim) << " edges):";
@@ -114,14 +127,22 @@
T.reset();
{
- for(int i=0;i<50000;i++)
+ for(int i=0;i<mul;i++)
bfsStlQueue(G,nodes[0]);
}
PrintTime("BFS-STL",T);
T.reset();
{
- for(int i=0;i<50000;i++)
+ for(int i=0;i<mul;i++)
bfsOwnQueue(G,nodes[0]);
}
PrintTime("BFS-OWN",T);
+ T.reset();
+ {
+ for(int i=0;i<mul;i++)
+ iteratorBench(G);
+ }
+ PrintTime("ITERATE",T);
+
+
}
Modified: hugo/branches/hugo++/src/hugo/dijkstra.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/dijkstra.h (original)
+++ hugo/branches/hugo++/src/hugo/dijkstra.h Thu Aug 19 13:44:00 2004
@@ -2,7 +2,7 @@
#ifndef HUGO_DIJKSTRA_H
#define HUGO_DIJKSTRA_H
-///\ingroup galgs
+///\ingroup flowalgs
///\file
///\brief Dijkstra algorithm.
@@ -11,7 +11,7 @@
namespace hugo {
-/// \addtogroup galgs
+/// \addtogroup flowalgs
/// @{
///%Dijkstra algorithm class.
Modified: hugo/branches/hugo++/src/hugo/full_graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/full_graph.h (original)
+++ hugo/branches/hugo++/src/hugo/full_graph.h Thu Aug 19 13:44:00 2004
@@ -25,7 +25,8 @@
///Otherwise it conforms to the graph interface documented under
///the description of \ref GraphSkeleton.
///\sa \ref GraphSkeleton.
- ///\todo Shouldn't we avoid loops?
+ ///\todo What about loops?
+ ///\todo Don't we need SymEdgeMap?
///
///\author Alpar Juttner
class FullGraph {
Modified: hugo/branches/hugo++/src/hugo/max_flow.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/max_flow.h (original)
+++ hugo/branches/hugo++/src/hugo/max_flow.h Thu Aug 19 13:44:00 2004
@@ -1,23 +1,22 @@
// -*- C++ -*-
-#ifndef HUGO_MAX_FLOW_NO_STACK_H
-#define HUGO_MAX_FLOW_NO_STACK_H
+#ifndef HUGO_MAX_FLOW_H
+#define HUGO_MAX_FLOW_H
#include <vector>
#include <queue>
-//#include <stack>
#include <hugo/graph_wrapper.h>
#include <hugo/invalid.h>
#include <hugo/maps.h>
/// \file
-/// \brief The same as max_flow.h, but without using stl stack for the active nodes. Only for test.
-/// \ingroup galgs
+/// \ingroup flowalgs
namespace hugo {
- /// \addtogroup galgs
- /// @{
+ /// \addtogroup flowalgs
+ /// @{
+
///Maximum flow algorithms class.
///This class provides various algorithms for finding a flow of
@@ -25,20 +24,22 @@
///target node, the \e capacity of the edges and the \e starting \e
///flow value of the edges should be passed to the algorithm through the
///constructor. It is possible to change these quantities using the
- ///functions \ref resetSource, \ref resetTarget, \ref resetCap and
- ///\ref resetFlow. Before any subsequent runs of any algorithm of
- ///the class \ref resetFlow should be called.
-
+ ///functions \ref setSource, \ref setTarget, \ref setCap and
+ ///\ref setFlow. Before any subsequent runs of any algorithm of
+ ///the class \ref setFlow should be called.
+ ///
///After running an algorithm of the class, the actual flow value
///can be obtained by calling \ref flowValue(). The minimum
///value cut can be written into a \c node map of \c bools by
///calling \ref minCut. (\ref minMinCut and \ref maxMinCut writes
///the inclusionwise minimum and maximum of the minimum value
- ///cuts, resp.)
+ ///cuts, resp.)
+ ///
///\param Graph The directed graph type the algorithm runs on.
///\param Num The number type of the capacities and the flow values.
///\param CapMap The capacity map type.
- ///\param FlowMap The flow map type.
+ ///\param FlowMap The flow map type.
+ ///
///\author Marton Makai, Jacint Szabo
template <typename Graph, typename Num,
typename CapMap=typename Graph::template EdgeMap<Num>,
@@ -51,7 +52,6 @@
typedef typename Graph::OutEdgeIt OutEdgeIt;
typedef typename Graph::InEdgeIt InEdgeIt;
- // typedef typename std::vector<std::stack<Node> > VecStack;
typedef typename std::vector<Node> VecFirst;
typedef typename Graph::template NodeMap<Node> NNMap;
typedef typename std::vector<Node> VecNode;
@@ -66,7 +66,6 @@
//typedef ExpResGraphWrapper<const Graph, Num, CapMap, FlowMap> ResGW;
typedef typename ResGW::OutEdgeIt ResGWOutEdgeIt;
typedef typename ResGW::Edge ResGWEdge;
- //typedef typename ResGW::template NodeMap<bool> ReachedMap;
typedef typename Graph::template NodeMap<int> ReachedMap;
@@ -110,7 +109,7 @@
AFTER_PRE_FLOW_PHASE_2
};
- /// Don not needle this flag only if necessary.
+ /// Do not needle this flag only if necessary.
StatusEnum status;
// int number_of_augmentations;
@@ -140,7 +139,7 @@
///\todo Document, please.
///
MaxFlow(const Graph& _G, Node _s, Node _t,
- const CapMap& _capacity, FlowMap& _flow) :
+ const CapMap& _capacity, FlowMap& _flow) :
g(&_G), s(_s), t(_t), capacity(&_capacity),
flow(&_flow), n(_G.nodeNum()), level(_G), excess(_G,0),
status(AFTER_NOTHING) { }
@@ -188,7 +187,7 @@
///The preflow algorithm consists of two phases, this method runs the
///first phase. After the first phase the maximum flow value and a
///minimum value cut can already be computed, though a maximum flow
- ///is net yet obtained. So after calling this method \ref flowValue
+ ///is not yet obtained. So after calling this method \ref flowValue
///and \ref actMinCut gives proper results.
///\warning: \ref minCut, \ref minMinCut and \ref maxMinCut do not
///give minimum value cuts unless calling \ref preflowPhase2.
@@ -217,73 +216,15 @@
VecFirst first(n, INVALID);
NNMap next(*g, INVALID); //maybe INVALID is not needed
- // VecStack active(n);
NNMap left(*g, INVALID);
NNMap right(*g, INVALID);
VecNode level_list(n,INVALID);
//List of the nodes in level i<n, set to n.
- NodeIt v;
- for(g->first(v); g->valid(v); g->next(v)) level.set(v,n);
- //setting each node to level n
-
- if ( fe == NO_FLOW ) {
- EdgeIt e;
- for(g->first(e); g->valid(e); g->next(e)) flow->set(e,0);
- }
-
- switch (fe) { //computing the excess
- case PRE_FLOW:
- {
- NodeIt v;
- for(g->first(v); g->valid(v); g->next(v)) {
- Num exc=0;
-
- InEdgeIt e;
- for(g->first(e,v); g->valid(e); g->next(e)) exc+=(*flow)[e];
- OutEdgeIt f;
- for(g->first(f,v); g->valid(f); g->next(f)) exc-=(*flow)[f];
-
- excess.set(v,exc);
-
- //putting the active nodes into the stack
- int lev=level[v];
- if ( exc > 0 && lev < n && v != t )
- {
- next.set(v,first[lev]);
- first[lev]=v;
- }
- // active[lev].push(v);
- }
- break;
- }
- case GEN_FLOW:
- {
- NodeIt v;
- for(g->first(v); g->valid(v); g->next(v)) excess.set(v,0);
-
- Num exc=0;
- InEdgeIt e;
- for(g->first(e,t); g->valid(e); g->next(e)) exc+=(*flow)[e];
- OutEdgeIt f;
- for(g->first(f,t); g->valid(f); g->next(f)) exc-=(*flow)[f];
- excess.set(t,exc);
- break;
- }
- case ZERO_FLOW:
- case NO_FLOW:
- {
- NodeIt v;
- for(g->first(v); g->valid(v); g->next(v)) excess.set(v,0);
- break;
- }
- }
-
- preflowPreproc(fe, next, first,/*active*/ level_list, left, right);
+ preflowPreproc(fe, next, first, level_list, left, right);
//End of preprocessing
-
//Push/relabel on the highest level active nodes.
while ( true ) {
if ( b == 0 ) {
@@ -293,15 +234,13 @@
} else break;
}
- if ( !g->valid(first[b])/*active[b].empty()*/ ) --b;
+ if ( !g->valid(first[b]) ) --b;
else {
end=false;
Node w=first[b];
first[b]=next[w];
- /* Node w=active[b].top();
- active[b].pop();*/
- int newlevel=push(w,/*active*/next, first);
- if ( excess[w] > 0 ) relabel(w, newlevel, /*active*/next, first, level_list,
+ int newlevel=push(w, next, first);
+ if ( excess[w] > 0 ) relabel(w, newlevel, next, first, level_list,
left, right, b, k, what_heur);
++numrelabel;
@@ -340,7 +279,6 @@
VecFirst first(n, INVALID);
NNMap next(*g, INVALID); //maybe INVALID is not needed
- // VecStack active(n);
level.set(s,0);
std::queue<Node> bfs_queue;
bfs_queue.push(s);
@@ -361,7 +299,6 @@
if ( excess[u] > 0 ) {
next.set(u,first[l]);
first[l]=u;
- //active[l].push(u);
}
}
}
@@ -376,7 +313,6 @@
if ( excess[u] > 0 ) {
next.set(u,first[l]);
first[l]=u;
- //active[l].push(u);
}
}
}
@@ -387,13 +323,11 @@
if ( b == 0 ) break;
- if ( !g->valid(first[b])/*active[b].empty()*/ ) --b;
+ if ( !g->valid(first[b]) ) --b;
else {
Node w=first[b];
first[b]=next[w];
- /* Node w=active[b].top();
- active[b].pop();*/
int newlevel=push(w,next, first/*active*/);
//relabel
@@ -401,29 +335,31 @@
level.set(w,++newlevel);
next.set(w,first[newlevel]);
first[newlevel]=w;
- //active[newlevel].push(w);
b=newlevel;
}
- } // if stack[b] is nonempty
+ }
} // while(true)
status=AFTER_PRE_FLOW_PHASE_2;
}
- /// Returns the maximum value of a flow.
+ /// Returns the value of the maximum flow.
- /// Returns the maximum value of a flow, by counting the
- /// over-flow of the target node \ref t.
+ /// Returns the excess of the target node \ref t.
+ /// After running \ref preflowPhase1, this is the value of
+ /// the maximum flow.
/// It can be called already after running \ref preflowPhase1.
Num flowValue() const {
- Num a=0;
- for(InEdgeIt e(*g,t);g->valid(e);g->next(e)) a+=(*flow)[e];
- for(OutEdgeIt e(*g,t);g->valid(e);g->next(e)) a-=(*flow)[e];
-
+// Num a=0;
+// for(InEdgeIt e(*g,t);g->valid(e);g->next(e)) a+=(*flow)[e];
+// for(OutEdgeIt e(*g,t);g->valid(e);g->next(e)) a-=(*flow)[e];
+// return a;
+ return excess[t];
//marci figyu: excess[t] epp ezt adja preflow 1. fazisa utan
}
+
///Returns a minimum value cut after calling \ref preflowPhase1.
///After the first phase of the preflow algorithm the maximum flow
@@ -451,6 +387,8 @@
break;
case AFTER_PRE_FLOW_PHASE_2:
case AFTER_NOTHING:
+ case AFTER_AUGMENTING:
+ case AFTER_FAST_AUGMENTING:
minMinCut(M);
break;
}
@@ -546,30 +484,30 @@
template<typename CutMap>
void minCut(CutMap& M) const { minMinCut(M); }
- ///Resets the source node to \c _s.
+ ///Sets the source node to \c _s.
- ///Resets the source node to \c _s.
+ ///Sets the source node to \c _s.
///
- void resetSource(Node _s) { s=_s; status=AFTER_NOTHING; }
+ void setSource(Node _s) { s=_s; status=AFTER_NOTHING; }
- ///Resets the target node to \c _t.
+ ///Sets the target node to \c _t.
- ///Resets the target node to \c _t.
+ ///Sets the target node to \c _t.
///
- void resetTarget(Node _t) { t=_t; status=AFTER_NOTHING; }
+ void setTarget(Node _t) { t=_t; status=AFTER_NOTHING; }
- /// Resets the edge map of the capacities to _cap.
+ /// Sets the edge map of the capacities to _cap.
- /// Resets the edge map of the capacities to _cap.
+ /// Sets the edge map of the capacities to _cap.
///
- void resetCap(const CapMap& _cap)
+ void setCap(const CapMap& _cap)
{ capacity=&_cap; status=AFTER_NOTHING; }
- /// Resets the edge map of the flows to _flow.
+ /// Sets the edge map of the flows to _flow.
- /// Resets the edge map of the flows to _flow.
+ /// Sets the edge map of the flows to _flow.
///
- void resetFlow(FlowMap& _flow) { flow=&_flow; status=AFTER_NOTHING; }
+ void setFlow(FlowMap& _flow) { flow=&_flow; status=AFTER_NOTHING; }
private:
@@ -591,8 +529,6 @@
if ( excess[v]<=0 && v!=t && v!=s ) {
next.set(v,first[level[v]]);
first[level[v]]=v;
- // int lev_v=level[v];
- //active[lev_v].push(v);
}
Num cap=(*capacity)[e];
@@ -626,8 +562,6 @@
if ( excess[v]<=0 && v!=t && v!=s ) {
next.set(v,first[level[v]]);
first[level[v]]=v;
- //int lev_v=level[v];
- //active[lev_v].push(v);
}
Num flo=(*flow)[e];
@@ -655,13 +589,51 @@
}
+
void preflowPreproc(FlowEnum fe, NNMap& next, VecFirst& first,
VecNode& level_list, NNMap& left, NNMap& right)
{
+ switch (fe) { //setting excess
+ case NO_FLOW:
+ {
+ EdgeIt e;
+ for(g->first(e); g->valid(e); g->next(e)) flow->set(e,0);
+
+ NodeIt v;
+ for(g->first(v); g->valid(v); g->next(v)) excess.set(v,0);
+ break;
+ }
+ case ZERO_FLOW:
+ {
+ NodeIt v;
+ for(g->first(v); g->valid(v); g->next(v)) excess.set(v,0);
+ break;
+ }
+ case GEN_FLOW:
+ {
+ NodeIt v;
+ for(g->first(v); g->valid(v); g->next(v)) excess.set(v,0);
+
+ Num exc=0;
+ InEdgeIt e;
+ for(g->first(e,t); g->valid(e); g->next(e)) exc+=(*flow)[e];
+ OutEdgeIt f;
+ for(g->first(f,t); g->valid(f); g->next(f)) exc-=(*flow)[f];
+ excess.set(t,exc);
+ break;
+ }
+ default: break;
+ }
+
+ NodeIt v;
+ for(g->first(v); g->valid(v); g->next(v)) level.set(v,n);
+ //setting each node to level n
+
std::queue<Node> bfs_queue;
+
switch (fe) {
- case NO_FLOW: //flow is already set to const zero in this case
+ case NO_FLOW: //flow is already set to const zero
case ZERO_FLOW:
{
//Reverse_bfs from t, to find the starting level.
@@ -696,11 +668,10 @@
if ( c <= 0 ) continue;
Node w=g->head(e);
if ( level[w] < n ) {
- if ( excess[w] <= 0 && w!=t )
- {
+ if ( excess[w] <= 0 && w!=t ) //putting into the stack
+ {
next.set(w,first[level[w]]);
first[level[w]]=w;
- //active[level[w]].push(w);
}
flow->set(e, c);
excess.set(w, excess[w]+c);
@@ -710,7 +681,6 @@
}
case GEN_FLOW:
- case PRE_FLOW:
{
//Reverse_bfs from t in the residual graph,
//to find the starting level.
@@ -752,7 +722,6 @@
}
}
-
//the starting flow
OutEdgeIt e;
for(g->first(e,s); g->valid(e); g->next(e))
@@ -761,11 +730,10 @@
if ( rem <= 0 ) continue;
Node w=g->head(e);
if ( level[w] < n ) {
- if ( excess[w] <= 0 && w!=t )
+ if ( excess[w] <= 0 && w!=t ) //putting into the stack
{
next.set(w,first[level[w]]);
first[level[w]]=w;
- //active[level[w]].push(w);
}
flow->set(e, (*capacity)[e]);
excess.set(w, excess[w]+rem);
@@ -782,19 +750,106 @@
{
next.set(w,first[level[w]]);
first[level[w]]=w;
- //active[level[w]].push(w);
- }
+ }
+ excess.set(w, excess[w]+(*flow)[f]);
+ flow->set(f, 0);
+ }
+ }
+ break;
+ } //case GEN_FLOW
+
+ case PRE_FLOW:
+ {
+ //Reverse_bfs from t in the residual graph,
+ //to find the starting level.
+ level.set(t,0);
+ bfs_queue.push(t);
+
+ while (!bfs_queue.empty()) {
+
+ Node v=bfs_queue.front();
+ bfs_queue.pop();
+ int l=level[v]+1;
+
+ InEdgeIt e;
+ for(g->first(e,v); g->valid(e); g->next(e)) {
+ if ( (*capacity)[e] <= (*flow)[e] ) continue;
+ Node w=g->tail(e);
+ if ( level[w] == n && w != s ) {
+ bfs_queue.push(w);
+ Node z=level_list[l];
+ if ( g->valid(z) ) left.set(z,w);
+ right.set(w,z);
+ level_list[l]=w;
+ level.set(w, l);
+ }
+ }
+
+ OutEdgeIt f;
+ for(g->first(f,v); g->valid(f); g->next(f)) {
+ if ( 0 >= (*flow)[f] ) continue;
+ Node w=g->head(f);
+ if ( level[w] == n && w != s ) {
+ bfs_queue.push(w);
+ Node z=level_list[l];
+ if ( g->valid(z) ) left.set(z,w);
+ right.set(w,z);
+ level_list[l]=w;
+ level.set(w, l);
+ }
+ }
+ }
+
+
+ //the starting flow
+ OutEdgeIt e;
+ for(g->first(e,s); g->valid(e); g->next(e))
+ {
+ Num rem=(*capacity)[e]-(*flow)[e];
+ if ( rem <= 0 ) continue;
+ Node w=g->head(e);
+ if ( level[w] < n ) {
+ flow->set(e, (*capacity)[e]);
+ excess.set(w, excess[w]+rem);
+ }
+ }
+
+ InEdgeIt f;
+ for(g->first(f,s); g->valid(f); g->next(f))
+ {
+ if ( (*flow)[f] <= 0 ) continue;
+ Node w=g->tail(f);
+ if ( level[w] < n ) {
excess.set(w, excess[w]+(*flow)[f]);
flow->set(f, 0);
}
}
+
+ NodeIt w; //computing the excess
+ for(g->first(w); g->valid(w); g->next(w)) {
+ Num exc=0;
+
+ InEdgeIt e;
+ for(g->first(e,w); g->valid(e); g->next(e)) exc+=(*flow)[e];
+ OutEdgeIt f;
+ for(g->first(f,w); g->valid(f); g->next(f)) exc-=(*flow)[f];
+
+ excess.set(w,exc);
+
+ //putting the active nodes into the stack
+ int lev=level[w];
+ if ( exc > 0 && lev < n && w != t )
+ {
+ next.set(w,first[lev]);
+ first[lev]=w;
+ }
+ }
break;
} //case PRE_FLOW
}
} //preflowPreproc
-
void relabel(Node w, int newlevel, NNMap& next, VecFirst& first,
VecNode& level_list, NNMap& left,
NNMap& right, int& b, int& k, bool what_heur )
@@ -834,11 +889,6 @@
}
level_list[i]=INVALID;
if ( !what_heur ) first[i]=INVALID;
- /*{
- while ( !active[i].empty() ) {
- active[i].pop(); //FIXME: ezt szebben kene
- }
- }*/
}
level.set(w,n);
@@ -853,7 +903,6 @@
level.set(w,++newlevel);
next.set(w,first[newlevel]);
first[newlevel]=w;
- // active[newlevel].push(w);
if ( what_heur ) b=newlevel;
if ( k < newlevel ) ++k; //now k=newlevel
Node z=level_list[newlevel];
@@ -864,6 +913,35 @@
}
}
} //relabel
+
+ void printexcess() {////
+ std::cout << "Excesses:" <<std::endl;
+
+ NodeIt v;
+ for(g->first(v); g->valid(v); g->next(v)) {
+ std::cout << 1+(g->id(v)) << ":" << excess[v]<<std::endl;
+ }
+ }
+
+ void printlevel() {////
+ std::cout << "Levels:" <<std::endl;
+
+ NodeIt v;
+ for(g->first(v); g->valid(v); g->next(v)) {
+ std::cout << 1+(g->id(v)) << ":" << level[v]<<std::endl;
+ }
+ }
+
+void printactive() {////
+ std::cout << "Levels:" <<std::endl;
+
+ NodeIt v;
+ for(g->first(v); g->valid(v); g->next(v)) {
+ std::cout << 1+(g->id(v)) << ":" << level[v]<<std::endl;
+ }
+ }
+
+
}; //class MaxFlow
} //namespace hugo
Modified: hugo/branches/hugo++/src/hugo/mincostflows.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/mincostflows.h (original)
+++ hugo/branches/hugo++/src/hugo/mincostflows.h Thu Aug 19 13:44:00 2004
@@ -2,7 +2,7 @@
#ifndef HUGO_MINCOSTFLOWS_H
#define HUGO_MINCOSTFLOWS_H
-///\ingroup galgs
+///\ingroup flowalgs
///\file
///\brief An algorithm for finding a flow of value \c k (for small values of \c k) having minimal total cost
@@ -15,7 +15,7 @@
namespace hugo {
-/// \addtogroup galgs
+/// \addtogroup flowalgs
/// @{
///\brief Implementation of an algorithm for finding a flow of value \c k
Modified: hugo/branches/hugo++/src/hugo/minlengthpaths.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/minlengthpaths.h (original)
+++ hugo/branches/hugo++/src/hugo/minlengthpaths.h Thu Aug 19 13:44:00 2004
@@ -2,7 +2,7 @@
#ifndef HUGO_MINLENGTHPATHS_H
#define HUGO_MINLENGTHPATHS_H
-///\ingroup galgs
+///\ingroup flowalgs
///\file
///\brief An algorithm for finding k paths of minimal total length.
@@ -16,7 +16,7 @@
namespace hugo {
-/// \addtogroup galgs
+/// \addtogroup flowalgs
/// @{
///\brief Implementation of an algorithm for finding k paths between 2 nodes
Modified: hugo/branches/hugo++/src/hugo/smart_graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/smart_graph.h (original)
+++ hugo/branches/hugo++/src/hugo/smart_graph.h Thu Aug 19 13:44:00 2004
@@ -28,6 +28,12 @@
///\sa \ref GraphSkeleton.
///
///\todo Some member functions could be \c static.
+ ///
+ ///\todo A possibly useful functionality: a function saveState() would
+ ///give back a data sturcture X and then the function restoreState(X)
+ ///would remove the nodes and edges added after the call of saveState().
+ ///Of course it should be used as a stack. (Maybe X is not necessary.)
+ ///
///\author Alpar Juttner
class SmartGraph {
Modified: hugo/branches/hugo++/src/hugo/template.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/template.h (original)
+++ hugo/branches/hugo++/src/hugo/template.h Thu Aug 19 13:44:00 2004
@@ -3,14 +3,16 @@
/*
* src/hugo/template.h - Part of HUGOlib, a generic C++ optimization library
*
- * Copyright (C) 2004 Mihaly Barasz <klao at cs.elte.hu>
+ * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Combinatorial Optimization Research Group, EGRES).
*
* Permission to use, modify and distribute this software is granted
- * provided this copyright notice appears in all copies. For precise terms
- * see the accompanying LICENSE file.
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
*
- * This software is provided "AS IS" with no warranty, either express or
- * implied, and with no claim as to its suitability for any purpose.
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
*
*/
Modified: hugo/branches/hugo++/src/work/Doxyfile
==============================================================================
--- hugo/branches/hugo++/src/work/Doxyfile (original)
+++ hugo/branches/hugo++/src/work/Doxyfile Thu Aug 19 13:44:00 2004
@@ -404,6 +404,7 @@
jacint/max_matching.h \
marci/bfs_dfs.h \
marci/bfs_dfs_misc.h \
+ marci/lp/lp_solver_wrapper.h \
jacint/graph_gen.h \
marci/max_bipartite_matching.h \
marci/bipartite_graph_wrapper.h \
Modified: hugo/branches/hugo++/src/work/jacint/makefile
==============================================================================
--- hugo/branches/hugo++/src/work/jacint/makefile (original)
+++ hugo/branches/hugo++/src/work/jacint/makefile Thu Aug 19 13:44:00 2004
@@ -1,3 +1,3 @@
-BINARIES = max_flow_test
+BINARIES = max_flow_bug
INCLUDEDIRS= -I../../include -I../.. -I.. -I../{klao,marci,jacint,alpar,johanna,akos}
include ../makefile
Modified: hugo/branches/hugo++/src/work/jacint/max_flow_test.cc
==============================================================================
--- hugo/branches/hugo++/src/work/jacint/max_flow_test.cc (original)
+++ hugo/branches/hugo++/src/work/jacint/max_flow_test.cc Thu Aug 19 13:44:00 2004
@@ -81,7 +81,7 @@
Graph::EdgeMap<int> flow2(G,0);
std::cout << "Calling resetFlow() " << std::endl
<< ts << std::endl;
- max_flow_test.resetFlow(flow2);
+ max_flow_test.setFlow(flow2);
ts.reset();
max_flow_test.preflow(max_flow_test.PRE_FLOW);
std::cout << "Elapsed time of preflow(PRE_FLOW) starting from the zero flow: " << std::endl
Modified: hugo/branches/hugo++/src/work/johanna/kruskal.h
==============================================================================
--- hugo/branches/hugo++/src/work/johanna/kruskal.h (original)
+++ hugo/branches/hugo++/src/work/johanna/kruskal.h Thu Aug 19 13:44:00 2004
@@ -5,11 +5,22 @@
#include <algorithm>
#include <hugo/unionfind.h>
+/**
+ at defgroup spantree Minimum Cost Spanning Tree Algorithms
+\brief This group containes the algorithms for finding a minimum cost spanning
+tree in a graph
+ at ingroup galgs
+*/
+
+///\ingroup spantree
///\file
///\brief Kruskal's algorithm to compute a minimum cost tree
namespace hugo {
+ /// \addtogroup spantree
+ /// @{
+
/// Kruskal's algorithm to find a minimum cost tree of a graph.
/// This function runs Kruskal's algorithm to find a minimum cost tree.
@@ -117,7 +128,7 @@
/// Kruskal input source.
///
template<typename Graph, typename Map>
- class KruskalPairVec
+ class KruskalMapInput
: public std::vector< std::pair<typename Graph::Edge,
typename Map::ValueType> > {
@@ -143,14 +154,14 @@
public:
// FIXME: kell ez?
- // KruskalPairVec(Parent const& p) : Parent(p) {}
+ // KruskalMapInput(Parent const& p) : Parent(p) {}
void sort() {
std::sort(this->begin(), this->end(), comparePair());
}
// FIXME: nem nagyon illik ez ide...
- KruskalPairVec(Graph const& G, Map const& m) {
+ KruskalMapInput(Graph const& G, Map const& m) {
typedef typename Graph::EdgeIt EdgeIt;
this->clear();
@@ -169,21 +180,46 @@
};
-// template <typename Map>
-// class KruskalMapVec : public std::vector<typename Map::KeyType> {
+// template<typename Graph, typename Map>
+// class KruskalMapVec {
// public:
-// typedef typename Map::KeyType KeyType;
-// typedef typename Map::ValueType ValueType;
-
-// typedef typename std::vector<KeyType> Parent;
-// typedef typename Parent::iterator iterator;
-// typedef typename Parent::const_iterator const_iterator;
-
-// private:
-
+// typedef std::pair<typename Map::KeyType, Map::ValueType> value_type;
+
+// typedef std::vector<KeyType> Container;
+// Container container;
+// std::vector<typename Map::KeyType> container
// const Map &m;
+
+
+// class iterator
+// {
+// Container::iterator i;
+// public:
+// iterator &operator ++() {++i;return *this;}
+// valuetype operator *() {return value_type(container(i),m[container(i)]);}
+// bool operator==(iterator b) {return i==b.i;}
+// iterator() {}
+// iterator(Container::iterator _i) i(_i) {}
+// };
+// class const_iterator
+// {
+// Container::const_iterator i;
+// public:
+// iterator &operator ++() {++i;return *this;}
+// valuetype operator *() {return value_type(container(i),m[container(i)]);}
+// bool operator==(iterator b) {return i==b.i;}
+// const_iterator() {}
+// const_iterator(Container::iterator _i) i(_i) {}
+// };
+// iterator begin() { return iterator(container.begin());}
+// const_iterator begin() const { return iterator(container.begin());}
+// iterator end() { return iterator(container.end());}
+// const_iterator end() const { return iterator(container.end());}
+
+// private:
+
// class compareKeys {
// const Map &m;
// public:
@@ -221,6 +257,7 @@
// ValueType& second(iterator i) { return m[*i]; }
// };
+
/* ** ** Wrapper fuggvenyek ** ** */
@@ -236,7 +273,7 @@
EdgeCostMap const& edge_costs,
RetEdgeBoolMap &ret_bool_map) {
- typedef KruskalPairVec<Graph,EdgeCostMap> InputVec;
+ typedef KruskalMapInput<Graph,EdgeCostMap> InputVec;
InputVec iv(G, edge_costs);
return kruskal(G, iv, ret_bool_map);
@@ -260,13 +297,14 @@
typedef SequenceOutput<RetIterator> OutMap;
OutMap out(ret_iterator);
- typedef KruskalPairVec<Graph, EdgeCostMap> InputVec;
+ typedef KruskalMapInput<Graph, EdgeCostMap> InputVec;
InputVec iv(G, edge_costs);
return kruskal(G, iv, out);
}
+ /// @}
} //namespace hugo
Modified: hugo/branches/hugo++/src/work/makefile
==============================================================================
--- hugo/branches/hugo++/src/work/makefile (original)
+++ hugo/branches/hugo++/src/work/makefile Thu Aug 19 13:44:00 2004
@@ -1,5 +1,5 @@
INCLUDEDIRS ?= -I.. -I. -I./{marci,jacint,alpar,klao,akos}
-CXXFLAGS = -g -O3 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
+CXXFLAGS = -g -O2 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
BINARIES ?= bin_heap_demo
Modified: hugo/branches/hugo++/src/work/marci/bfs_dfs_misc.h
==============================================================================
--- hugo/branches/hugo++/src/work/marci/bfs_dfs_misc.h (original)
+++ hugo/branches/hugo++/src/work/marci/bfs_dfs_misc.h Thu Aug 19 13:44:00 2004
@@ -11,7 +11,7 @@
// ///\author Marton Makai
#include <bfs_dfs.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
namespace hugo {
Modified: hugo/branches/hugo++/src/work/marci/bfsit_vs_byhand.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/bfsit_vs_byhand.cc (original)
+++ hugo/branches/hugo++/src/work/marci/bfsit_vs_byhand.cc Thu Aug 19 13:44:00 2004
@@ -6,7 +6,7 @@
//#include <smart_graph.h>
#include <hugo/dimacs.h>
#include <hugo/time_measure.h>
-#include <hugo/for_each_macros.h>
+//#include <hugo/for_each_macros.h>
#include <bfs_dfs.h>
using namespace hugo;
@@ -21,7 +21,7 @@
Graph g;
Node s, t;
- Graph::EdgeMap<int> cap(g);
+ //Graph::EdgeMap<int> cap(g);
//readDimacsMaxFlow(std::cin, g, s, t, cap);
readDimacs(std::cin, g);
Modified: hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper.h
==============================================================================
--- hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper.h (original)
+++ hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper.h Thu Aug 19 13:44:00 2004
@@ -13,6 +13,7 @@
#include <hugo/invalid.h>
#include <iter_map.h>
#include <hugo/graph_wrapper.h>
+#include <for_each_macros.h>
namespace hugo {
Modified: hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper_test.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper_test.cc (original)
+++ hugo/branches/hugo++/src/work/marci/bipartite_graph_wrapper_test.cc Thu Aug 19 13:44:00 2004
@@ -7,12 +7,13 @@
//#include <smart_graph.h>
//#include <dimacs.h>
#include <hugo/time_measure.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
#include <bfs_dfs.h>
#include <hugo/graph_wrapper.h>
#include <bipartite_graph_wrapper.h>
#include <hugo/maps.h>
-#include <max_flow.h>
+#include <hugo/max_flow.h>
+#include <augmenting_flow.h>
using namespace hugo;
@@ -133,7 +134,7 @@
++bfs_stgw;
}
- MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
+ AugmentingFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
while (max_flow_test.augmentOnShortestPath()) { }
Modified: hugo/branches/hugo++/src/work/marci/bipartite_matching_try.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/bipartite_matching_try.cc (original)
+++ hugo/branches/hugo++/src/work/marci/bipartite_matching_try.cc Thu Aug 19 13:44:00 2004
@@ -8,12 +8,13 @@
//#include <smart_graph.h>
//#include <dimacs.h>
#include <hugo/time_measure.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
#include <bfs_dfs.h>
#include <hugo/graph_wrapper.h>
#include <bipartite_graph_wrapper.h>
#include <hugo/maps.h>
-#include <max_flow.h>
+#include <hugo/max_flow.h>
+#include <augmenting_flow.h>
/**
* Inicializalja a veletlenszamgeneratort.
@@ -163,7 +164,7 @@
Timer ts;
ts.reset();
stGW::EdgeMap<int> max_flow(stgw);
- MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
+ AugmentingFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, max_flow);
// while (max_flow_test.augmentOnShortestPath()) { }
typedef SageGraph MutableGraph;
Modified: hugo/branches/hugo++/src/work/marci/bipartite_matching_try_3.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/bipartite_matching_try_3.cc (original)
+++ hugo/branches/hugo++/src/work/marci/bipartite_matching_try_3.cc Thu Aug 19 13:44:00 2004
@@ -7,11 +7,11 @@
//#include <smart_graph.h>
//#include <dimacs.h>
#include <hugo/time_measure.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
#include <bfs_dfs.h>
#include <bipartite_graph_wrapper.h>
#include <hugo/maps.h>
-#include <max_flow.h>
+#include <hugo/max_flow.h>
#include <graph_gen.h>
#include <max_bipartite_matching.h>
Modified: hugo/branches/hugo++/src/work/marci/lg_vs_sg_vs_sg.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/lg_vs_sg_vs_sg.cc (original)
+++ hugo/branches/hugo++/src/work/marci/lg_vs_sg_vs_sg.cc Thu Aug 19 13:44:00 2004
@@ -7,9 +7,10 @@
#include <hugo/list_graph.h>
#include <hugo/smart_graph.h>
#include <hugo/dimacs.h>
-#include <max_flow.h>
+#include <hugo/max_flow.h>
+#include <augmenting_flow.h>
#include <hugo/time_measure.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
using namespace hugo;
@@ -37,6 +38,8 @@
Graph::EdgeMap<int> flow(g); //0 flow
MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
max_flow_test(g, s, t, cap, flow/*, true*/);
+ AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
+ augmenting_flow_test(g, s, t, cap, flow/*, true*/);
std::cout << "SageGraph ..." << std::endl;
@@ -53,10 +56,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
// {
@@ -75,10 +78,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
{
@@ -86,10 +89,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnShortestPath()) { ++i; }
+ while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
}
@@ -109,6 +112,8 @@
Graph::EdgeMap<int> flow(g); //0 flow
MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
max_flow_test(g, s, t, cap, flow/*, true*/);
+ AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
+ augmenting_flow_test(g, s, t, cap, flow/*, true*/);
// MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
// max_flow_test(g, s, t, cap, flow);
@@ -128,10 +133,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
// {
@@ -150,10 +155,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
{
@@ -161,10 +166,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnShortestPath()) { ++i; }
+ while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
}
@@ -184,6 +189,8 @@
Graph::EdgeMap<int> flow(g); //0 flow
MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
max_flow_test(g, s, t, cap, flow/*, true*/);
+ AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
+ augmenting_flow_test(g, s, t, cap, flow/*, true*/);
// MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
// max_flow_test(g, s, t, cap, flow);
@@ -203,10 +210,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
// {
@@ -225,10 +232,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
{
@@ -236,15 +243,12 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnShortestPath()) { ++i; }
+ while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
}
}
-
-
-
return 0;
}
Modified: hugo/branches/hugo++/src/work/marci/macro_test.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/macro_test.cc (original)
+++ hugo/branches/hugo++/src/work/marci/macro_test.cc Thu Aug 19 13:44:00 2004
@@ -3,7 +3,7 @@
#include <fstream>
#include <sage_graph.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
using namespace hugo;
Modified: hugo/branches/hugo++/src/work/marci/makefile
==============================================================================
--- hugo/branches/hugo++/src/work/marci/makefile (original)
+++ hugo/branches/hugo++/src/work/marci/makefile Thu Aug 19 13:44:00 2004
@@ -1,10 +1,11 @@
CXX2 = g++-2.95
CXX3=$(CXX)
BOOSTROOT ?= /home/marci/boost
-INCLUDEDIRS ?= -I../.. -I.. -I../{marci,jacint,alpar,klao,akos,athos} -I$(BOOSTROOT)
+INCLUDEDIRS ?= -I../{jacint,marci,alpar,klao,akos,athos} -I../.. -I.. -I$(BOOSTROOT)
LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try bipartite_matching_try_3 top_sort_test max_flow_1
+#BINARIES = preflow_bug
#gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
include ../makefile
Modified: hugo/branches/hugo++/src/work/marci/max_bipartite_matching.h
==============================================================================
--- hugo/branches/hugo++/src/work/marci/max_bipartite_matching.h (original)
+++ hugo/branches/hugo++/src/work/marci/max_bipartite_matching.h Thu Aug 19 13:44:00 2004
@@ -15,7 +15,7 @@
//#include <for_each_macros.h>
#include <bipartite_graph_wrapper.h>
//#include <hugo/maps.h>
-#include <max_flow.h>
+#include <hugo/max_flow.h>
namespace hugo {
Modified: hugo/branches/hugo++/src/work/marci/max_flow_1.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/max_flow_1.cc (original)
+++ hugo/branches/hugo++/src/work/marci/max_flow_1.cc Thu Aug 19 13:44:00 2004
@@ -7,9 +7,9 @@
#include <hugo/dimacs.h>
#include <hugo/time_measure.h>
//#include <graph_wrapper.h>
-#include <max_flow.h>
+#include <hugo/max_flow.h>
//#include <preflow_res.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
using namespace hugo;
Modified: hugo/branches/hugo++/src/work/marci/max_flow_demo.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/max_flow_demo.cc (original)
+++ hugo/branches/hugo++/src/work/marci/max_flow_demo.cc Thu Aug 19 13:44:00 2004
@@ -7,9 +7,10 @@
#include <hugo/dimacs.h>
#include <hugo/time_measure.h>
//#include <graph_wrapper.h>
-#include <max_flow.h>
+#include <hugo/max_flow.h>
+#include <augmenting_flow.h>
//#include <preflow_res.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
#include <graph_concept.h>
using namespace hugo;
@@ -38,8 +39,8 @@
typedef SageGraph MutableGraph;
//typedef FullFeatureGraphConcept Graph;
- typedef SmartGraph Graph;
- // typedef SageGraph Graph;
+ //typedef SmartGraph Graph;
+ typedef SageGraph Graph;
typedef Graph::Node Node;
typedef Graph::EdgeIt EdgeIt;
@@ -75,6 +76,9 @@
Graph::EdgeMap<int> flow(g); //0 flow
MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
max_flow_test(g, s, t, cap, flow);
+ AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
+ augmenting_flow_test(g, s, t, cap, flow);
+
Graph::NodeMap<bool> cut(g);
{
@@ -123,10 +127,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
FOR_EACH_LOC(Graph::EdgeIt, e, g) {
if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
@@ -152,10 +156,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
+ while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
FOR_EACH_LOC(Graph::EdgeIt, e, g) {
if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
@@ -170,10 +174,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnShortestPath()) { ++i; }
+ while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
FOR_EACH_LOC(Graph::EdgeIt, e, g) {
if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
@@ -188,10 +192,10 @@
FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
ts.reset();
int i=0;
- while (max_flow_test.augmentOnShortestPath2()) { ++i; }
+ while (augmenting_flow_test.augmentOnShortestPath2()) { ++i; }
std::cout << "elapsed time: " << ts << std::endl;
std::cout << "number of augmentation phases: " << i << std::endl;
- std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+ std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
FOR_EACH_LOC(Graph::EdgeIt, e, g) {
if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
Modified: hugo/branches/hugo++/src/work/marci/top_sort_test.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/top_sort_test.cc (original)
+++ hugo/branches/hugo++/src/work/marci/top_sort_test.cc Thu Aug 19 13:44:00 2004
@@ -8,7 +8,7 @@
#include <sage_graph.h>
#include <hugo/graph_wrapper.h>
#include <hugo/maps.h>
-#include <hugo/for_each_macros.h>
+#include <for_each_macros.h>
using namespace hugo;
More information about the Lemon-commits
mailing list