lemon/smart_graph.h
changeset 149 2f7ae34e1333
parent 139 701c529ba737
child 157 2ccc1afc2c52
     1.1 --- a/lemon/smart_graph.h	Thu Apr 24 11:56:44 2008 +0200
     1.2 +++ b/lemon/smart_graph.h	Thu Apr 24 13:53:09 2008 +0100
     1.3 @@ -115,6 +115,13 @@
     1.4      static Node nodeFromId(int id) { return Node(id);}
     1.5      static Arc arcFromId(int id) { return Arc(id);}
     1.6  
     1.7 +    bool valid(Node n) const { 
     1.8 +      return n._id >= 0 && n._id < static_cast<int>(nodes.size()); 
     1.9 +    }
    1.10 +    bool valid(Arc a) const { 
    1.11 +      return a._id >= 0 && a._id < static_cast<int>(arcs.size()); 
    1.12 +    }
    1.13 +
    1.14      class Node {
    1.15        friend class SmartDigraphBase;
    1.16        friend class SmartDigraph;
    1.17 @@ -261,6 +268,24 @@
    1.18      /// \sa reserveNode
    1.19      void reserveArc(int m) { arcs.reserve(m); };
    1.20  
    1.21 +    /// \brief Node validity check
    1.22 +    ///
    1.23 +    /// This function gives back true if the given node is valid,
    1.24 +    /// ie. it is a real node of the graph.  
    1.25 +    ///
    1.26 +    /// \warning A removed node (using Snapshot) could become valid again
    1.27 +    /// when new nodes are added to the graph.
    1.28 +    bool valid(Node n) const { return Parent::valid(n); }
    1.29 +
    1.30 +    /// \brief Arc validity check
    1.31 +    ///
    1.32 +    /// This function gives back true if the given arc is valid,
    1.33 +    /// ie. it is a real arc of the graph.  
    1.34 +    ///
    1.35 +    /// \warning A removed arc (using Snapshot) could become valid again
    1.36 +    /// when new arcs are added to the graph.
    1.37 +    bool valid(Arc a) const { return Parent::valid(a); }
    1.38 +
    1.39      ///Clear the digraph.
    1.40      
    1.41      ///Erase all the nodes and arcs from the digraph.
    1.42 @@ -550,6 +575,16 @@
    1.43      static Arc arcFromId(int id) { return Arc(id);}
    1.44      static Edge edgeFromId(int id) { return Edge(id);}
    1.45  
    1.46 +    bool valid(Node n) const { 
    1.47 +      return n._id >= 0 && n._id < static_cast<int>(nodes.size()); 
    1.48 +    }
    1.49 +    bool valid(Arc a) const { 
    1.50 +      return a._id >= 0 && a._id < static_cast<int>(arcs.size());
    1.51 +    }
    1.52 +    bool valid(Edge e) const { 
    1.53 +      return e._id >= 0 && 2 * e._id < static_cast<int>(arcs.size()); 
    1.54 +    }
    1.55 +
    1.56      Node addNode() {     
    1.57        int n = nodes.size();
    1.58        nodes.push_back(NodeT());
    1.59 @@ -642,6 +677,33 @@
    1.60        return Parent::addEdge(s, t); 
    1.61      }
    1.62  
    1.63 +    /// \brief Node validity check
    1.64 +    ///
    1.65 +    /// This function gives back true if the given node is valid,
    1.66 +    /// ie. it is a real node of the graph.  
    1.67 +    ///
    1.68 +    /// \warning A removed node (using Snapshot) could become valid again
    1.69 +    /// when new nodes are added to the graph.
    1.70 +    bool valid(Node n) const { return Parent::valid(n); }
    1.71 +
    1.72 +    /// \brief Arc validity check
    1.73 +    ///
    1.74 +    /// This function gives back true if the given arc is valid,
    1.75 +    /// ie. it is a real arc of the graph.  
    1.76 +    ///
    1.77 +    /// \warning A removed arc (using Snapshot) could become valid again
    1.78 +    /// when new edges are added to the graph.
    1.79 +    bool valid(Arc a) const { return Parent::valid(a); }
    1.80 +
    1.81 +    /// \brief Edge validity check
    1.82 +    ///
    1.83 +    /// This function gives back true if the given edge is valid,
    1.84 +    /// ie. it is a real edge of the graph.  
    1.85 +    ///
    1.86 +    /// \warning A removed edge (using Snapshot) could become valid again
    1.87 +    /// when new edges are added to the graph.
    1.88 +    bool valid(Edge e) const { return Parent::valid(e); }
    1.89 +
    1.90      ///Clear the graph.
    1.91      
    1.92      ///Erase all the nodes and edges from the graph.