COIN-OR::LEMON - Graph Library

Changeset 1986:9b56cca61e2e in lemon-0.x for lemon


Ignore:
Timestamp:
02/27/06 11:36:01 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2584
Message:

An additional simplier interface for static size graphs.
Node operator()(int) for getting node by index
int index(Node node) for getting index by node

Location:
lemon
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lemon/full_graph.h

    r1979 r1986  
    3737namespace lemon {
    3838
     39  /// \brief Base of the FullGrpah.
     40  ///
     41  /// Base of the FullGrpah.
    3942  class FullGraphBase {
    4043    int _nodeNum;
     
    5457    ///Creates a full graph with \c n nodes.
    5558    void construct(int n) { _nodeNum = n; _edgeNum = n * n; }
    56     ///
    57     //    FullGraphBase(const FullGraphBase &_g)
    58     //      : _nodeNum(_g.nodeNum()), _edgeNum(_nodeNum*_nodeNum) { }
    5959   
    6060    typedef True NodeNumTag;
    6161    typedef True EdgeNumTag;
     62
     63    /// \brief Returns the node with the given index.
     64    ///
     65    /// Returns the node with the given index. Because it is a
     66    /// static size graph the node's of the graph can be indiced
     67    /// by the range from 0 to \e nodeNum()-1 and the index of
     68    /// the node can accessed by the \e index() member.
     69    Node operator()(int index) const { return Node(index); }
     70
     71    /// \brief Returns the index of the node.
     72    ///
     73    /// Returns the index of the node. Because it is a
     74    /// static size graph the node's of the graph can be indiced
     75    /// by the range from 0 to \e nodeNum()-1 and the index of
     76    /// the node can accessed by the \e index() member.
     77    int index(const Node& node) const { return node.id; }
    6278
    6379    ///Number of nodes.
     
    203219  /// \sa concept::StaticGraph.
    204220  ///
     221  /// \sa FullGraphBase
     222  /// \sa FullUGraph
     223  ///
    205224  /// \author Alpar Juttner
    206225  class FullGraph : public ExtendedFullGraphBase {
     
    215234    /// \brief Resize the graph
    216235    ///
     236    /// Resize the graph. The function will fully destroy and build the graph.
     237    /// This cause that the maps of the graph will reallocated
     238    /// automatically and the previous values will be lost.
    217239    void resize(int n) {
    218240      Parent::getNotifier(Edge()).clear();
     
    225247
    226248
     249  /// \brief Base of the FullUGrpah.
     250  ///
     251  /// Base of the FullUGrpah.
    227252  class FullUGraphBase {
    228253    int _nodeNum;
     
    242267    ///Creates a full graph with \c n nodes.
    243268    void construct(int n) { _nodeNum = n; _edgeNum = n * (n - 1) / 2; }
    244     ///
    245     //    FullGraphBase(const FullGraphBase &_g)
    246     //      : _nodeNum(_g.nodeNum()), _edgeNum(_nodeNum*_nodeNum) { }
    247    
     269
     270    /// \brief Returns the node with the given index.
     271    ///
     272    /// Returns the node with the given index. Because it is a
     273    /// static size graph the node's of the graph can be indiced
     274    /// by the range from 0 to \e nodeNum()-1 and the index of
     275    /// the node can accessed by the \e index() member.
     276    Node operator()(int index) const { return Node(index); }
     277
     278    /// \brief Returns the index of the node.
     279    ///
     280    /// Returns the index of the node. Because it is a
     281    /// static size graph the node's of the graph can be indiced
     282    /// by the range from 0 to \e nodeNum()-1 and the index of
     283    /// the node can accessed by the \e index() member.
     284    int index(const Node& node) const { return node.id; }
     285
    248286    typedef True NodeNumTag;
    249287    typedef True EdgeNumTag;
     
    276314
    277315
    278     /// Node ID.
    279    
     316    /// \brief Node ID.
     317    ///
    280318    /// The ID of a valid Node is a nonnegative integer not greater than
    281319    /// \ref maxNodeId(). The range of the ID's is not surely continuous
     
    283321    ///
    284322    /// The ID of the \ref INVALID node is -1.
    285     ///\return The ID of the node \c v.
     323    /// \return The ID of the node \c v.
    286324
    287325    static int id(Node v) { return v.id; }
    288     /// Edge ID.
    289    
     326
     327    /// \brief Edge ID.
     328    ///
    290329    /// The ID of a valid Edge is a nonnegative integer not greater than
    291330    /// \ref maxEdgeId(). The range of the ID's is not surely continuous
     
    296335    static int id(Edge e) { return e.id; }
    297336
    298     /// Finds an edge between two nodes.
    299    
     337    /// \brief Finds an edge between two nodes.
     338    ///
    300339    /// Finds an edge from node \c u to node \c v.
    301340    ///
     
    305344    /// \return The found edge or INVALID if there is no such an edge.
    306345    Edge findEdge(Node u, Node v, Edge prev = INVALID) const {
    307       if (prev.id != -1 || u.id <= v.id) return -1;
     346      if (prev.id != -1 || u.id <= v.id) return Edge(-1);
    308347      return Edge(u.id * (u.id - 1) / 2 + v.id);
    309348    }
     
    404443  /// it does not contain the loop edges.
    405444  ///
     445  /// \sa FullUGraphBase
    406446  /// \sa FullGraph
    407447  ///
     
    417457    /// \brief Resize the graph
    418458    ///
     459    /// Resize the graph. The function will fully destroy and build the graph.
     460    /// This cause that the maps of the graph will reallocated
     461    /// automatically and the previous values will be lost.
    419462    void resize(int n) {
    420463      Parent::getNotifier(Edge()).clear();
     
    613656  /// edges or nodes.
    614657  ///
     658  /// \sa FullUGraphBase
    615659  /// \sa FullGraph
    616660  ///
  • lemon/grid_ugraph.h

    r1979 r1986  
    127127    /// Gives back the node on the given position.
    128128    Node operator()(int i, int j) const {
    129       LEMON_ASSERT(0 <= i && i < width() && 0 <= j  && j < height(), IndexError());
     129      LEMON_ASSERT(0 <= i && i < width() && 0 <= j  &&
     130                   j < height(), IndexError());
    130131      return Node(i + j * _width);
    131132    }
  • lemon/hypercube_graph.h

    r1979 r1986  
    225225    ///
    226226    ///  Gives back the node by its index.
    227     Node node(int index) const {
     227    Node operator()(int index) const {
    228228      return Node(index);
    229229    }
Note: See TracChangeset for help on using the changeset viewer.