Changeset 977:48962802d168 in lemon0.x for src/lemon/graph_utils.h
 Timestamp:
 11/10/04 21:14:32 (19 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1365
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/graph_utils.h
r967 r977 21 21 22 22 #include <lemon/invalid.h> 23 #include <lemon/utility.h> 23 24 24 25 ///\ingroup gutils … … 36 37 /// @{ 37 38 38 // counters in the graph39 39 /// \brief Function to count the items in the graph. 40 40 /// … … 44 44 45 45 template <typename Graph, typename ItemIt> 46 inline int countItems(const Graph& _g) {46 inline int countItems(const Graph& g) { 47 47 int num = 0; 48 for (ItemIt it( _g); it != INVALID; ++it) {48 for (ItemIt it(g); it != INVALID; ++it) { 49 49 ++num; 50 50 } 51 51 return num; 52 } 53 54 // Node counting: 55 56 template <typename Graph> 57 inline 58 typename enable_if<typename Graph::NodeNumTag, int>::type 59 _countNodes(const Graph &g) { 60 return g.nodeNum(); 61 } 62 63 template <typename Graph> 64 inline int _countNodes(Wrap<Graph> w) { 65 return countItems<Graph, typename Graph::NodeIt>(w.value); 52 66 } 53 67 … … 57 71 /// The complexity of the function is O(n) but for some 58 72 /// graph structure it is specialized to run in O(1). 59 60 template <typename Graph> 61 inline int countNodes(const Graph& _g) { 62 return countItems<Graph, typename Graph::NodeIt>(_g); 73 /// 74 /// \todo refer how to specialize it 75 76 template <typename Graph> 77 inline int countNodes(const Graph& g) { 78 return _countNodes<Graph>(g); 79 } 80 81 // Edge counting: 82 83 template <typename Graph> 84 inline 85 typename enable_if<typename Graph::EdgeNumTag, int>::type 86 _countEdges(const Graph &g) { 87 return g.edgeNum(); 88 } 89 90 template <typename Graph> 91 inline int _countEdges(Wrap<Graph> w) { 92 return countItems<Graph, typename Graph::EdgeIt>(w.value); 63 93 } 64 94 … … 68 98 /// The complexity of the function is O(e) but for some 69 99 /// graph structure it is specialized to run in O(1). 70 template <typename Graph> 71 inline int countEdges(const Graph& _g) { 72 return countItems<Graph, typename Graph::EdgeIt>(_g); 100 101 template <typename Graph> 102 inline int countEdges(const Graph& g) { 103 return _countEdges<Graph>(g); 73 104 } 74 105 … … 82 113 return countItems<Graph, typename Graph::SymEdgeIt>(_g); 83 114 } 115 84 116 85 117 template <typename Graph, typename DegIt>
Note: See TracChangeset
for help on using the changeset viewer.