[Lemon-commits] [lemon_svn] marci: r840 - in hugo/trunk/src/work: . marci

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:41:47 CET 2006


Author: marci
Date: Fri May 14 20:28:57 2004
New Revision: 840

Added:
   hugo/trunk/src/work/sage_graph.h
      - copied, changed from r838, /hugo/trunk/src/work/list_graph.h
Removed:
   hugo/trunk/src/work/list_graph.h
Modified:
   hugo/trunk/src/work/marci/bfsit_vs_byhand.cc
   hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc
   hugo/trunk/src/work/marci/bipartite_matching_try.cc
   hugo/trunk/src/work/marci/bipartite_matching_try_3.cc
   hugo/trunk/src/work/marci/iterator_bfs_demo.cc
   hugo/trunk/src/work/marci/lg_vs_sg.cc
   hugo/trunk/src/work/marci/macro_test.cc
   hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc
   hugo/trunk/src/work/marci/max_flow_1.cc
   hugo/trunk/src/work/marci/max_flow_demo.cc
   hugo/trunk/src/work/marci/top_sort_test.cc

Log:
To avoid confusion my old ListGraph is can be used under name SageGraph, work/sage_graph.h contains it.


Modified: hugo/trunk/src/work/marci/bfsit_vs_byhand.cc
==============================================================================
--- hugo/trunk/src/work/marci/bfsit_vs_byhand.cc	(original)
+++ hugo/trunk/src/work/marci/bfsit_vs_byhand.cc	Fri May 14 20:28:57 2004
@@ -2,7 +2,7 @@
 #include <iostream>
 #include <fstream>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 //#include <smart_graph.h>
 #include <hugo/dimacs.h>
 #include <hugo/time_measure.h>
