src/hugo/smart_graph.h
changeset 716 e7f13f60fcfd
parent 706 0fe42b8ec5a6
child 722 be8712e1fe07
equal deleted inserted replaced
4:5aa97915b27b 5:d87942f89905
   134 //     It first() const { It e; first(e); return e; }
   134 //     It first() const { It e; first(e); return e; }
   135 
   135 
   136 //     template< typename It >
   136 //     template< typename It >
   137 //     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; }
   138 
   138 
   139     bool valid(Edge e) const { return e.n!=-1; }
   139     static bool valid(Edge e) { return e.n!=-1; }
   140     bool valid(Node n) const { return n.n!=-1; }
   140     static bool valid(Node n) { return n.n!=-1; }
   141     
   141     
   142     ///\deprecated Use
   142     ///\deprecated Use
   143     ///\code
   143     ///\code
   144     ///  e=INVALID;
   144     ///  e=INVALID;
   145     ///\endcode
   145     ///\endcode
   146     ///instead.
   146     ///instead.
   147     void setInvalid(Edge &e) { e.n=-1; }
   147     static void setInvalid(Edge &e) { e.n=-1; }
   148     ///\deprecated Use
   148     ///\deprecated Use
   149     ///\code
   149     ///\code
   150     ///  e=INVALID;
   150     ///  e=INVALID;
   151     ///\endcode
   151     ///\endcode
   152     ///instead.
   152     ///instead.
   153     void setInvalid(Node &n) { n.n=-1; }
   153     static void setInvalid(Node &n) { n.n=-1; }
   154     
   154     
   155     template <typename It> It getNext(It it) const
   155     template <typename It> It getNext(It it) const
   156     { It tmp(it); return next(tmp); }
   156     { It tmp(it); return next(tmp); }
   157 
   157 
   158     NodeIt& next(NodeIt& it) const { 
   158     NodeIt& next(NodeIt& it) const { 
   163     { it.n=edges[it.n].next_out; return it; }
   163     { it.n=edges[it.n].next_out; return it; }
   164     InEdgeIt& next(InEdgeIt& it) const
   164     InEdgeIt& next(InEdgeIt& it) const
   165     { it.n=edges[it.n].next_in; return it; }
   165     { it.n=edges[it.n].next_in; return it; }
   166     EdgeIt& next(EdgeIt& it) const { --it.n; return it; }
   166     EdgeIt& next(EdgeIt& it) const { --it.n; return it; }
   167 
   167 
   168     int id(Node v) const { return v.n; }
   168     static int id(Node v) { return v.n; }
   169     int id(Edge e) const { return e.n; }
   169     static int id(Edge e) { return e.n; }
   170 
   170 
   171     Node addNode() {
   171     Node addNode() {
   172       Node n; n.n=nodes.size();
   172       Node n; n.n=nodes.size();
   173       nodes.push_back(NodeT()); //FIXME: Hmmm...
   173       nodes.push_back(NodeT()); //FIXME: Hmmm...
   174 
   174 
   501 
   501 
   502     ///The oppositely directed edge.
   502     ///The oppositely directed edge.
   503 
   503 
   504     ///Returns the oppositely directed
   504     ///Returns the oppositely directed
   505     ///pair of the edge \c e.
   505     ///pair of the edge \c e.
   506     Edge opposite(Edge e) const
   506     static Edge opposite(Edge e)
   507     {
   507     {
   508       Edge f;
   508       Edge f;
   509       f.idref() = e.idref() - 2*(e.idref()%2) + 1;
   509       f.idref() = e.idref() - 2*(e.idref()%2) + 1;
   510       return f;
   510       return f;
   511     }
   511     }