[Lemon-commits] [lemon_svn] alpar: r3002 - hugo/trunk/benchmark
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 21:51:45 CET 2006
Author: alpar
Date: Tue Oct 17 13:02:30 2006
New Revision: 3002
Modified:
hugo/trunk/benchmark/edge_lookup.cc
hugo/trunk/benchmark/edge_lookup_test.h
Log:
A trial to make the last test platform independent.
Modified: hugo/trunk/benchmark/edge_lookup.cc
==============================================================================
--- hugo/trunk/benchmark/edge_lookup.cc (original)
+++ hugo/trunk/benchmark/edge_lookup.cc Tue Oct 17 13:02:30 2006
@@ -75,22 +75,22 @@
};
-// class EL4
-// {
-// public:
-// Graph &_g;
-// EdgeLookUp4<Graph> _el;
-// EL4(Graph &g) :_g(g), _el(g) {}
-// void operator()()
-// {
-// Edge e;
+class EL4
+{
+public:
+ Graph &_g;
+ EdgeLookUp4<Graph> _el;
+ EL4(Graph &g) :_g(g), _el(g) {}
+ void operator()()
+ {
+ Edge e;
-// for(NodeIt v(_g);v!=INVALID;++v)
-// for(NodeIt u(_g);u!=INVALID;++u)
-// e=_el(u,v);
-// }
+ for(NodeIt v(_g);v!=INVALID;++v)
+ for(NodeIt u(_g);u!=INVALID;++u)
+ e=_el(u,v);
+ }
-// };
+};
int main(int, char**argv)
{
Modified: hugo/trunk/benchmark/edge_lookup_test.h
==============================================================================
--- hugo/trunk/benchmark/edge_lookup_test.h (original)
+++ hugo/trunk/benchmark/edge_lookup_test.h Tue Oct 17 13:02:30 2006
@@ -189,92 +189,98 @@
};
-// template<class G>
-// class EdgeLookUp4
-// {
-// public:
-// GRAPH_TYPEDEFS(typename G)
-// typedef G Graph;
-
-// private:
-// const Graph &_g;
-// typename Graph::template NodeMap<Edge*> _start;
-// typename Graph::template NodeMap<Edge*> _end;
-// std::vector<Edge> _edges;
-
-// class EdgeLess {
-// const Graph &g;
-// public:
-// EdgeLess(const Graph &_g) : g(_g) {}
-// bool operator()(Edge a,Edge b) const
-// {
-// return g.target(a)<g.target(b);
-// }
-// };
-
-// public:
-
-// ///Constructor
-// EdgeLookUp4(const Graph &g) :_g(g),_start(g),_end(g) {refresh();}
-
-// public:
-// ///Refresh the data structure at a node.
-// void refresh(Node n)
-// {
-// const int bi = _start[n] = _edges.size();
-// for(OutEdgeIt e(_g,n);e!=INVALID;++e) _edges.push_back(e);
-// const typename std::vector<Edge>::iterator ei=_edges.end();
-// _end[n]=_edges.size();
-// std::sort(_edges.begin()+bi,ei,EdgeLess(_g));
-// }
-// ///Refresh the full data structure.
-// void refresh()
-// {
-// _edges.resize(countEdges(_g));
-// int l=0;
-// for(NodeIt n(_g);n!=INVALID;++n)
-// {
-// int ls = l;
-// _start[n]=&(_edges[l]);
-// for(OutEdgeIt e(_g,n);e!=INVALID;++e) _edges[l++]=e;
-// _end[n]=&(_edges[l]);
-// std::sort(_edges.begin()+ls,_edges.begin()+l,EdgeLess(_g));
-// }
+ template<class G>
+ class EdgeLookUp4
+ {
+ public:
+ GRAPH_TYPEDEFS(typename G)
+ typedef G Graph;
+
+ private:
+ const Graph &_g;
+ typename Graph::template NodeMap<Edge*> _start;
+ typename Graph::template NodeMap<Edge*> _end;
+ std::vector<Edge> _edges;
+
+ class EdgeLess {
+ const Graph &g;
+ public:
+ EdgeLess(const Graph &_g) : g(_g) {}
+ bool operator()(Edge a,Edge b) const
+ {
+ return g.target(a)<g.target(b);
+ }
+ };
+
+ public:
+
+ ///Constructor
+ EdgeLookUp4(const Graph &g) :_g(g),_start(g),_end(g) {refresh();}
+
+ public:
+ ///Refresh the data structure at a node.
+ void refresh(Node n)
+ {
+ const int bi = _start[n] = _edges.size();
+ for(OutEdgeIt e(_g,n);e!=INVALID;++e) _edges.push_back(e);
+ const typename std::vector<Edge>::iterator ei=_edges.end();
+ _end[n]=_edges.size();
+ std::sort(_edges.begin()+bi,ei,EdgeLess(_g));
+ }
+ ///Refresh the full data structure.
+ void refresh()
+ {
+ _edges.resize(countEdges(_g));
+ int l=0;
+ for(NodeIt n(_g);n!=INVALID;++n)
+ {
+ int ls = l;
+ _start[n]=&(_edges[l]);
+ for(OutEdgeIt e(_g,n);e!=INVALID;++e) _edges[l++]=e;
+ _end[n]=&(_edges[l]);
+ std::sort(_edges.begin()+ls,_edges.begin()+l,EdgeLess(_g));
+ }
-// }
+ }
-// ///Find an edge between two nodes.
+ ///Find an edge between two nodes.
-// ///Find an edge between two nodes.
-// ///\param s The source node
-// ///\param t The target node
-// ///\return An edge from \c s to \c t if there exists,
-// ///\ref INVALID otherwise.
-
-// Edge operator()(Node s, Node t)
-// {
-// Edge *a=_start[s];
-// Edge *b=_end[s];
-// while(a!=b)
-// {
-// Edge *m=(Edge*)(((unsigned int)a+(unsigned int)b)/2 & 0xfffffffc);
-// Node tt = _g.target(*m);
-// if(tt==t) return *m;
-// else if(tt<t) a=m+1;
-// else b=m;
-// }
-// return INVALID;
-// }
+ ///Find an edge between two nodes.
+ ///\param s The source node
+ ///\param t The target node
+ ///\return An edge from \c s to \c t if there exists,
+ ///\ref INVALID otherwise.
+
+ Edge operator()(Node s, Node t)
+ {
+ Edge *a=_start[s];
+ Edge *b=_end[s];
+ while(a!=b)
+ {
+#ifdef X86
+ Edge *m=(Edge*)(((unsigned int)a+(unsigned int)b)/2 & 0xfffffffc);
+#elif X86_64
+ Edge *m=(Edge*)(((unsigned long)a+(undigned long)b)/2 & 0xfffffffc);
+#else
+ Edge *m=a+((b-a)/2);
+#endif
+ Node tt = _g.target(*m);
+ if(tt==t) return *m;
+ else if(tt<t) a=m+1;
+ else b=m;
+ }
+ return INVALID;
+ }
-// ///Find the next edge
+ ///Find the next edge
-// ///\warning This function is unimplemented.
-// Edge operator()(Node s, Node t, Edge prev)
-// {
-// return prev==INVALID?(*this)(s,t):INVALID;
-// }
+ ///\warning This function is unimplemented.
+ Edge operator()(Node s, Node t, Edge prev)
+ {
+ return prev==INVALID?(*this)(s,t):INVALID;
+ }
-// };
+ };
}
More information about the Lemon-commits
mailing list