# HG changeset patch # User alpar # Date 1099153812 0 # Node ID bc86b64f958e76cab69707f7bb6b96be0a08a7b9 # Parent 93e9c45703eaef73a10b7368168c7520dece87ca - moveHead() and moveTail() added. Not tested. diff -r 93e9c45703ea -r bc86b64f958e src/lemon/list_graph.h --- a/src/lemon/list_graph.h Fri Oct 29 06:04:43 2004 +0000 +++ b/src/lemon/list_graph.h Sat Oct 30 16:30:12 2004 +0000 @@ -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 #include #include @@ -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 ClearableListGraphBase; typedef ErasableGraphExtender 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