[Lemon-commits] [lemon_svn] marci: r1042 - in hugo/branches/hugo++/src/work: . marci
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:55 CET 2006
Author: marci
Date: Wed Aug 25 19:12:29 2004
New Revision: 1042
Modified:
hugo/branches/hugo++/src/work/marci/bfsit_vs_byhand.cc
hugo/branches/hugo++/src/work/sage_graph.h
Log:
bug fix, hugo 0.2 stuff
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 Wed Aug 25 19:12:29 2004
@@ -3,7 +3,7 @@
#include <fstream>
#include <sage_graph.h>
-//#include <smart_graph.h>
+#include <hugo/smart_graph.h>
#include <hugo/dimacs.h>
#include <hugo/time_measure.h>
//#include <hugo/for_each_macros.h>
@@ -11,6 +11,9 @@
using namespace hugo;
+using std::cout;
+using std::endl;
+
int main() {
typedef SageGraph Graph;
typedef Graph::Node Node;
@@ -20,12 +23,18 @@
typedef Graph::OutEdgeIt OutEdgeIt;
Graph g;
- Node s, t;
+ //Node s;
//Graph::EdgeMap<int> cap(g);
//readDimacsMaxFlow(std::cin, g, s, t, cap);
readDimacs(std::cin, g);
+ NodeIt s;
+ g.first(s);
+
+ cout << g.nodeNum() << endl;
+ cout << g.edgeNum() << endl;
Graph::NodeMap<OutEdgeIt> pred(g);
+ cout << "iteration time of bfs written by hand..." << endl;
Timer ts;
{
ts.reset();
@@ -33,7 +42,7 @@
reached.set(s, true);
pred.set(s, INVALID);
std::queue<Node> bfs_queue;
- bfs_queue.push(t);
+ bfs_queue.push(s);
while (!bfs_queue.empty()) {
Node v=bfs_queue.front();
bfs_queue.pop();
@@ -51,6 +60,7 @@
std::cout << ts << std::endl;
}
+ cout << "iteration time with bfs iterator..." << endl;
{
ts.reset();
BfsIterator< Graph, Graph::NodeMap<bool> > bfs(g);
Modified: hugo/branches/hugo++/src/work/sage_graph.h
==============================================================================
--- hugo/branches/hugo++/src/work/sage_graph.h (original)
+++ hugo/branches/hugo++/src/work/sage_graph.h Wed Aug 25 19:12:29 2004
@@ -9,12 +9,12 @@
namespace hugo {
- template <typename It>
- int count(It it) {
- int i=0;
- for( ; it.valid(); ++it) { ++i; }
- return i;
- }
+// template <typename It>
+// int count(It it) {
+// int i=0;
+// for( ; it.valid(); ++it) { ++i; }
+// return i;
+// }
class SageGraph {
struct node_item;
@@ -385,11 +385,13 @@
//protected:
public: //for everybody but marci
NodeIt(const SageGraph& G) : Node(G._first_node) { }
+ NodeIt(const SageGraph& G, const Node& n) : Node(n) { }
public:
NodeIt() : Node() { }
NodeIt(const Invalid& i) : Node(i) { }
protected:
NodeIt(node_item* v) : Node(v) { }
+ public:
NodeIt& operator++() { node=node->_next_node; return *this; }
//FIXME::
// NodeIt& operator=(const Node& e)
@@ -425,18 +427,18 @@
class EdgeIt : public Edge {
friend class SageGraph;
- //protected:
- public: //for alpar
+ public:
+ EdgeIt() : Edge() { }
+ EdgeIt(const Invalid& i) : Edge(i) { }
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; }
}
+ EdgeIt(const SageGraph& G, const Edge& e) : Edge(e) { }
+// protected:
+// EdgeIt(edge_item* _e) : Edge(_e) { }
public:
- EdgeIt() : Edge() { }
- EdgeIt(const Invalid& i) : Edge(i) { }
- protected:
- EdgeIt(edge_item* _e) : Edge(_e) { }
EdgeIt& operator++() {
node_item* v=edge->_tail;
edge=edge->_next_out;
@@ -447,15 +449,11 @@
class OutEdgeIt : public Edge {
friend class SageGraph;
- //node_item* v;
- //protected:
- protected: //for alpar
- OutEdgeIt(const Node& _v) /*: v(_v.node)*/ { edge=_v.node->_first_out_edge; }
public:
- OutEdgeIt() : Edge()/*, v(0)*/ { }
+ OutEdgeIt() : Edge() { }
OutEdgeIt(const Invalid& i) : Edge(i) { }
- OutEdgeIt(const SageGraph&, Node _v) /*: v(_v.node)*/ { edge=_v.node->_first_out_edge; }
- protected:
+ OutEdgeIt(const SageGraph&, Node _v) : Edge(_v.node->_first_out_edge) { }
+ OutEdgeIt(const SageGraph&, const Edge& e) : Edge(e) { }
OutEdgeIt& operator++() { edge=edge->_next_out; return *this; }
protected:
Node aNode() const { return Node(edge->_tail); }
@@ -464,15 +462,11 @@
class InEdgeIt : public Edge {
friend class SageGraph;
- //node_item* v;
- //protected:
- protected: //for alpar
- InEdgeIt(const Node& _v) /*: v(_v.node)*/ { edge=_v.node->_first_in_edge; }
public:
- InEdgeIt() : Edge()/*, v(0)*/ { }
- InEdgeIt(const Invalid& i) : Edge(i) { }
- InEdgeIt(const SageGraph&, Node _v) /*: v(_v.node)*/ { edge=_v.node->_first_in_edge; }
- protected:
+ InEdgeIt() : Edge() { }
+ InEdgeIt(Invalid i) : Edge(i) { }
+ InEdgeIt(const SageGraph&, Node _v) : Edge(_v.node->_first_in_edge) { }
+ InEdgeIt(const SageGraph&, const Edge& e) : Edge(e) { }
InEdgeIt& operator++() { edge=edge->_next_in; return *this; }
protected:
Node aNode() const { return Node(edge->_head); }
More information about the Lemon-commits
mailing list