src/include/smart_graph.h
changeset 525 ddc405f1d48f
parent 491 4804c967543d
child 531 66f1c466889f
equal deleted inserted replaced
8:ee4a1a8bce25 9:59148018f7ec
    78     ///
    78     ///
    79     mutable std::vector<DynMapBase<Edge> * > dyn_edge_maps;
    79     mutable std::vector<DynMapBase<Edge> * > dyn_edge_maps;
    80     
    80     
    81   public:
    81   public:
    82 
    82 
       
    83 
    83     class NodeIt;
    84     class NodeIt;
    84     class EdgeIt;
    85     class EdgeIt;
    85     class OutEdgeIt;
    86     class OutEdgeIt;
    86     class InEdgeIt;
    87     class InEdgeIt;
    87     
    88     
   136 //     It first(Node v) const { It e; first(e,v); return e; }
   137 //     It first(Node v) const { It e; first(e,v); return e; }
   137 
   138 
   138     bool valid(Edge e) const { return e.n!=-1; }
   139     bool valid(Edge e) const { return e.n!=-1; }
   139     bool valid(Node n) const { return n.n!=-1; }
   140     bool valid(Node n) const { return n.n!=-1; }
   140     
   141     
       
   142     ///\deprecated Use
       
   143     ///\code
       
   144     ///  e=INVALID;
       
   145     ///\endcode
       
   146     ///instead.
   141     void setInvalid(Edge &e) { e.n=-1; }
   147     void setInvalid(Edge &e) { e.n=-1; }
       
   148     ///\deprecated Use
       
   149     ///\code
       
   150     ///  e=INVALID;
       
   151     ///\endcode
       
   152     ///instead.
   142     void setInvalid(Node &n) { n.n=-1; }
   153     void setInvalid(Node &n) { n.n=-1; }
   143     
   154     
   144     template <typename It> It getNext(It it) const
   155     template <typename It> It getNext(It it) const
   145     { It tmp(it); return next(tmp); }
   156     { It tmp(it); return next(tmp); }
   146 
   157 
   195       int n;
   206       int n;
   196       friend int SmartGraph::id(Node v) const; 
   207       friend int SmartGraph::id(Node v) const; 
   197       Node(int nn) {n=nn;}
   208       Node(int nn) {n=nn;}
   198     public:
   209     public:
   199       Node() {}
   210       Node() {}
   200       Node (Invalid i) { n=-1; }
   211       Node (Invalid) { n=-1; }
   201       bool operator==(const Node i) const {return n==i.n;}
   212       bool operator==(const Node i) const {return n==i.n;}
   202       bool operator!=(const Node i) const {return n!=i.n;}
   213       bool operator!=(const Node i) const {return n!=i.n;}
   203       bool operator<(const Node i) const {return n<i.n;}
   214       bool operator<(const Node i) const {return n<i.n;}
   204     };
   215     };
   205     
   216     
   377 	G->dyn_edge_maps.push_back(this);
   388 	G->dyn_edge_maps.push_back(this);
   378       } 
   389       } 
   379       EdgeMap(const EdgeMap<T> &m) :
   390       EdgeMap(const EdgeMap<T> &m) :
   380  	DynMapBase<Edge>(*m.G), container(m.container)
   391  	DynMapBase<Edge>(*m.G), container(m.container)
   381       {
   392       {
   382  	G->dyn_node_maps.push_back(this);
   393  	G->dyn_edge_maps.push_back(this);
   383       }
   394       }
   384 
   395 
   385       template<typename TT> friend class EdgeMap;
   396       template<typename TT> friend class EdgeMap;
   386 
   397 
   387       ///\todo It can copy between different types.
   398       ///\todo It can copy between different types.
   388       ///
   399       ///
   389       template<typename TT> EdgeMap(const EdgeMap<TT> &m) :
   400       template<typename TT> EdgeMap(const EdgeMap<TT> &m) :
   390 	DynMapBase<Edge>(*m.G)
   401 	DynMapBase<Edge>(*m.G)
   391       {
   402       {
   392 	G->dyn_node_maps.push_back(this);
   403 	G->dyn_edge_maps.push_back(this);
   393 	typename std::vector<TT>::const_iterator i;
   404 	typename std::vector<TT>::const_iterator i;
   394 	for(typename std::vector<TT>::const_iterator i=m.container.begin();
   405 	for(typename std::vector<TT>::const_iterator i=m.container.begin();
   395 	    i!=m.container.end();
   406 	    i!=m.container.end();
   396 	    i++)
   407 	    i++)
   397 	  container.push_back(*i);
   408 	  container.push_back(*i);