COIN-OR::LEMON - Graph Library

Changeset 948:bc86b64f958e in lemon-0.x


Ignore:
Timestamp:
10/30/04 18:30:12 (19 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1328
Message:
  • moveHead() and moveTail() added. Not tested.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/list_graph.h

    r946 r948  
    1 // -*- c++ -*-
     1/* -*- C++ -*-
     2 * src/lemon/list_graph.h - Part of LEMON, a generic C++ optimization library
     3 *
     4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     5 * (Egervary Combinatorial Optimization Research Group, EGRES).
     6 *
     7 * Permission to use, modify and distribute this software is granted
     8 * provided that this copyright notice appears in all copies. For
     9 * precise terms see the accompanying LICENSE file.
     10 *
     11 * This software is provided "AS IS" with no warranty of any kind,
     12 * express or implied, and with no claim as to its suitability for any
     13 * purpose.
     14 *
     15 */
    216
    317#ifndef LEMON_LIST_GRAPH_H
    418#define LEMON_LIST_GRAPH_H
     19
     20///\ingroup graphs
     21///\file
     22///\brief ListGraph, SymListGraph, NodeSet and EdgeSet classes.
    523
    624#include <lemon/erasable_graph_extender.h>
     
    83101
    84102   
    85     ///it possible to avoid the superfluous memory allocation.
     103    ///Using this it possible to avoid the superfluous memory allocation.
     104    ///\todo more docs...
     105    ///\todo It should be defined in ListGraph.
    86106    void reserveEdge(int n) { edges.reserve(n); };
    87107   
     
    268288  typedef ErasableGraphExtender<ClearableListGraphBase> ErasableListGraphBase;
    269289
    270   typedef ErasableListGraphBase ListGraph;
    271 
    272 }
    273 
    274 
     290/// \addtogroup graphs
     291/// @{
     292
     293  ///A list graph class.
     294
     295  ///This is a simple and fast erasable graph implementation.
     296  ///
     297  ///It conforms to the
     298  ///\ref skeleton::ErasableGraph "ErasableGraph" concept.
     299  ///\sa skeleton::ErasableGraph.
     300
     301  class ListGraph : public ErasableListGraphBase
     302  {
     303  public:
     304    /// Moves the head of \c e to \c n
     305
     306    /// Moves the head of \c e to \c n
     307    ///
     308    void moveHead(Edge e, Node n)
     309    {
     310      if(edges[e.n].next_in != -1)
     311        edges[edges[e.n].next_in].prev_in = edges[e.n].prev_in;
     312      if(edges[e.n].prev_in != -1)
     313        edges[edges[e.n].prev_in].next_in = edges[e.n].next_in;
     314      else nodes[edges[e.n].head].first_in = edges[e.n].next_in;
     315      edges[e.n].head = n.n;
     316      edges[e.n].prev_in = -1;
     317      edges[e.n].next_in = nodes[n.n].first_in;
     318      nodes[n.n].first_in = e.n;
     319    }
     320    /// Moves the tail of \c e to \c n
     321
     322    /// Moves the tail of \c e to \c n
     323    ///
     324    void moveTail(Edge e, Node n)
     325    {
     326      if(edges[e.n].next_out != -1)
     327        edges[edges[e.n].next_out].prev_out = edges[e.n].prev_out;
     328      if(edges[e.n].prev_out != -1)
     329        edges[edges[e.n].prev_out].next_out = edges[e.n].next_out;
     330      else nodes[edges[e.n].tail].first_out = edges[e.n].next_out;
     331      edges[e.n].tail = n.n;
     332      edges[e.n].prev_out = -1;
     333      edges[e.n].next_out = nodes[n.n].first_out;
     334      nodes[n.n].first_out = e.n;
     335    }
     336  }
     337  /// @} 
     338} //namespace lemon
    275339 
    276340
Note: See TracChangeset for help on using the changeset viewer.