ListGraph compilation bug fixed.
authoralpar
Sat, 30 Oct 2004 18:30:29 +0000
changeset 949b16a10926781
parent 948 bc86b64f958e
child 950 d74557d1f100
ListGraph compilation bug fixed.
src/lemon/list_graph.h
     1.1 --- a/src/lemon/list_graph.h	Sat Oct 30 16:30:12 2004 +0000
     1.2 +++ b/src/lemon/list_graph.h	Sat Oct 30 18:30:29 2004 +0000
     1.3 @@ -38,6 +38,7 @@
     1.4  
     1.5    class ListGraphBase {
     1.6  
     1.7 +  protected:
     1.8      struct NodeT {
     1.9        int first_in,first_out;
    1.10        int prev, next;
    1.11 @@ -100,11 +101,6 @@
    1.12  	first_free_node(-1), edges(), first_free_edge(-1) {}
    1.13  
    1.14      
    1.15 -    ///Using this it possible to avoid the superfluous memory allocation.
    1.16 -    ///\todo more docs...
    1.17 -    ///\todo It should be defined in ListGraph.
    1.18 -    void reserveEdge(int n) { edges.reserve(n); };
    1.19 -    
    1.20      /// Maximum node ID.
    1.21      
    1.22      /// Maximum node ID.
    1.23 @@ -277,6 +273,32 @@
    1.24        first_node = first_free_node = first_free_edge = -1;
    1.25      }
    1.26  
    1.27 +  protected:
    1.28 +    void _moveHead(Edge e, Node n) 
    1.29 +    {
    1.30 +      if(edges[e.id].next_in != -1)
    1.31 +	edges[edges[e.id].next_in].prev_in = edges[e.id].prev_in;
    1.32 +      if(edges[e.id].prev_in != -1)
    1.33 +	edges[edges[e.id].prev_in].next_in = edges[e.id].next_in;
    1.34 +      else nodes[edges[e.id].head].first_in = edges[e.id].next_in;
    1.35 +      edges[e.id].head = n.id;
    1.36 +      edges[e.id].prev_in = -1;
    1.37 +      edges[e.id].next_in = nodes[n.id].first_in;
    1.38 +      nodes[n.id].first_in = e.id;
    1.39 +    }
    1.40 +    void _moveTail(Edge e, Node n) 
    1.41 +    {
    1.42 +      if(edges[e.id].next_out != -1)
    1.43 +	edges[edges[e.id].next_out].prev_out = edges[e.id].prev_out;
    1.44 +      if(edges[e.id].prev_out != -1)
    1.45 +	edges[edges[e.id].prev_out].next_out = edges[e.id].next_out;
    1.46 +      else nodes[edges[e.id].tail].first_out = edges[e.id].next_out;
    1.47 +      edges[e.id].tail = n.id;
    1.48 +      edges[e.id].prev_out = -1;
    1.49 +      edges[e.id].next_out = nodes[n.id].first_out;
    1.50 +      nodes[n.id].first_out = e.id;
    1.51 +    }
    1.52 +
    1.53    };
    1.54  
    1.55    typedef AlterableGraphExtender<ListGraphBase> AlterableListGraphBase;
    1.56 @@ -305,35 +327,19 @@
    1.57  
    1.58      /// Moves the head of \c e to \c n
    1.59      ///
    1.60 -    void moveHead(Edge e, Node n) 
    1.61 -    {
    1.62 -      if(edges[e.n].next_in != -1)
    1.63 -	edges[edges[e.n].next_in].prev_in = edges[e.n].prev_in;
    1.64 -      if(edges[e.n].prev_in != -1)
    1.65 -	edges[edges[e.n].prev_in].next_in = edges[e.n].next_in;
    1.66 -      else nodes[edges[e.n].head].first_in = edges[e.n].next_in;
    1.67 -      edges[e.n].head = n.n;
    1.68 -      edges[e.n].prev_in = -1;
    1.69 -      edges[e.n].next_in = nodes[n.n].first_in;
    1.70 -      nodes[n.n].first_in = e.n;
    1.71 -    }
    1.72 +    void moveHead(Edge e, Node n) { _moveHead(e,n); }
    1.73      /// Moves the tail of \c e to \c n
    1.74  
    1.75      /// Moves the tail of \c e to \c n
    1.76      ///
    1.77 -    void moveTail(Edge e, Node n) 
    1.78 -    {
    1.79 -      if(edges[e.n].next_out != -1)
    1.80 -	edges[edges[e.n].next_out].prev_out = edges[e.n].prev_out;
    1.81 -      if(edges[e.n].prev_out != -1)
    1.82 -	edges[edges[e.n].prev_out].next_out = edges[e.n].next_out;
    1.83 -      else nodes[edges[e.n].tail].first_out = edges[e.n].next_out;
    1.84 -      edges[e.n].tail = n.n;
    1.85 -      edges[e.n].prev_out = -1;
    1.86 -      edges[e.n].next_out = nodes[n.n].first_out;
    1.87 -      nodes[n.n].first_out = e.n;
    1.88 -    }
    1.89 -  }
    1.90 +    void moveTail(Edge e, Node n) { _moveTail(e,n); }
    1.91 +
    1.92 +    ///Using this it possible to avoid the superfluous memory allocation.
    1.93 +    ///\todo more docs...
    1.94 +    void reserveEdge(int n) { edges.reserve(n); };
    1.95 +    
    1.96 +  };
    1.97 +  
    1.98    /// @}  
    1.99  } //namespace lemon
   1.100