Changeset 2029:e00114f165f5 in lemon-0.x for lemon/graph_utils.h
- Timestamp:
- 04/03/06 10:41:52 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2668
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/graph_utils.h
r2022 r2029 146 146 inline int countNodes(const Graph& g) { 147 147 return _graph_utils_bits::CountNodesSelector<Graph>::count(g); 148 } 149 150 namespace _graph_utils_bits { 151 152 template <typename Graph, typename Enable = void> 153 struct CountANodesSelector { 154 static int count(const Graph &g) { 155 return countItems<Graph, typename Graph::ANode>(g); 156 } 157 }; 158 159 template <typename Graph> 160 struct CountANodesSelector< 161 Graph, typename 162 enable_if<typename Graph::NodeNumTag, void>::type> 163 { 164 static int count(const Graph &g) { 165 return g.nodeNum(); 166 } 167 }; 168 } 169 170 /// \brief Function to count the anodes in the graph. 171 /// 172 /// This function counts the anodes in the graph. 173 /// The complexity of the function is O(an) but for some 174 /// graph structures it is specialized to run in O(1). 175 /// 176 /// \todo refer how to specialize it 177 178 template <typename Graph> 179 inline int countANodes(const Graph& g) { 180 return _graph_utils_bits::CountANodesSelector<Graph>::count(g); 181 } 182 183 namespace _graph_utils_bits { 184 185 template <typename Graph, typename Enable = void> 186 struct CountBNodesSelector { 187 static int count(const Graph &g) { 188 return countItems<Graph, typename Graph::BNode>(g); 189 } 190 }; 191 192 template <typename Graph> 193 struct CountBNodesSelector< 194 Graph, typename 195 enable_if<typename Graph::NodeNumTag, void>::type> 196 { 197 static int count(const Graph &g) { 198 return g.nodeNum(); 199 } 200 }; 201 } 202 203 /// \brief Function to count the bnodes in the graph. 204 /// 205 /// This function counts the bnodes in the graph. 206 /// The complexity of the function is O(bn) but for some 207 /// graph structures it is specialized to run in O(1). 208 /// 209 /// \todo refer how to specialize it 210 211 template <typename Graph> 212 inline int countBNodes(const Graph& g) { 213 return _graph_utils_bits::CountBNodesSelector<Graph>::count(g); 148 214 } 149 215
Note: See TracChangeset
for help on using the changeset viewer.