lemon/full_graph.h
changeset 1986 9b56cca61e2e
parent 1979 c2992fd74dad
child 1987 8cd6683382e0
     1.1 --- a/lemon/full_graph.h	Mon Feb 27 10:17:33 2006 +0000
     1.2 +++ b/lemon/full_graph.h	Mon Feb 27 10:36:01 2006 +0000
     1.3 @@ -36,6 +36,9 @@
     1.4  
     1.5  namespace lemon {
     1.6  
     1.7 +  /// \brief Base of the FullGrpah.
     1.8 +  ///
     1.9 +  /// Base of the FullGrpah.
    1.10    class FullGraphBase {
    1.11      int _nodeNum;
    1.12      int _edgeNum;
    1.13 @@ -53,13 +56,26 @@
    1.14  
    1.15      ///Creates a full graph with \c n nodes.
    1.16      void construct(int n) { _nodeNum = n; _edgeNum = n * n; }
    1.17 -    ///
    1.18 -    //    FullGraphBase(const FullGraphBase &_g)
    1.19 -    //      : _nodeNum(_g.nodeNum()), _edgeNum(_nodeNum*_nodeNum) { }
    1.20      
    1.21      typedef True NodeNumTag;
    1.22      typedef True EdgeNumTag;
    1.23  
    1.24 +    /// \brief Returns the node with the given index.
    1.25 +    ///
    1.26 +    /// Returns the node with the given index. Because it is a
    1.27 +    /// static size graph the node's of the graph can be indiced
    1.28 +    /// by the range from 0 to \e nodeNum()-1 and the index of
    1.29 +    /// the node can accessed by the \e index() member.
    1.30 +    Node operator()(int index) const { return Node(index); }
    1.31 +
    1.32 +    /// \brief Returns the index of the node.
    1.33 +    ///
    1.34 +    /// Returns the index of the node. Because it is a
    1.35 +    /// static size graph the node's of the graph can be indiced
    1.36 +    /// by the range from 0 to \e nodeNum()-1 and the index of
    1.37 +    /// the node can accessed by the \e index() member.
    1.38 +    int index(const Node& node) const { return node.id; }
    1.39 +
    1.40      ///Number of nodes.
    1.41      int nodeNum() const { return _nodeNum; }
    1.42      ///Number of edges.
    1.43 @@ -202,6 +218,9 @@
    1.44    /// the \ref concept::StaticGraph "StaticGraph" concept
    1.45    /// \sa concept::StaticGraph.
    1.46    ///
    1.47 +  /// \sa FullGraphBase
    1.48 +  /// \sa FullUGraph
    1.49 +  ///
    1.50    /// \author Alpar Juttner
    1.51    class FullGraph : public ExtendedFullGraphBase {
    1.52    public:
    1.53 @@ -214,6 +233,9 @@
    1.54  
    1.55      /// \brief Resize the graph
    1.56      ///
    1.57 +    /// Resize the graph. The function will fully destroy and build the graph.
    1.58 +    /// This cause that the maps of the graph will reallocated
    1.59 +    /// automatically and the previous values will be lost.
    1.60      void resize(int n) {
    1.61        Parent::getNotifier(Edge()).clear();
    1.62        Parent::getNotifier(Node()).clear();
    1.63 @@ -224,6 +246,9 @@
    1.64    };
    1.65  
    1.66  
    1.67 +  /// \brief Base of the FullUGrpah.
    1.68 +  ///
    1.69 +  /// Base of the FullUGrpah.
    1.70    class FullUGraphBase {
    1.71      int _nodeNum;
    1.72      int _edgeNum;
    1.73 @@ -241,10 +266,23 @@
    1.74  
    1.75      ///Creates a full graph with \c n nodes.
    1.76      void construct(int n) { _nodeNum = n; _edgeNum = n * (n - 1) / 2; }
    1.77 +
    1.78 +    /// \brief Returns the node with the given index.
    1.79      ///
    1.80 -    //    FullGraphBase(const FullGraphBase &_g)
    1.81 -    //      : _nodeNum(_g.nodeNum()), _edgeNum(_nodeNum*_nodeNum) { }
    1.82 -    
    1.83 +    /// Returns the node with the given index. Because it is a
    1.84 +    /// static size graph the node's of the graph can be indiced
    1.85 +    /// by the range from 0 to \e nodeNum()-1 and the index of
    1.86 +    /// the node can accessed by the \e index() member.
    1.87 +    Node operator()(int index) const { return Node(index); }
    1.88 +
    1.89 +    /// \brief Returns the index of the node.
    1.90 +    ///
    1.91 +    /// Returns the index of the node. Because it is a
    1.92 +    /// static size graph the node's of the graph can be indiced
    1.93 +    /// by the range from 0 to \e nodeNum()-1 and the index of
    1.94 +    /// the node can accessed by the \e index() member.
    1.95 +    int index(const Node& node) const { return node.id; }
    1.96 +
    1.97      typedef True NodeNumTag;
    1.98      typedef True EdgeNumTag;
    1.99  
   1.100 @@ -275,18 +313,19 @@
   1.101      }
   1.102  
   1.103  
   1.104 -    /// Node ID.
   1.105 -    
   1.106 +    /// \brief Node ID.
   1.107 +    ///
   1.108      /// The ID of a valid Node is a nonnegative integer not greater than
   1.109      /// \ref maxNodeId(). The range of the ID's is not surely continuous
   1.110      /// and the greatest node ID can be actually less then \ref maxNodeId().
   1.111      ///
   1.112      /// The ID of the \ref INVALID node is -1.
   1.113 -    ///\return The ID of the node \c v. 
   1.114 +    /// \return The ID of the node \c v. 
   1.115  
   1.116      static int id(Node v) { return v.id; }
   1.117 -    /// Edge ID.
   1.118 -    
   1.119 +
   1.120 +    /// \brief Edge ID.
   1.121 +    ///
   1.122      /// The ID of a valid Edge is a nonnegative integer not greater than
   1.123      /// \ref maxEdgeId(). The range of the ID's is not surely continuous
   1.124      /// and the greatest edge ID can be actually less then \ref maxEdgeId().
   1.125 @@ -295,8 +334,8 @@
   1.126      ///\return The ID of the edge \c e. 
   1.127      static int id(Edge e) { return e.id; }
   1.128  
   1.129 -    /// Finds an edge between two nodes.
   1.130 -    
   1.131 +    /// \brief Finds an edge between two nodes.
   1.132 +    ///
   1.133      /// Finds an edge from node \c u to node \c v.
   1.134      ///
   1.135      /// If \c prev is \ref INVALID (this is the default value), then
   1.136 @@ -304,7 +343,7 @@
   1.137      /// the next edge from \c u to \c v after \c prev.
   1.138      /// \return The found edge or INVALID if there is no such an edge.
   1.139      Edge findEdge(Node u, Node v, Edge prev = INVALID) const {
   1.140 -      if (prev.id != -1 || u.id <= v.id) return -1;
   1.141 +      if (prev.id != -1 || u.id <= v.id) return Edge(-1);
   1.142        return Edge(u.id * (u.id - 1) / 2 + v.id);
   1.143      }
   1.144  
   1.145 @@ -403,6 +442,7 @@
   1.146    /// is that this class conforms to the undirected graph concept and
   1.147    /// it does not contain the loop edges.
   1.148    ///
   1.149 +  /// \sa FullUGraphBase
   1.150    /// \sa FullGraph
   1.151    ///
   1.152    /// \author Balazs Dezso
   1.153 @@ -416,6 +456,9 @@
   1.154  
   1.155      /// \brief Resize the graph
   1.156      ///
   1.157 +    /// Resize the graph. The function will fully destroy and build the graph.
   1.158 +    /// This cause that the maps of the graph will reallocated
   1.159 +    /// automatically and the previous values will be lost.
   1.160      void resize(int n) {
   1.161        Parent::getNotifier(Edge()).clear();
   1.162        Parent::getNotifier(UEdge()).clear();
   1.163 @@ -612,6 +655,7 @@
   1.164    /// It is completely static, so you can neither add nor delete either
   1.165    /// edges or nodes.
   1.166    ///
   1.167 +  /// \sa FullUGraphBase
   1.168    /// \sa FullGraph
   1.169    ///
   1.170    /// \author Balazs Dezso