61 for (
size_t i=0; i<
_vertices.size(); i++){
80 VertexIDMap::iterator it=
_vertices.find(
id);
88 VertexIDMap::const_iterator it=
_vertices.find(
id);
119 std::pair<EdgeSet::iterator, bool> result =
_edges.insert(e);
122 for (std::vector<Vertex*>::iterator it = e->
vertices().begin(); it != e->
vertices().end(); ++it) {
125 v->
edges().insert(e);
134 vOld->
edges().erase(e);
137 v->
edges().insert(e);
143 VertexIDMap::iterator it=
_vertices.find(vBig->
id());
153 for(EdgeSet::iterator it=tmp.begin(); it!=tmp.end(); ++it){
155 for (
size_t i=0; i<e->
vertices().size(); i++){
170 assert(it->second==v);
172 for (EdgeSet::iterator it=tmp.begin(); it!=tmp.end(); ++it){
174 for (
size_t i = 0 ; i<e->
vertices().size(); i++){
187 assert (0 &&
"inconsistency in detaching vertex, ");
193 assert(it->second==v);
196 for (EdgeSet::iterator it=tmp.begin(); it!=tmp.end(); ++it){
198 assert(0 &&
"error in erasing vertex");
208 EdgeSet::iterator it =
_edges.find(e);
212 for (std::vector<Vertex*>::iterator vit = e->
vertices().begin(); vit != e->
vertices().end(); ++vit) {
216 it = v->
edges().find(e);
217 assert(it!=v->
edges().end());
218 v->
edges().erase(it);
233 for (EdgeSet::iterator it=
_edges.begin(); it!=
_edges.end(); ++it)
int id() const
returns the id
const Vertex * vertex(size_t i) const
virtual bool removeVertex(Vertex *v, bool detach=false)
removes a vertex from the graph. Returns true on success (vertex was present)
virtual bool changeId(Vertex *v, int newId)
Vertex * vertex(int id)
returns a vertex id in the hyper-graph, or 0 if the vertex id is not present
void setVertex(size_t i, Vertex *v)
DataContainer * _dataContainer
virtual bool addEdge(Edge *e)
virtual void setId(int newId)
virtual bool setEdgeVertex(Edge *e, int pos, Vertex *v)
std::set< Edge * > EdgeSet
int numUndefinedVertices() const
const VertexContainer & vertices() const
const EdgeSet & edges() const
returns the set of hyper-edges that are leaving/entering in this vertex
Vertex(int id=InvalidId)
creates a vertex having an ID specified by the argument
virtual void clear()
clears the graph and empties all structures.
abstract Vertex, your types must derive from that one
virtual bool detachVertex(Vertex *v)
virtual bool addVertex(Vertex *v)
virtual void resize(size_t size)
virtual bool mergeVertices(Vertex *vBig, Vertex *vSmall, bool erase)
HyperGraph()
constructs an empty hyper graph
virtual bool removeEdge(Edge *e)
removes a vertex from the graph. Returns true on success (edge was present)
Edge(int id=InvalidId)
creates and empty edge with no vertices
virtual ~HyperGraph()
destroys the hyper-graph and all the vertices of the graph
VertexContainer _vertices