[Lemon-commits] Peter Kovacs: Several fixes and improvements in ...

Lemon HG hg at lemon.cs.elte.hu
Tue Feb 12 22:09:35 CET 2008


details:   http://lemon.cs.elte.hu/hg/lemon/rev/c56b7389dc78
changeset: 73:c56b7389dc78
user:      Peter Kovacs <kpeter [at] inf.elte.hu>
date:      Tue Feb 05 11:24:57 2008 +0100
description:
	Several fixes and improvements in list_graph.h.

	- Fix incorrect or misleading renamings in the code and in the
	documentation.
	- Improve the documentation.

diffstat:

1 file changed, 166 insertions(+), 144 deletions(-)
lemon/list_graph.h |  310 +++++++++++++++++++++++++++-------------------------

diffs (truncated from 659 to 300 lines):

diff -r 1113f6d12c0c -r c56b7389dc78 lemon/list_graph.h
--- a/lemon/list_graph.h	Fri Jan 25 14:52:50 2008 +0000
+++ b/lemon/list_graph.h	Tue Feb 05 11:24:57 2008 +0100
@@ -111,12 +111,12 @@ namespace lemon {
     }
 
 
-    void first(Arc& e) const { 
+    void first(Arc& arc) const { 
       int n;
       for(n = first_node; 
 	  n!=-1 && nodes[n].first_in == -1; 
 	  n = nodes[n].next);
-      e.id = (n == -1) ? -1 : nodes[n].first_in;
+      arc.id = (n == -1) ? -1 : nodes[n].first_in;
     }
 
     void next(Arc& arc) const {
@@ -293,35 +293,37 @@ namespace lemon {
 
   typedef DigraphExtender<ListDigraphBase> ExtendedListDigraphBase;
 
-  /// \addtogroup digraphs
+  /// \addtogroup graphs
   /// @{
 
-  ///A list digraph class.
+  ///A general directed graph structure. 
 
-  ///This is a simple and fast digraph implementation.
+  ///\ref ListDigraph is a simple and fast <em>directed graph</em> 
+  ///implementation based on static linked lists that are stored in 
+  ///\c std::vector structures.   
   ///
   ///It conforms to the \ref concepts::Digraph "Digraph concept" and it
-  ///also provides several additional useful extra functionalities.
-  ///The most of the member functions and nested classes are
-  ///documented only in the concept class.
+  ///also provides several useful additional functionalities.
+  ///Most of the member functions and nested classes are documented
+  ///only in the concept class.
   ///
   ///An important extra feature of this digraph implementation is that
   ///its maps are real \ref concepts::ReferenceMap "reference map"s.
   ///
-  ///\sa concepts::Digraph.
+  ///\sa concepts::Digraph
 
   class ListDigraph : public ExtendedListDigraphBase {
   private:
-    ///ListDigraph is \e not copy constructible. Use DigraphCopy() instead.
+    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
     
-    ///ListDigraph is \e not copy constructible. Use DigraphCopy() instead.
+    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
     ///
     ListDigraph(const ListDigraph &) :ExtendedListDigraphBase() {};
     ///\brief Assignment of ListDigraph to another one is \e not allowed.
-    ///Use DigraphCopy() instead.
+    ///Use copyDigraph() instead.
 
     ///Assignment of ListDigraph to another one is \e not allowed.
-    ///Use DigraphCopy() instead.
+    ///Use copyDigraph() instead.
     void operator=(const ListDigraph &) {}
   public:
 
@@ -335,8 +337,8 @@ namespace lemon {
 
     ///Add a new node to the digraph.
     
-    /// \return the new node.
-    ///
+    ///Add a new node to the digraph.
+    ///\return the new node.
     Node addNode() { return Parent::addNode(); }
 
     ///Add a new arc to the digraph.
@@ -348,25 +350,27 @@ namespace lemon {
       return Parent::addArc(s, t); 
     }
 
-    /// Changes the target of \c e to \c n
+    /// Change the target of \c e to \c n
 
-    /// Changes the target of \c e to \c n
+    /// Change the target of \c e to \c n
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s referencing
     ///the changed arc remain valid. However <tt>InArcIt</tt>s are
     ///invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
     void changeTarget(Arc e, Node n) { 
       Parent::changeTarget(e,n); 
     }
-    /// Changes the source of \c e to \c n
+    /// Change the source of \c e to \c n
 
-    /// Changes the source of \c e to \c n
+    /// Change the source of \c e to \c n
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s referencing
     ///the changed arc remain valid. However <tt>OutArcIt</tt>s are
     ///invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
     void changeSource(Arc e, Node n) { 
@@ -378,6 +382,7 @@ namespace lemon {
     ///\note The <tt>ArcIt</tt>s referencing the changed arc remain
     ///valid. However <tt>OutArcIt</tt>s and <tt>InArcIt</tt>s are
     ///invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
     void reverseArc(Arc e) {
@@ -386,7 +391,9 @@ namespace lemon {
       changeSource(e,t);
     }
 
-    /// Using this it is possible to avoid the superfluous memory
+    /// Reserve memory for nodes.
+
+    /// Using this function it is possible to avoid the superfluous memory
     /// allocation: if you know that the digraph you want to build will
     /// be very large (e.g. it will contain millions of nodes and/or arcs)
     /// then it is worth reserving space for this amount before starting
@@ -394,10 +401,9 @@ namespace lemon {
     /// \sa reserveArc
     void reserveNode(int n) { nodes.reserve(n); };
 
-    /// \brief Using this it is possible to avoid the superfluous memory
-    /// allocation.
+    /// Reserve memory for arcs.
 
-    /// Using this it is possible to avoid the superfluous memory
+    /// Using this function it is possible to avoid the superfluous memory
     /// allocation: if you know that the digraph you want to build will
     /// be very large (e.g. it will contain millions of nodes and/or arcs)
     /// then it is worth reserving space for this amount before starting
@@ -408,16 +414,15 @@ namespace lemon {
     ///Contract two nodes.
 
     ///This function contracts two nodes.
-    ///
     ///Node \p b will be removed but instead of deleting
     ///incident arcs, they will be joined to \p a.
     ///The last parameter \p r controls whether to remove loops. \c true
     ///means that loops will be removed.
     ///
-    ///\note The <tt>ArcIt</tt>s
-    ///referencing a moved arc remain
+    ///\note The <tt>ArcIt</tt>s referencing a moved arc remain
     ///valid. However <tt>InArcIt</tt>s and <tt>OutArcIt</tt>s
     ///may be invalidated.
+    ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
     void contract(Node a, Node b, bool r = true) 
@@ -452,8 +457,9 @@ namespace lemon {
     ///be invalidated.  
     ///
     ///\warning This functionality cannot be used together with the
-    ///Snapshot feature.  \todo It could be implemented in a bit
-    ///faster way.
+    ///Snapshot feature.
+    ///
+    ///\todo It could be implemented in a bit faster way.
     Node split(Node n, bool connect = true) {
       Node b = addNode();
       for(OutArcIt e(*this,n);e!=INVALID;) {
@@ -471,9 +477,11 @@ namespace lemon {
     ///This function splits an arc. First a new node \c b is added to
     ///the digraph, then the original arc is re-targeted to \c
     ///b. Finally an arc from \c b to the original target is added.
-    ///\return The newly created node.  
-    ///\warning This functionality
-    ///cannot be used together with the Snapshot feature.
+    ///
+    ///\return The newly created node.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
     Node split(Arc e) {
       Node b = addNode();
       addArc(b,target(e));
@@ -482,16 +490,16 @@ namespace lemon {
     }
       
     /// \brief Class to make a snapshot of the digraph and restore
-    /// to it later.
+    /// it later.
     ///
-    /// Class to make a snapshot of the digraph and to restore it
-    /// later.
+    /// Class to make a snapshot of the digraph and restore it later.
     ///
     /// The newly added nodes and arcs can be removed using the
     /// restore() function.
     ///
-    /// \warning Arc and node deletions cannot be restored. This
-    /// events invalidate the snapshot. 
+    /// \warning Arc and node deletions and other modifications (e.g.
+    /// contracting, splitting, reversing arcs or nodes) cannot be 
+    /// restored. These events invalidate the snapshot. 
     class Snapshot {
     protected:
 
@@ -776,9 +784,9 @@ namespace lemon {
     public:
       Edge() {}
       Edge (Invalid) { id = -1; }
-      bool operator==(const Edge& arc) const {return id == arc.id;}
-      bool operator!=(const Edge& arc) const {return id != arc.id;}
-      bool operator<(const Edge& arc) const {return id < arc.id;}
+      bool operator==(const Edge& edge) const {return id == edge.id;}
+      bool operator!=(const Edge& edge) const {return id != edge.id;}
+      bool operator<(const Edge& edge) const {return id < edge.id;}
     };
 
     class Arc {
@@ -909,20 +917,20 @@ namespace lemon {
     }
 
     void firstInc(Edge &e, bool& d, const Node& v) const {
-      int de = nodes[v.id].first_out;
-      if (de != -1 ) {
-        e.id = de / 2;
-        d = ((de & 1) == 1);
+      int a = nodes[v.id].first_out;
+      if (a != -1 ) {
+        e.id = a / 2;
+        d = ((a & 1) == 1);
       } else {
         e.id = -1;
         d = true;
       }
     }
     void nextInc(Edge &e, bool& d) const {
-      int de = (arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
-      if (de != -1 ) {
-        e.id = de / 2;
-        d = ((de & 1) == 1);
+      int a = (arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
+      if (a != -1 ) {
+        e.id = a / 2;
+        d = ((a & 1) == 1);
       } else {
         e.id = -1;
         d = true;
@@ -1008,8 +1016,8 @@ namespace lemon {
 
     }
     
-    void erase(const Edge& arc) {
-      int n = arc.id * 2;
+    void erase(const Edge& edge) {
+      int n = edge.id * 2;
       
       if (arcs[n].next_out != -1) {
 	arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
@@ -1089,40 +1097,40 @@ namespace lemon {
 
   };
 
-//   typedef GraphExtender<UndirDigraphExtender<ListDigraphBase> > 
-//   ExtendedListGraphBase;
-
   typedef GraphExtender<ListGraphBase> ExtendedListGraphBase;
 
 
-
-  /// \addtogroup digraphs
+  /// \addtogroup graphs
   /// @{
 
-  ///An undirected list digraph class.
+  ///A general undirected graph structure.
 
-  ///This is a simple and fast undirected digraph implementation.
+  ///\ref ListGraph is a simple and fast <em>undirected graph</em> 
+  ///implementation based on static linked lists that are stored in 
+  ///\c std::vector structures. 
   ///
-  ///An important extra feature of this digraph implementation is that
+  ///It conforms to the \ref concepts::Graph "Graph concept" and it
+  ///also provides several useful additional functionalities.
+  ///Most of the member functions and nested classes are documented
+  ///only in the concept class.
+  ///
+  ///An important extra feature of this graph implementation is that
   ///its maps are real \ref concepts::ReferenceMap "reference map"s.
   ///
-  ///It conforms to the
-  ///\ref concepts::Graph "Graph concept".
-  ///
-  ///\sa concepts::Graph.
-  ///



More information about the Lemon-commits mailing list