27#ifndef G2O_AIS_HYPER_GRAPH_HH
28#define G2O_AIS_HYPER_GRAPH_HH
34#include <unordered_map>
67 static const int UnassignedId = -1;
68 static const int InvalidId = -2;
98 virtual bool read(std::istream& is) = 0;
100 virtual bool write(std::ostream& os)
const = 0;
102 return HyperGraph::HGET_DATA;
110 _dataContainer = dataContainer_;
151 explicit Vertex(
int id = InvalidId);
154 int id()
const {
return _id; }
155 virtual void setId(
int newId) { _id = newId; }
175 explicit Edge(
int id = InvalidId);
181 virtual void resize(
size_t size);
196 assert(i < _vertices.size() &&
"index out of bounds");
203 assert(i < _vertices.size() &&
"index out of bounds");
210 assert(i < _vertices.size() &&
"index out of bounds");
214 int id()
const {
return _id; }
218 int numUndefinedVertices()
const;
236 const Vertex* vertex(
int id)
const;
240 virtual bool removeVertex(
Vertex* v,
bool detach =
false);
243 virtual bool removeEdge(
Edge* e);
245 virtual void clear();
263 virtual bool addVertex(Vertex* v);
269 virtual bool addEdge(Edge* e);
275 virtual bool setEdgeVertex(Edge* e,
int pos, Vertex* v);
282 virtual bool mergeVertices(Vertex* vBig, Vertex* vSmall,
bool erase);
287 virtual bool detachVertex(Vertex* v);
294 virtual bool changeId(Vertex* v,
int newId);
Container class that implements an interface for adding/removing Data elements in a linked list.
const Data * userData() const
the user data associated with this vertex
void setUserData(Data *obs)
void addUserData(Data *obs)
data packet for a vertex. Extend this class to store in the vertices the potential additional informa...
const Data * next() const
virtual bool read(std::istream &is)=0
read the data from a stream
DataContainer * _dataContainer
void setNext(Data *next_)
virtual HyperGraph::HyperGraphElementType elementType() const
DataContainer * dataContainer()
virtual bool write(std::ostream &os) const =0
write the data to a stream
const DataContainer * dataContainer() const
void setDataContainer(DataContainer *dataContainer_)
virtual HyperGraphElementType elementType() const
void setVertex(size_t i, Vertex *v)
const VertexContainer & vertices() const
VertexContainer _vertices
const Vertex * vertex(size_t i) const
VertexContainer & vertices()
Vertex * vertex(size_t i)
abstract Vertex, your types must derive from that one
int id() const
returns the id
const EdgeSet & edges() const
returns the set of hyper-edges that are leaving/entering in this vertex
virtual HyperGraphElementType elementType() const
virtual void setId(int newId)
EdgeSet & edges()
returns the set of hyper-edges that are leaving/entering in this vertex
HyperGraph & operator=(const HyperGraph &)
std::unordered_map< int, Vertex * > VertexIDMap
std::set< Edge * > EdgeSet
std::set< Vertex * > VertexSet
std::bitset< HyperGraph::HGET_NUM_ELEMS > GraphElemBitset
std::vector< Vertex * > VertexContainer
const EdgeSet & edges() const
HyperGraph(const HyperGraph &)
const VertexIDMap & vertices() const
virtual HyperGraphElementType elementType() const =0
virtual ~HyperGraphElement()