27 #ifndef G2O_AIS_HYPER_GRAPH_HH 28 #define G2O_AIS_HYPER_GRAPH_HH 38 #include <unordered_map> 71 static const int UnassignedId = -1;
72 static const int InvalidId = -2;
89 virtual HyperGraphElementType elementType()
const = 0;
102 virtual bool read(std::istream& is) = 0;
104 virtual bool write(std::ostream& os)
const = 0;
145 explicit Vertex(
int id=InvalidId);
148 int id()
const {
return _id;}
149 virtual void setId(
int newId) { _id=newId; }
151 const EdgeSet&
edges()
const {
return _edges;}
168 explicit Edge(
int id = InvalidId);
174 virtual void resize(
size_t size);
178 const VertexContainer&
vertices()
const {
return _vertices;}
186 const Vertex*
vertex(
size_t i)
const { assert(i < _vertices.size() &&
"index out of bounds");
return _vertices[i];}
190 Vertex*
vertex(
size_t i) { assert(i < _vertices.size() &&
"index out of bounds");
return _vertices[i];}
194 void setVertex(
size_t i,
Vertex* v) { assert(i < _vertices.size() &&
"index out of bounds"); _vertices[i]=v;}
196 int id()
const {
return _id;}
200 int numUndefinedVertices()
const;
215 const Vertex* vertex(
int id)
const;
218 virtual bool removeVertex(
Vertex* v,
bool detach=
false);
220 virtual bool removeEdge(
Edge* e);
222 virtual void clear();
225 const VertexIDMap&
vertices()
const {
return _vertices;}
230 const EdgeSet&
edges()
const {
return _edges;}
240 virtual bool addVertex(
Vertex* v);
246 virtual bool addEdge(
Edge* e);
253 virtual bool setEdgeVertex(
Edge* e,
int pos,
Vertex* v);
260 virtual bool mergeVertices(
Vertex* vBig,
Vertex* vSmall,
bool erase);
265 virtual bool detachVertex(
Vertex* v);
271 virtual bool changeId(
Vertex* v,
int newId);
const Data * next() const
int id() const
returns the id
const Vertex * vertex(size_t i) const
virtual HyperGraph::HyperGraphElementType elementType() const
data packet for a vertex. Extend this class to store in the vertices the potential additional informa...
const Data * userData() const
the user data associated with this vertex
std::vector< Vertex * > VertexContainer
std::bitset< HyperGraph::HGET_NUM_ELEMS > GraphElemBitset
std::set< Vertex * > VertexSet
HyperGraphElement * clone() const
void setVertex(size_t i, Vertex *v)
DataContainer * _dataContainer
const VertexIDMap & vertices() const
virtual void setId(int newId)
std::set< Edge * > EdgeSet
Vertex * vertex(size_t i)
const VertexContainer & vertices() const
const EdgeSet & edges() const
returns the set of hyper-edges that are leaving/entering in this vertex
void setDataContainer(DataContainer *dataContainer_)
const EdgeSet & edges() const
VertexContainer & vertices()
virtual ~HyperGraphElement()
std::unordered_map< int, Vertex * > VertexIDMap
DataContainer * dataContainer()
abstract Vertex, your types must derive from that one
virtual HyperGraphElementType elementType() const
void setNext(Data *next_)
void setUserData(Data *obs)
virtual HyperGraphElementType elementType() const
Container class that implements an interface for adding/removing Data elements in a linked list...
void addUserData(Data *obs)
HyperGraph(const HyperGraph &)
EdgeSet & edges()
returns the set of hyper-edges that are leaving/entering in this vertex
const DataContainer * dataContainer() const
VertexContainer _vertices