[Lemon-commits] [lemon_svn] alpar: r1328 - hugo/trunk/src/lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:44:38 CET 2006


Author: alpar
Date: Sat Oct 30 18:30:12 2004
New Revision: 1328

Modified:
   hugo/trunk/src/lemon/list_graph.h

Log:
- moveHead() and moveTail() added. Not tested.

Modified: hugo/trunk/src/lemon/list_graph.h
==============================================================================
--- hugo/trunk/src/lemon/list_graph.h	(original)
+++ hugo/trunk/src/lemon/list_graph.h	Sat Oct 30 18:30:12 2004
@@ -1,8 +1,26 @@
-// -*- c++ -*-
+/* -*- C++ -*-
+ * src/lemon/list_graph.h - Part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Combinatorial Optimization Research Group, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
 
 #ifndef LEMON_LIST_GRAPH_H
 #define LEMON_LIST_GRAPH_H
 
+///\ingroup graphs
+///\file
+///\brief ListGraph, SymListGraph, NodeSet and EdgeSet classes.
+
 #include <lemon/erasable_graph_extender.h>
 #include <lemon/clearable_graph_extender.h>
 #include <lemon/extendable_graph_extender.h>
@@ -82,7 +100,9 @@
 	first_free_node(-1), edges(), first_free_edge(-1) {}
 
     
-    ///it possible to avoid the superfluous memory allocation.
+    ///Using this it possible to avoid the superfluous memory allocation.
+    ///\todo more docs...
+    ///\todo It should be defined in ListGraph.
     void reserveEdge(int n) { edges.reserve(n); };
     
     /// Maximum node ID.
@@ -267,11 +287,55 @@
   typedef ClearableGraphExtender<ExtendableListGraphBase> ClearableListGraphBase;
   typedef ErasableGraphExtender<ClearableListGraphBase> ErasableListGraphBase;
 
-  typedef ErasableListGraphBase ListGraph;
+/// \addtogroup graphs
+/// @{
+
+  ///A list graph class.
 
-}
+  ///This is a simple and fast erasable graph implementation.
+  ///
+  ///It conforms to the
+  ///\ref skeleton::ErasableGraph "ErasableGraph" concept.
+  ///\sa skeleton::ErasableGraph.
 
+  class ListGraph : public ErasableListGraphBase 
+  {
+  public:
+    /// Moves the head of \c e to \c n
 
+    /// Moves the head of \c e to \c n
+    ///
+    void moveHead(Edge e, Node n) 
+    {
+      if(edges[e.n].next_in != -1)
+	edges[edges[e.n].next_in].prev_in = edges[e.n].prev_in;
+      if(edges[e.n].prev_in != -1)
+	edges[edges[e.n].prev_in].next_in = edges[e.n].next_in;
+      else nodes[edges[e.n].head].first_in = edges[e.n].next_in;
+      edges[e.n].head = n.n;
+      edges[e.n].prev_in = -1;
+      edges[e.n].next_in = nodes[n.n].first_in;
+      nodes[n.n].first_in = e.n;
+    }
+    /// Moves the tail of \c e to \c n
+
+    /// Moves the tail of \c e to \c n
+    ///
+    void moveTail(Edge e, Node n) 
+    {
+      if(edges[e.n].next_out != -1)
+	edges[edges[e.n].next_out].prev_out = edges[e.n].prev_out;
+      if(edges[e.n].prev_out != -1)
+	edges[edges[e.n].prev_out].next_out = edges[e.n].next_out;
+      else nodes[edges[e.n].tail].first_out = edges[e.n].next_out;
+      edges[e.n].tail = n.n;
+      edges[e.n].prev_out = -1;
+      edges[e.n].next_out = nodes[n.n].first_out;
+      nodes[n.n].first_out = e.n;
+    }
+  }
+  /// @}  
+} //namespace lemon
   
 
 #endif



More information about the Lemon-commits mailing list