@@ -12,7 +12,7 @@
 using namespace hugo;
 
 int main() {
-  typedef ListGraph Graph; 
+  typedef SageGraph Graph; 
   typedef Graph::Node Node;
   typedef Graph::NodeIt NodeIt;
   typedef Graph::Edge Edge;

Modified: hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc	Fri May 14 20:28:57 2004
@@ -3,7 +3,7 @@
 #include <fstream>
 #include <vector>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 //#include <smart_graph.h>
 //#include <dimacs.h>
 #include <hugo/time_measure.h>
@@ -17,7 +17,7 @@
 using namespace hugo;
 
 int main() {
-  typedef UndirListGraph Graph; 
+  typedef UndirSageGraph Graph; 
   typedef Graph::Node Node;
   typedef Graph::NodeIt NodeIt;
   typedef Graph::Edge Edge;

Modified: hugo/trunk/src/work/marci/bipartite_matching_try.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_matching_try.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_matching_try.cc	Fri May 14 20:28:57 2004
@@ -4,7 +4,7 @@
 #include <vector>
 #include <cstdlib>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 //#include <smart_graph.h>
 //#include <dimacs.h>
 #include <hugo/time_measure.h>
@@ -40,7 +40,7 @@
 using namespace hugo;
 
 int main() {
-  typedef UndirListGraph Graph; 
+  typedef UndirSageGraph Graph; 
   typedef Graph::Node Node;
   typedef Graph::NodeIt NodeIt;
   typedef Graph::Edge Edge;
@@ -166,7 +166,7 @@
   MaxFlow<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 ListGraph MutableGraph;
+  typedef SageGraph MutableGraph;
 //  while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
   while (max_flow_test.augmentOnBlockingFlow2()) {
    std::cout << max_flow_test.flowValue() << std::endl;

Modified: hugo/trunk/src/work/marci/bipartite_matching_try_3.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_matching_try_3.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_matching_try_3.cc	Fri May 14 20:28:57 2004
@@ -3,7 +3,7 @@
 #include <fstream>
 #include <vector>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 //#include <smart_graph.h>
 //#include <dimacs.h>
 #include <hugo/time_measure.h>
@@ -19,7 +19,7 @@
 
 int main() {
   //typedef UndirListGraph Graph; 
-  typedef BipartiteGraph<ListGraph> Graph;
+  typedef BipartiteGraph<SageGraph> Graph;
   
   typedef Graph::Node Node;
   typedef Graph::NodeIt NodeIt;

Modified: hugo/trunk/src/work/marci/iterator_bfs_demo.cc
==============================================================================
--- hugo/trunk/src/work/marci/iterator_bfs_demo.cc	(original)
+++ hugo/trunk/src/work/marci/iterator_bfs_demo.cc	Fri May 14 20:28:57 2004
@@ -3,7 +3,7 @@
 #include <vector>
 #include <string>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 //#include <smart_graph.h>
 #include <bfs_dfs.h>
 #include <hugo/graph_wrapper.h>
@@ -29,7 +29,7 @@
 int main (int, char*[])
 {
   //typedef SmartGraph Graph;
-  typedef ListGraph Graph;
+  typedef SageGraph Graph;
 
   typedef Graph::Node Node;
   typedef Graph::Edge Edge;

Modified: hugo/trunk/src/work/marci/lg_vs_sg.cc
==============================================================================
--- hugo/trunk/src/work/marci/lg_vs_sg.cc	(original)
+++ hugo/trunk/src/work/marci/lg_vs_sg.cc	Fri May 14 20:28:57 2004
@@ -3,7 +3,8 @@
 #include <fstream>
 #include <string>
 
-#include <list_graph.h>
+#include <sage_graph.h>
+#include <hugo/list_graph.h>
 #include <hugo/smart_graph.h>
 #include <hugo/dimacs.h>
 #include <max_flow.h>
@@ -18,10 +19,10 @@
 int main(int, char** argv) {
 
   std::string in=argv[1];
-  typedef ListGraph MutableGraph;
+  typedef SageGraph MutableGraph;
 
   {
-    typedef ListGraph Graph;
+    typedef SageGraph Graph;
     typedef Graph::Node Node;
     typedef Graph::EdgeIt EdgeIt;
 
@@ -37,7 +38,7 @@
     MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
       max_flow_test(g, s, t, cap, flow/*, true*/);
 
-    std::cout << "ListGraph ..." << std::endl;
+    std::cout << "SageGraph ..." << std::endl;
 
     {
       std::cout << "preflow ..." << std::endl;
@@ -92,7 +93,6 @@
     }
   }
 
-
   {
     typedef SmartGraph Graph;
     typedef Graph::Node Node;
@@ -112,7 +112,82 @@
     //    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
     //  max_flow_test(g, s, t, cap, flow);
 
-    std::cout << "SmatrGraph ..." << std::endl;
+    std::cout << "SmartGraph ..." << std::endl;
+
+    {
+      std::cout << "preflow ..." << std::endl;
+      FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
+      ts.reset();
+      max_flow_test.run();
+      std::cout << "elapsed time: " << ts << std::endl;
+      std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+    }
+
+    {
+      std::cout << "physical blocking flow augmentation ..." << std::endl;
+      FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
+      ts.reset();
+      int i=0;
+      while (max_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 << "faster physical blocking flow augmentation ..." << std::endl;
+//       FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
+//       ts.reset();
+//       int i=0;
+//       while (max_flow_test.augmentOnBlockingFlow1<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 << "on-the-fly blocking flow augmentation ..." << std::endl;
+      FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
+      ts.reset();
+      int i=0;
+      while (max_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 << "on-the-fly shortest path augmentation ..." << std::endl;
+      FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
+      ts.reset();
+      int i=0;
+      while (max_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;
+    }
+  }
+
+  {
+    typedef ListGraph Graph;
+    typedef Graph::Node Node;
+    typedef Graph::EdgeIt EdgeIt;
+
+    Graph g;
+    Node s, t;
+    Graph::EdgeMap<int> cap(g);
+    std::ifstream ins(in.c_str());
+    //readDimacsMaxFlow(ins, g, s, t, cap);
+    readDimacs(ins, g, cap, s, t);
+
+    Timer ts;
+    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*/);
+    //    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
+    //  max_flow_test(g, s, t, cap, flow);
+
+    std::cout << "ListGraph ..." << std::endl;
 
     {
       std::cout << "preflow ..." << std::endl;

Modified: hugo/trunk/src/work/marci/macro_test.cc
==============================================================================
--- hugo/trunk/src/work/marci/macro_test.cc	(original)
+++ hugo/trunk/src/work/marci/macro_test.cc	Fri May 14 20:28:57 2004
@@ -2,14 +2,14 @@
 #include <iostream>
 #include <fstream>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 #include <hugo/for_each_macros.h>
 
 using namespace hugo;
 
 int main() 
 {
-  typedef ListGraph Graph;
+  typedef SageGraph Graph;
   Graph g;
   Graph::Node n1=g.addNode();
   Graph::Node n2=g.addNode();

Modified: hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc
==============================================================================
--- hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc	(original)
+++ hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc	Fri May 14 20:28:57 2004
@@ -9,7 +9,7 @@
 #include <LEDA/list.h>
 
 #include <leda_graph_wrapper.h>
-#include <list_graph.h>
+#include <sage_graph.h>
 #include <dimacs.h>
 #include <time_measure.h>
 #include <edmonds_karp.h>

Modified: hugo/trunk/src/work/marci/max_flow_1.cc
==============================================================================
--- hugo/trunk/src/work/marci/max_flow_1.cc	(original)
+++ hugo/trunk/src/work/marci/max_flow_1.cc	Fri May 14 20:28:57 2004
@@ -2,7 +2,7 @@
 #include <iostream>
 #include <fstream>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 #include <hugo/smart_graph.h>
 #include <hugo/dimacs.h>
 #include <hugo/time_measure.h>
@@ -19,7 +19,7 @@
 
 int main(int, char **) {
 
-  typedef ListGraph MutableGraph;
+  typedef SageGraph MutableGraph;
 
   typedef SmartGraph Graph;
   //  typedef ListGraph Graph;

Modified: hugo/trunk/src/work/marci/max_flow_demo.cc
==============================================================================
--- hugo/trunk/src/work/marci/max_flow_demo.cc	(original)
+++ hugo/trunk/src/work/marci/max_flow_demo.cc	Fri May 14 20:28:57 2004
@@ -2,7 +2,7 @@
 #include <iostream>
 #include <fstream>
 
-#include <list_graph.h>
+#include <sage_graph.h>
 #include <hugo/smart_graph.h>
 #include <hugo/dimacs.h>
 #include <hugo/time_measure.h>
@@ -34,10 +34,10 @@
 
 int main(int, char **) {
 
-  typedef ListGraph MutableGraph;
+  typedef SageGraph MutableGraph;
 
   typedef SmartGraph Graph;
-  //  typedef ListGraph Graph;
+  //  typedef SageGraph Graph;
   typedef Graph::Node Node;
   typedef Graph::EdgeIt EdgeIt;
 

Modified: hugo/trunk/src/work/marci/top_sort_test.cc
==============================================================================
--- hugo/trunk/src/work/marci/top_sort_test.cc	(original)
+++ hugo/trunk/src/work/marci/top_sort_test.cc	Fri May 14 20:28:57 2004
@@ -5,7 +5,7 @@
 
 #include <hugo/dimacs.h>
 #include <bfs_dfs_misc.h>
-#include <list_graph.h>
+#include <sage_graph.h>
 #include <hugo/graph_wrapper.h>
 #include <hugo/maps.h>
 #include <hugo/for_each_macros.h>
@@ -16,7 +16,7 @@
 using std::endl;
 
 int main() {
-  typedef ListGraph Graph;
+  typedef SageGraph Graph;
   Graph g;
   readDimacs(std::cin, g); 
  

Copied: hugo/trunk/src/work/sage_graph.h (from r838, /hugo/trunk/src/work/list_graph.h)
==============================================================================
--- /hugo/trunk/src/work/list_graph.h	(original)
+++ hugo/trunk/src/work/sage_graph.h	Fri May 14 20:28:57 2004
@@ -1,6 +1,6 @@
 // -*- c++ -*-
-#ifndef HUGO_LIST_GRAPH_H
-#define HUGO_LIST_GRAPH_H
+#ifndef HUGO_SAGE_GRAPH_H
+#define HUGO_SAGE_GRAPH_H
 
 #include <iostream>
 #include <vector>
@@ -16,7 +16,7 @@
     return i;
   }
 
-  class ListGraph {
+  class SageGraph {
     struct node_item;
     struct edge_item;
   public:
@@ -35,13 +35,13 @@
  
     template <typename T>
     class NodeMap {
-      const ListGraph& G; 
+      const SageGraph& G; 
       std::vector<T> container;
     public:
       typedef T ValueType;
       typedef Node KeyType;
-      NodeMap(const ListGraph& _G) : G(_G), container(G.node_id) { }
-      NodeMap(const ListGraph& _G, T a) : 
+      NodeMap(const SageGraph& _G) : G(_G), container(G.node_id) { }
+      NodeMap(const SageGraph& _G, T a) : 
 	G(_G), container(G.node_id, a) { }
       void set(Node n, T a) { container[/*G.id(n)*/n.node->id]=a; }
 //      T get(Node n) const { return container[/*G.id(n)*/n.node->id]; }
@@ -56,13 +56,13 @@
 
     template <typename T>
     class EdgeMap {
-      const ListGraph& G; 
+      const SageGraph& G; 
       std::vector<T> container;
     public:
       typedef T ValueType;
       typedef Edge KeyType;
-      EdgeMap(const ListGraph& _G) : G(_G), container(G.edge_id) { }
-      EdgeMap(const ListGraph& _G, T a) : 
+      EdgeMap(const SageGraph& _G) : G(_G), container(G.edge_id) { }
+      EdgeMap(const SageGraph& _G, T a) : 
 	G(_G), container(G.edge_id, a) { }
       void set(Edge e, T a) { container[/*G.id(e)*/e.edge->id]=a; }
 //      T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; }
@@ -202,9 +202,9 @@
 
     /* default constructor */
 
-    ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0) { }
+    SageGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0) { }
     
-    ~ListGraph() { 
+    ~SageGraph() { 
       NodeIt n;
       while (this->valid(first(n))) erase(n);
       //while (first<NodeIt>().valid()) erase(first<NodeIt>());
@@ -355,7 +355,7 @@
 //     }
 
     class Node {
-      friend class ListGraph;
+      friend class SageGraph;
       template <typename T> friend class NodeMap;
 
       friend class Edge;
@@ -366,7 +366,7 @@
     protected:
       node_item* node;
     protected:
-      friend int ListGraph::id(Node v) const; 
+      friend int SageGraph::id(Node v) const; 
     public:
       Node() /*: node(0)*/ { }
       Node(const Invalid&) : node(0) { }
@@ -381,10 +381,10 @@
     };
     
     class NodeIt : public Node {
-      friend class ListGraph;
+      friend class SageGraph;
       //protected:
     public: //for everybody but marci
-      NodeIt(const ListGraph& G) : Node(G._first_node) { }
+      NodeIt(const SageGraph& G) : Node(G._first_node) { }
     public:
       NodeIt() : Node() { }
       NodeIt(const Invalid& i) : Node(i) { }
@@ -397,14 +397,14 @@
     };
 
     class Edge {
-      friend class ListGraph;
+      friend class SageGraph;
       template <typename T> friend class EdgeMap;
       
       friend class Node;
       friend class NodeIt;
     protected:
       edge_item* edge;
-      friend int ListGraph::id(Edge e) const;
+      friend int SageGraph::id(Edge e) const;
     public:
       Edge() /*: edge(0)*/ { }
       Edge(const Invalid&) : edge(0) { }
@@ -424,10 +424,10 @@
     };
     
     class EdgeIt : public Edge {
-      friend class ListGraph;
+      friend class SageGraph;
       //protected: 
     public: //for alpar
-      EdgeIt(const ListGraph& G) {
+      EdgeIt(const SageGraph& G) {
 	node_item* v=G._first_node;
 	if (v) edge=v->_first_out_edge; else edge=0;
 	while (v && !edge) { v=v->_next_node; if (v) edge=v->_first_out_edge; }
@@ -446,7 +446,7 @@
     };
     
     class OutEdgeIt : public Edge {
-      friend class ListGraph;
+      friend class SageGraph;
       //node_item* v;
       //protected: 
     protected: //for alpar
@@ -454,7 +454,7 @@
     public:
       OutEdgeIt() : Edge()/*, v(0)*/ { }
       OutEdgeIt(const Invalid& i) : Edge(i) { }
-      OutEdgeIt(const ListGraph&, Node _v) /*: v(_v.node)*/ { edge=_v.node->_first_out_edge; }
+      OutEdgeIt(const SageGraph&, Node _v) /*: v(_v.node)*/ { edge=_v.node->_first_out_edge; }
     protected:
       OutEdgeIt& operator++() { edge=edge->_next_out; return *this; }
     protected:
@@ -463,7 +463,7 @@
     };
     
     class InEdgeIt : public Edge {
-      friend class ListGraph;
+      friend class SageGraph;
       //node_item* v;
       //protected:
     protected: //for alpar
@@ -471,7 +471,7 @@
     public:
       InEdgeIt() : Edge()/*, v(0)*/ { }
       InEdgeIt(const Invalid& i) : Edge(i) { }
-      InEdgeIt(const ListGraph&, Node _v) /*: v(_v.node)*/ { edge=_v.node->_first_in_edge; }
+      InEdgeIt(const SageGraph&, Node _v) /*: v(_v.node)*/ { edge=_v.node->_first_in_edge; }
     protected:
       InEdgeIt& operator++() { edge=edge->_next_in; return *this; }
     protected:
@@ -480,7 +480,7 @@
     };
 
     class SymEdgeIt : public Edge {
-      friend class ListGraph;
+      friend class SageGraph;
       bool out_or_in; //1 iff out, 0 iff in
       //node_item* v;
       //protected:
@@ -493,7 +493,7 @@
     public:
       SymEdgeIt() : Edge() /*, v(0)*/ { }
       SymEdgeIt(const Invalid& i) : Edge(i) { }
-      SymEdgeIt(const ListGraph&, Node _v) /*: v(_v.node)*/ { 
+      SymEdgeIt(const SageGraph&, Node _v) /*: v(_v.node)*/ { 
 	out_or_in=1;
 	edge=_v.node->_first_out_edge; 
 	if (!edge) { edge=_v.node->_first_in_edge; out_or_in=0; }
@@ -518,7 +518,7 @@
   };
 
   inline
-  std::ostream& operator<<(std::ostream& os, const ListGraph::Node& i) { 
+  std::ostream& operator<<(std::ostream& os, const SageGraph::Node& i) { 
     if (i.valid())
       os << i.node->id;
     else
@@ -527,7 +527,7 @@
   }
 
   inline
-  std::ostream& operator<<(std::ostream& os, const ListGraph::Edge& i) { 
+  std::ostream& operator<<(std::ostream& os, const SageGraph::Edge& i) { 
     if (i.valid()) 
       os << "(" << i.tailNode() << "--" << i.edge->id << "->" 
 	 << i.headNode() << ")"; 
@@ -536,7 +536,7 @@
     return os; 
   }
 
-  class UndirListGraph : public ListGraph {
+  class UndirSageGraph : public SageGraph {
   public:
     typedef SymEdgeIt OutEdgeIt;
     typedef SymEdgeIt InEdgeIt;
@@ -544,4 +544,4 @@
 
 } //namespace hugo
 
-#endif //HUGO_LIST_GRAPH_H
+#endif //HUGO_SAGE_GRAPH_H



More information about the Lemon-commits mailing list