# HG changeset patch # User marci # Date 1095343176 0 # Node ID f3cc65f9fb6b63c7f0b778355e6919b2af8b685e # Parent 7477e00f1a644c289ca8b1fa07ccc01e4d4cb606 Demo file for SubGraphWrapper. Documentation will be added later. The purpose of this graph is to have an easy and short demo for the above class. diff -r 7477e00f1a64 -r f3cc65f9fb6b src/demo/sub_graph_wrapper_demo.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/demo/sub_graph_wrapper_demo.cc Thu Sep 16 13:59:36 2004 +0000 @@ -0,0 +1,71 @@ +// -*- c++ -*- + +// Use a DIMACS max flow file as stdin. +// sub_graph_wrapper_demo < dimacs_max_flow_file + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace hugo; + +using std::cout; +using std::endl; + +int main() +{ + typedef SmartGraph Graph; + + typedef Graph::Edge Edge; + typedef Graph::Node Node; + typedef Graph::EdgeIt EdgeIt; + typedef Graph::NodeIt NodeIt; + typedef Graph::EdgeMap LengthMap; + + Graph g; + Node s, t; + LengthMap length(g); + + readDimacs(std::cin, g, length, s, t); + + cout << "edges with lengths (of form tail--length->head): " << endl; + for(EdgeIt e(g); e!=INVALID; ++e) + cout << " " << g.id(g.tail(e)) << "--" + << length[e] << "->" << g.id(g.head(e)) << endl; + + cout << "s: " << g.id(s) << " t: " << g.id(t) << endl; + + typedef Dijkstra Dijkstra; + Dijkstra dijkstra(g, length); + dijkstra.run(s); + + typedef TightEdgeFilterMap + TightEdgeFilter; + TightEdgeFilter tight_edge_filter(g, dijkstra.distMap(), length); + + ConstMap const_true_map(true); + typedef SubGraphWrapper, TightEdgeFilter> SubGW; + SubGW gw(g, const_true_map, tight_edge_filter); + + ConstMap const_1_map(1); + Graph::EdgeMap flow(g, 0); + Preflow, Graph::EdgeMap > + preflow(gw, s, t, const_1_map, flow); + preflow.run(); + + cout << "edges of the maximum number of edge-disjoint shortest s-t paths: " + << endl; + for(EdgeIt e(g); e!=INVALID; ++e) + if (flow[e]) + cout << " " << g.id(g.tail(e)) << "--" + << length[e] << "->" << g.id(g.head(e)) << endl; + + return 0; +} diff -r 7477e00f1a64 -r f3cc65f9fb6b src/demo/sub_graph_wrapper_demo.dim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/demo/sub_graph_wrapper_demo.dim Thu Sep 16 13:59:36 2004 +0000 @@ -0,0 +1,14 @@ +c HUGO max flow problem +p max 7 9 +n 1 s +n 7 t +a 1 2 3 +a 1 3 2 +a 1 4 1 +a 2 5 3 +a 3 5 2 +a 3 7 5 +a 3 6 3 +a 4 6 1 +a 5 7 2 +a 6 7 4 diff -r 7477e00f1a64 -r f3cc65f9fb6b src/work/makefile --- a/src/work/makefile Thu Sep 16 13:57:41 2004 +0000 +++ b/src/work/makefile Thu Sep 16 13:59:36 2004 +0000 @@ -1,5 +1,5 @@ INCLUDEDIRS ?= -I.. -I. -I./{marci,jacint,alpar,klao,akos} -CXXFLAGS = -g -O0 -W -Wall $(INCLUDEDIRS) -ansi -pedantic +CXXFLAGS = -g -O3 -W -Wall $(INCLUDEDIRS) -ansi -pedantic BINARIES ?= bin_heap_demo diff -r 7477e00f1a64 -r f3cc65f9fb6b src/work/marci/sub_graph_wrapper_demo.cc --- a/src/work/marci/sub_graph_wrapper_demo.cc Thu Sep 16 13:57:41 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -// -*- c++ -*- - -// Use a DIMACS max flow file as stdin. -// sub_graph_wrapper_demo < dimacs_max_flow_file - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace hugo; - -using std::cout; -using std::endl; - -int main() -{ - typedef SmartGraph Graph; - - typedef Graph::Edge Edge; - typedef Graph::Node Node; - typedef Graph::EdgeIt EdgeIt; - typedef Graph::NodeIt NodeIt; - typedef Graph::EdgeMap LengthMap; - - Graph g; - Node s, t; - LengthMap length(g); - - readDimacs(std::cin, g, length, s, t); - - cout << "edges with lengths (of form tail--length->head): " << endl; - for(EdgeIt e(g); e!=INVALID; ++e) - cout << " " << g.id(g.tail(e)) << "--" - << length[e] << "->" << g.id(g.head(e)) << endl; - - cout << "s: " << g.id(s) << " t: " << g.id(t) << endl; - - typedef Dijkstra Dijkstra; - Dijkstra dijkstra(g, length); - dijkstra.run(s); - - typedef TightEdgeFilterMap - TightEdgeFilter; - TightEdgeFilter tight_edge_filter(g, dijkstra.distMap(), length); - - ConstMap const_true_map(true); - typedef SubGraphWrapper, TightEdgeFilter> SubGW; - SubGW gw(g, const_true_map, tight_edge_filter); - - ConstMap const_1_map(1); - Graph::EdgeMap flow(g, 0); - Preflow, Graph::EdgeMap > - preflow(gw, s, t, const_1_map, flow); - preflow.run(); - - cout << "edges of the maximum number of edge-disjoint shortest s-t paths: " - << endl; - for(EdgeIt e(g); e!=INVALID; ++e) - if (flow[e]) - cout << " " << g.id(g.tail(e)) << "--" - << length[e] << "->" << g.id(g.head(e)) << endl; - - return 0; -} diff -r 7477e00f1a64 -r f3cc65f9fb6b src/work/marci/sub_graph_wrapper_demo.dim --- a/src/work/marci/sub_graph_wrapper_demo.dim Thu Sep 16 13:57:41 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -c HUGO max flow problem -p max 7 9 -n 1 s -n 7 t -a 1 2 3 -a 1 3 2 -a 1 4 1 -a 2 5 3 -a 3 5 2 -a 3 7 5 -a 3 6 3 -a 4 6 1 -a 5 7 2 -a 6 7 4