diff -r d0e8a86a1ff2 -r e00114f165f5 lemon/graph_utils.h --- a/lemon/graph_utils.h Fri Mar 31 12:51:44 2006 +0000 +++ b/lemon/graph_utils.h Mon Apr 03 08:41:52 2006 +0000 @@ -147,6 +147,72 @@ return _graph_utils_bits::CountNodesSelector::count(g); } + namespace _graph_utils_bits { + + template + struct CountANodesSelector { + static int count(const Graph &g) { + return countItems(g); + } + }; + + template + struct CountANodesSelector< + Graph, typename + enable_if::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 + inline int countANodes(const Graph& g) { + return _graph_utils_bits::CountANodesSelector::count(g); + } + + namespace _graph_utils_bits { + + template + struct CountBNodesSelector { + static int count(const Graph &g) { + return countItems(g); + } + }; + + template + struct CountBNodesSelector< + Graph, typename + enable_if::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 + inline int countBNodes(const Graph& g) { + return _graph_utils_bits::CountBNodesSelector::count(g); + } + // Edge counting: