50 |
53 |
51 /// \brief Function to count the nodes in the graph. |
54 /// \brief Function to count the nodes in the graph. |
52 /// |
55 /// |
53 /// This function counts the nodes in the graph. |
56 /// This function counts the nodes in the graph. |
54 /// The complexity of the function is O(n) but for some |
57 /// The complexity of the function is O(n) but for some |
55 /// graph structure it is specialized to O(1). |
58 /// graph structure it is specialized to run in O(1). |
56 |
59 |
57 template <typename Graph> |
60 template <typename Graph> |
58 inline int countNodes(const Graph& _g) { |
61 inline int countNodes(const Graph& _g) { |
59 return countItems<Graph, typename Graph::NodeIt>(_g); |
62 return countItems<Graph, typename Graph::NodeIt>(_g); |
60 } |
63 } |
61 |
64 |
62 /// \brief Function to count the edges in the graph. |
65 /// \brief Function to count the edges in the graph. |
63 /// |
66 /// |
64 /// This function counts the edges in the graph. |
67 /// This function counts the edges in the graph. |
65 /// The complexity of the function is O(e) but for some |
68 /// The complexity of the function is O(e) but for some |
66 /// graph structure it is specialized to O(1). |
69 /// graph structure it is specialized to run in O(1). |
67 template <typename Graph> |
70 template <typename Graph> |
68 inline int countEdges(const Graph& _g) { |
71 inline int countEdges(const Graph& _g) { |
69 return countItems<Graph, typename Graph::EdgeIt>(_g); |
72 return countItems<Graph, typename Graph::EdgeIt>(_g); |
70 } |
73 } |
71 |
74 |
72 /// \brief Function to count the symmetric edges in the graph. |
75 /// \brief Function to count the symmetric edges in the graph. |
73 /// |
76 /// |
74 /// This function counts the symmetric edges in the graph. |
77 /// This function counts the symmetric edges in the graph. |
75 /// The complexity of the function is O(e) but for some |
78 /// The complexity of the function is O(e) but for some |
76 /// graph structure it is specialized to O(1). |
79 /// graph structure it is specialized to run in O(1). |
77 template <typename Graph> |
80 template <typename Graph> |
78 inline int countSymEdges(const Graph& _g) { |
81 inline int countSymEdges(const Graph& _g) { |
79 return countItems<Graph, typename Graph::SymEdgeIt>(_g); |
82 return countItems<Graph, typename Graph::SymEdgeIt>(_g); |
80 } |
83 } |
81 |
84 |
85 for (DegIt it(_g, _n); it != INVALID; ++it) { |
88 for (DegIt it(_g, _n); it != INVALID; ++it) { |
86 ++num; |
89 ++num; |
87 } |
90 } |
88 return num; |
91 return num; |
89 } |
92 } |
|
93 |
|
94 ///\e |
90 |
95 |
|
96 ///\todo Please document. |
|
97 /// |
91 template <typename Graph> |
98 template <typename Graph> |
92 inline int countOutEdges(const Graph& _g, const typename Graph::Node& _n) { |
99 inline int countOutEdges(const Graph& _g, const typename Graph::Node& _n) { |
93 return countNodeDegree<Graph, typename Graph::OutEdgeIt>(_g, _n); |
100 return countNodeDegree<Graph, typename Graph::OutEdgeIt>(_g, _n); |
94 } |
101 } |
95 |
102 |
|
103 ///\e |
|
104 |
|
105 ///\todo Please document. |
|
106 /// |
96 template <typename Graph> |
107 template <typename Graph> |
97 inline int countInEdges(const Graph& _g, const typename Graph::Node& _n) { |
108 inline int countInEdges(const Graph& _g, const typename Graph::Node& _n) { |
98 return countNodeDegree<Graph, typename Graph::InEdgeIt>(_g, _n); |
109 return countNodeDegree<Graph, typename Graph::InEdgeIt>(_g, _n); |
99 } |
110 } |
100 |
111 |