[Lemon-commits] [lemon_svn] deba: r2668 - hugo/trunk/lemon
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:54:20 CET 2006
Author: deba
Date: Mon Apr 3 10:41:52 2006
New Revision: 2668
Modified:
hugo/trunk/lemon/graph_utils.h
Log:
Count ANodes-BNodes
Modified: hugo/trunk/lemon/graph_utils.h
==============================================================================
--- hugo/trunk/lemon/graph_utils.h (original)
+++ hugo/trunk/lemon/graph_utils.h Mon Apr 3 10:41:52 2006
@@ -147,6 +147,72 @@
return _graph_utils_bits::CountNodesSelector<Graph>::count(g);
}
+ namespace _graph_utils_bits {
+
+ template <typename Graph, typename Enable = void>
+ struct CountANodesSelector {
+ static int count(const Graph &g) {
+ return countItems<Graph, typename Graph::ANode>(g);
+ }
+ };
+
+ template <typename Graph>
+ struct CountANodesSelector<
+ Graph, typename
+ enable_if<typename Graph::NodeNumTag, void>::type>
+ {
+ static int count(const Graph &g) {
+ return g.nodeNum();
+ }
+ };
+ }
+
+ /// \brief Function to count the anodes in the graph.
+ ///
+ /// This function counts the anodes in the graph.
+ /// The complexity of the function is O(an) but for some
+ /// graph structures it is specialized to run in O(1).
+ ///
+ /// \todo refer how to specialize it
+
+ template <typename Graph>
+ inline int countANodes(const Graph& g) {
+ return _graph_utils_bits::CountANodesSelector<Graph>::count(g);
+ }
+
+ namespace _graph_utils_bits {
+
+ template <typename Graph, typename Enable = void>
+ struct CountBNodesSelector {
+ static int count(const Graph &g) {
+ return countItems<Graph, typename Graph::BNode>(g);
+ }
+ };
+
+ template <typename Graph>
+ struct CountBNodesSelector<
+ Graph, typename
+ enable_if<typename Graph::NodeNumTag, void>::type>
+ {
+ static int count(const Graph &g) {
+ return g.nodeNum();
+ }
+ };
+ }
+
+ /// \brief Function to count the bnodes in the graph.
+ ///
+ /// This function counts the bnodes in the graph.
+ /// The complexity of the function is O(bn) but for some
+ /// graph structures it is specialized to run in O(1).
+ ///
+ /// \todo refer how to specialize it
+
+ template <typename Graph>
+ inline int countBNodes(const Graph& g) {
+ return _graph_utils_bits::CountBNodesSelector<Graph>::count(g);
+ }
+
// Edge counting:
More information about the Lemon-commits
mailing list