1.1 --- a/lemon/full_graph.h Fri Aug 09 11:07:27 2013 +0200
1.2 +++ b/lemon/full_graph.h Sun Aug 11 15:28:12 2013 +0200
1.3 @@ -2,7 +2,7 @@
1.4 *
1.5 * This file is a part of LEMON, a generic C++ optimization library.
1.6 *
1.7 - * Copyright (C) 2003-2009
1.8 + * Copyright (C) 2003-2010
1.9 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 *
1.12 @@ -24,7 +24,7 @@
1.13
1.14 ///\ingroup graphs
1.15 ///\file
1.16 -///\brief FullGraph and FullDigraph classes.
1.17 +///\brief FullDigraph and FullGraph classes.
1.18
1.19 namespace lemon {
1.20
1.21 @@ -51,7 +51,7 @@
1.22 typedef True ArcNumTag;
1.23
1.24 Node operator()(int ix) const { return Node(ix); }
1.25 - int index(const Node& node) const { return node._id; }
1.26 + static int index(const Node& node) { return node._id; }
1.27
1.28 Arc arc(const Node& s, const Node& t) const {
1.29 return Arc(s._id * _node_num + t._id);
1.30 @@ -148,24 +148,28 @@
1.31
1.32 /// \ingroup graphs
1.33 ///
1.34 - /// \brief A full digraph class.
1.35 + /// \brief A directed full graph class.
1.36 ///
1.37 - /// This is a simple and fast directed full graph implementation.
1.38 - /// From each node go arcs to each node (including the source node),
1.39 - /// therefore the number of the arcs in the digraph is the square of
1.40 - /// the node number. This digraph type is completely static, so you
1.41 - /// can neither add nor delete either arcs or nodes, and it needs
1.42 - /// constant space in memory.
1.43 + /// FullDigraph is a simple and fast implmenetation of directed full
1.44 + /// (complete) graphs. It contains an arc from each node to each node
1.45 + /// (including a loop for each node), therefore the number of arcs
1.46 + /// is the square of the number of nodes.
1.47 + /// This class is completely static and it needs constant memory space.
1.48 + /// Thus you can neither add nor delete nodes or arcs, however
1.49 + /// the structure can be resized using resize().
1.50 ///
1.51 - /// This class fully conforms to the \ref concepts::Digraph
1.52 - /// "Digraph concept".
1.53 + /// This type fully conforms to the \ref concepts::Digraph "Digraph concept".
1.54 + /// Most of its member functions and nested classes are documented
1.55 + /// only in the concept class.
1.56 ///
1.57 - /// The \c FullDigraph and \c FullGraph classes are very similar,
1.58 + /// This class provides constant time counting for nodes and arcs.
1.59 + ///
1.60 + /// \note FullDigraph and FullGraph classes are very similar,
1.61 /// but there are two differences. While this class conforms only
1.62 - /// to the \ref concepts::Digraph "Digraph" concept, the \c FullGraph
1.63 - /// class conforms to the \ref concepts::Graph "Graph" concept,
1.64 - /// moreover \c FullGraph does not contain a loop arc for each
1.65 - /// node as \c FullDigraph does.
1.66 + /// to the \ref concepts::Digraph "Digraph" concept, FullGraph
1.67 + /// conforms to the \ref concepts::Graph "Graph" concept,
1.68 + /// moreover FullGraph does not contain a loop for each
1.69 + /// node as this class does.
1.70 ///
1.71 /// \sa FullGraph
1.72 class FullDigraph : public ExtendedFullDigraphBase {
1.73 @@ -173,7 +177,9 @@
1.74
1.75 public:
1.76
1.77 - /// \brief Constructor
1.78 + /// \brief Default constructor.
1.79 + ///
1.80 + /// Default constructor. The number of nodes and arcs will be zero.
1.81 FullDigraph() { construct(0); }
1.82
1.83 /// \brief Constructor
1.84 @@ -184,8 +190,8 @@
1.85
1.86 /// \brief Resizes the digraph
1.87 ///
1.88 - /// Resizes the digraph. The function will fully destroy and
1.89 - /// rebuild the digraph. This cause that the maps of the digraph will
1.90 + /// This function resizes the digraph. It fully destroys and
1.91 + /// rebuilds the structure, therefore the maps of the digraph will be
1.92 /// reallocated automatically and the previous values will be lost.
1.93 void resize(int n) {
1.94 Parent::notifier(Arc()).clear();
1.95 @@ -197,24 +203,26 @@
1.96
1.97 /// \brief Returns the node with the given index.
1.98 ///
1.99 - /// Returns the node with the given index. Since it is a static
1.100 - /// digraph its nodes can be indexed with integers from the range
1.101 - /// <tt>[0..nodeNum()-1]</tt>.
1.102 + /// Returns the node with the given index. Since this structure is
1.103 + /// completely static, the nodes can be indexed with integers from
1.104 + /// the range <tt>[0..nodeNum()-1]</tt>.
1.105 + /// The index of a node is the same as its ID.
1.106 /// \sa index()
1.107 Node operator()(int ix) const { return Parent::operator()(ix); }
1.108
1.109 /// \brief Returns the index of the given node.
1.110 ///
1.111 - /// Returns the index of the given node. Since it is a static
1.112 - /// digraph its nodes can be indexed with integers from the range
1.113 - /// <tt>[0..nodeNum()-1]</tt>.
1.114 - /// \sa operator()
1.115 - int index(const Node& node) const { return Parent::index(node); }
1.116 + /// Returns the index of the given node. Since this structure is
1.117 + /// completely static, the nodes can be indexed with integers from
1.118 + /// the range <tt>[0..nodeNum()-1]</tt>.
1.119 + /// The index of a node is the same as its ID.
1.120 + /// \sa operator()()
1.121 + static int index(const Node& node) { return Parent::index(node); }
1.122
1.123 /// \brief Returns the arc connecting the given nodes.
1.124 ///
1.125 /// Returns the arc connecting the given nodes.
1.126 - Arc arc(const Node& u, const Node& v) const {
1.127 + Arc arc(Node u, Node v) const {
1.128 return Parent::arc(u, v);
1.129 }
1.130
1.131 @@ -283,7 +291,7 @@
1.132 public:
1.133
1.134 Node operator()(int ix) const { return Node(ix); }
1.135 - int index(const Node& node) const { return node._id; }
1.136 + static int index(const Node& node) { return node._id; }
1.137
1.138 Edge edge(const Node& u, const Node& v) const {
1.139 if (u._id < v._id) {
1.140 @@ -520,21 +528,25 @@
1.141 ///
1.142 /// \brief An undirected full graph class.
1.143 ///
1.144 - /// This is a simple and fast undirected full graph
1.145 - /// implementation. From each node go edge to each other node,
1.146 - /// therefore the number of edges in the graph is \f$n(n-1)/2\f$.
1.147 - /// This graph type is completely static, so you can neither
1.148 - /// add nor delete either edges or nodes, and it needs constant
1.149 - /// space in memory.
1.150 + /// FullGraph is a simple and fast implmenetation of undirected full
1.151 + /// (complete) graphs. It contains an edge between every distinct pair
1.152 + /// of nodes, therefore the number of edges is <tt>n(n-1)/2</tt>.
1.153 + /// This class is completely static and it needs constant memory space.
1.154 + /// Thus you can neither add nor delete nodes or edges, however
1.155 + /// the structure can be resized using resize().
1.156 ///
1.157 - /// This class fully conforms to the \ref concepts::Graph "Graph concept".
1.158 + /// This type fully conforms to the \ref concepts::Graph "Graph concept".
1.159 + /// Most of its member functions and nested classes are documented
1.160 + /// only in the concept class.
1.161 ///
1.162 - /// The \c FullGraph and \c FullDigraph classes are very similar,
1.163 - /// but there are two differences. While the \c FullDigraph class
1.164 + /// This class provides constant time counting for nodes, edges and arcs.
1.165 + ///
1.166 + /// \note FullDigraph and FullGraph classes are very similar,
1.167 + /// but there are two differences. While FullDigraph
1.168 /// conforms only to the \ref concepts::Digraph "Digraph" concept,
1.169 /// this class conforms to the \ref concepts::Graph "Graph" concept,
1.170 - /// moreover \c FullGraph does not contain a loop arc for each
1.171 - /// node as \c FullDigraph does.
1.172 + /// moreover this class does not contain a loop for each
1.173 + /// node as FullDigraph does.
1.174 ///
1.175 /// \sa FullDigraph
1.176 class FullGraph : public ExtendedFullGraphBase {
1.177 @@ -542,7 +554,9 @@
1.178
1.179 public:
1.180
1.181 - /// \brief Constructor
1.182 + /// \brief Default constructor.
1.183 + ///
1.184 + /// Default constructor. The number of nodes and edges will be zero.
1.185 FullGraph() { construct(0); }
1.186
1.187 /// \brief Constructor
1.188 @@ -553,8 +567,8 @@
1.189
1.190 /// \brief Resizes the graph
1.191 ///
1.192 - /// Resizes the graph. The function will fully destroy and
1.193 - /// rebuild the graph. This cause that the maps of the graph will
1.194 + /// This function resizes the graph. It fully destroys and
1.195 + /// rebuilds the structure, therefore the maps of the graph will be
1.196 /// reallocated automatically and the previous values will be lost.
1.197 void resize(int n) {
1.198 Parent::notifier(Arc()).clear();
1.199 @@ -568,31 +582,33 @@
1.200
1.201 /// \brief Returns the node with the given index.
1.202 ///
1.203 - /// Returns the node with the given index. Since it is a static
1.204 - /// graph its nodes can be indexed with integers from the range
1.205 - /// <tt>[0..nodeNum()-1]</tt>.
1.206 + /// Returns the node with the given index. Since this structure is
1.207 + /// completely static, the nodes can be indexed with integers from
1.208 + /// the range <tt>[0..nodeNum()-1]</tt>.
1.209 + /// The index of a node is the same as its ID.
1.210 /// \sa index()
1.211 Node operator()(int ix) const { return Parent::operator()(ix); }
1.212
1.213 /// \brief Returns the index of the given node.
1.214 ///
1.215 - /// Returns the index of the given node. Since it is a static
1.216 - /// graph its nodes can be indexed with integers from the range
1.217 - /// <tt>[0..nodeNum()-1]</tt>.
1.218 - /// \sa operator()
1.219 - int index(const Node& node) const { return Parent::index(node); }
1.220 + /// Returns the index of the given node. Since this structure is
1.221 + /// completely static, the nodes can be indexed with integers from
1.222 + /// the range <tt>[0..nodeNum()-1]</tt>.
1.223 + /// The index of a node is the same as its ID.
1.224 + /// \sa operator()()
1.225 + static int index(const Node& node) { return Parent::index(node); }
1.226
1.227 /// \brief Returns the arc connecting the given nodes.
1.228 ///
1.229 /// Returns the arc connecting the given nodes.
1.230 - Arc arc(const Node& s, const Node& t) const {
1.231 + Arc arc(Node s, Node t) const {
1.232 return Parent::arc(s, t);
1.233 }
1.234
1.235 - /// \brief Returns the edge connects the given nodes.
1.236 + /// \brief Returns the edge connecting the given nodes.
1.237 ///
1.238 - /// Returns the edge connects the given nodes.
1.239 - Edge edge(const Node& u, const Node& v) const {
1.240 + /// Returns the edge connecting the given nodes.
1.241 + Edge edge(Node u, Node v) const {
1.242 return Parent::edge(u, v);
1.243 }
1.244