hyper_graph.h
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
00003 // 
00004 // g2o is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as published
00006 // by the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // g2o is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef _AIS_HYPER_GRAPH_HH
00018 #define _AIS_HYPER_GRAPH_HH
00019 
00020 #include <map>
00021 #include <set>
00022 #include <cassert>
00023 #include <vector>
00024 #include <limits>
00025 #include <cstddef>
00026 
00027 #ifdef _MSC_VER
00028 #include <unordered_map>
00029 #else
00030 #include <tr1/unordered_map>
00031 #endif
00032 
00035 namespace g2o {
00036 
00046   class HyperGraph
00047   {
00048     public:
00049       class Vertex;
00050       class Edge;
00051       
00053       struct HyperGraphElement {
00054         virtual ~HyperGraphElement() {}
00055       };
00056 
00057       typedef std::set<Edge*>                           EdgeSet;
00058       typedef std::set<Vertex*>                         VertexSet;
00059 
00060       typedef std::tr1::unordered_map<int, Vertex*>     VertexIDMap;
00061       typedef std::vector<Vertex*>                      VertexVector;
00062 
00064       class Vertex : public HyperGraphElement {
00065         public:
00067           explicit Vertex(int id=-1);
00068           virtual ~Vertex();
00070           int id() const {return _id;}
00072           const EdgeSet& edges() const {return _edges;}
00074           EdgeSet& edges() {return _edges;}
00075         protected:
00076           int _id;
00077           EdgeSet _edges;
00078       };
00079 
00084       class Edge : public HyperGraphElement {
00085         public:
00087           explicit Edge(int id = -1);
00088           virtual ~Edge();
00089 
00093           virtual void resize(size_t size);
00097           const VertexVector& vertices() const { return _vertices;}
00101           VertexVector& vertices() { return _vertices;}
00102 
00103           int id() const {return _id;}
00104           void setId(int id);
00105         protected:
00106           VertexVector _vertices;
00107           int _id; // unique id
00108       };
00109 
00110     public:
00112       HyperGraph();
00114       virtual ~HyperGraph();
00115 
00117       Vertex* vertex(int id);
00119       const Vertex* vertex(int id) const;
00120 
00122       virtual bool removeVertex(Vertex* v);
00124       virtual bool removeEdge(Edge* e);
00126       virtual void clear();
00127 
00129       const VertexIDMap& vertices() const {return _vertices;}
00131       VertexIDMap& vertices() {return _vertices;}
00132 
00134       const EdgeSet& edges() const {return _edges;}
00136       EdgeSet& edges() {return _edges;}
00137 
00144       Vertex* addVertex(Vertex* v);
00145 
00147       Edge* addEdge(Edge* e);
00148 
00149     protected:
00150       VertexIDMap _vertices;
00151       EdgeSet _edges;
00152   };
00153 
00154 } // end namespace
00155 
00157 
00158 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:24