g2o
Loading...
Searching...
No Matches
g2o::HyperGraph Class Reference

#include <hyper_graph.h>

Inheritance diagram for g2o::HyperGraph:

Classes

struct  HyperGraphElement
class  Data
 data packet for a vertex. Extend this class to store in the vertices the potential additional information you need (e.g. images, laser scans, ...). More...
class  DataContainer
 Container class that implements an interface for adding/removing Data elements in a linked list. More...
class  Vertex
 abstract Vertex, your types must derive from that one More...
class  Edge

Public Types

typedef std::bitset< HyperGraph::HGET_NUM_ELEMS > GraphElemBitset
typedef std::set< Edge * > EdgeSet
typedef std::set< Vertex * > VertexSet
typedef std::unordered_map< int, Vertex * > VertexIDMap
typedef std::vector< Vertex * > VertexContainer

Public Member Functions

 HyperGraph ()
 constructs an empty hyper graph
virtual ~HyperGraph ()
 destroys the hyper-graph and all the vertices of the graph
Vertex * vertex (int id)
const Vertex * vertex (int id) const
virtual bool removeVertex (Vertex *v, bool detach=false)
virtual bool removeEdge (Edge *e)
virtual void clear ()
 clears the graph and empties all structures.
const VertexIDMap & vertices () const
VertexIDMap & vertices ()
const EdgeSet & edges () const
EdgeSet & edges ()
virtual bool addVertex (Vertex *v)
virtual bool addEdge (Edge *e)
virtual bool setEdgeVertex (Edge *e, int pos, Vertex *v)
virtual bool mergeVertices (Vertex *vBig, Vertex *vSmall, bool erase)
virtual bool detachVertex (Vertex *v)
virtual bool changeId (Vertex *v, int newId)

Public Attributes

class G2O_CORE_API Data
class G2O_CORE_API DataContainer
class G2O_CORE_API Vertex
class G2O_CORE_API Edge

Static Public Attributes

static const int UnassignedId = -1
static const int InvalidId = -2

Protected Attributes

VertexIDMap _vertices
EdgeSet _edges

Private Member Functions

 HyperGraph (const HyperGraph &)
HyperGraph & operator= (const HyperGraph &)

Detailed Description

Class that models a directed Hyper-Graph. An hyper graph is a graph where an edge can connect one or more nodes. Both Vertices and Edges of an hyper graph derive from the same class HyperGraphElement, thus one can implement generic algorithms that operate transparently on edges or vertices (see HyperGraphAction).

The vertices are uniquely identified by an int id, while the edges are identfied by their pointers.

Definition at line 53 of file hyper_graph.h.

Member Typedef Documentation

◆ EdgeSet

typedef std::set<Edge*> g2o::HyperGraph::EdgeSet

Definition at line 141 of file hyper_graph.h.

◆ GraphElemBitset

typedef std::bitset<HyperGraph::HGET_NUM_ELEMS> g2o::HyperGraph::GraphElemBitset

Definition at line 70 of file hyper_graph.h.

◆ VertexContainer

Definition at line 145 of file hyper_graph.h.

◆ VertexIDMap

typedef std::unordered_map<int, Vertex*> g2o::HyperGraph::VertexIDMap

Definition at line 144 of file hyper_graph.h.

◆ VertexSet

typedef std::set<Vertex*> g2o::HyperGraph::VertexSet

Definition at line 142 of file hyper_graph.h.

Constructor & Destructor Documentation

◆ HyperGraph() [1/2]

g2o::HyperGraph::HyperGraph ( )

constructs an empty hyper graph

Definition at line 204 of file hyper_graph.cpp.

Referenced by g2o::OptimizableGraph::Edge::Edge(), HyperGraph(), operator=(), and g2o::OptimizableGraph::Vertex::Vertex().

◆ ~HyperGraph()

g2o::HyperGraph::~HyperGraph ( )
virtual

destroys the hyper-graph and all the vertices of the graph

Definition at line 219 of file hyper_graph.cpp.

References clear().

◆ HyperGraph() [2/2]

g2o::HyperGraph::HyperGraph ( const HyperGraph & )
inlineprivate

Definition at line 302 of file hyper_graph.h.

References HyperGraph().

Member Function Documentation

◆ addEdge()

bool g2o::HyperGraph::addEdge ( Edge * e)
virtual

Adds an edge to the graph. If the edge is already in the graph, it does nothing and returns false. Otherwise it returns true.

Reimplemented in g2o::OptimizableGraph.

Definition at line 93 of file hyper_graph.cpp.

References _edges, and g2o::HyperGraph::Edge::vertices().

Referenced by g2o::OptimizableGraph::addEdge().

◆ addVertex()

bool g2o::HyperGraph::addVertex ( Vertex * v)
virtual

adds a vertex to the graph. The id of the vertex should be set before invoking this function. the function fails if another vertex with the same id is already in the graph. returns true, on success, or false on failure.

Reimplemented in g2o::OptimizableGraph.

Definition at line 75 of file hyper_graph.cpp.

References _vertices, and g2o::HyperGraph::Vertex::id().

Referenced by g2o::OptimizableGraph::addVertex().

◆ changeId()

bool g2o::HyperGraph::changeId ( Vertex * v,
int newId )
virtual

changes the id of a vertex already in the graph, and updates the bookkeeping @ returns false if the vertex is not in the graph;

Definition at line 84 of file hyper_graph.cpp.

References _vertices, g2o::HyperGraph::Vertex::id(), g2o::HyperGraph::Vertex::setId(), and vertex().

◆ clear()

void g2o::HyperGraph::clear ( )
virtual

clears the graph and empties all structures.

Reimplemented in g2o::SparseOptimizer.

Definition at line 206 of file hyper_graph.cpp.

References _edges, and _vertices.

Referenced by g2o::SparseOptimizer::clear(), g2o::OptimizableGraph::clearParameters(), ~HyperGraph(), and g2o::OptimizableGraph::~OptimizableGraph().

◆ detachVertex()

bool g2o::HyperGraph::detachVertex ( Vertex * v)
virtual

◆ edges() [1/2]

EdgeSet & g2o::HyperGraph::edges ( )
inline
Returns
the set of edges of the hyper graph

Definition at line 255 of file hyper_graph.h.

References _edges.

◆ edges() [2/2]

◆ mergeVertices()

bool g2o::HyperGraph::mergeVertices ( Vertex * vBig,
Vertex * vSmall,
bool erase )
virtual

merges two (valid) vertices, adjusts the bookkeeping and relabels all edges. the observations of vSmall are retargeted to vBig. If erase = true, vSmall is deleted from the graph repeatedly calls setEdgeVertex(...)

Definition at line 132 of file hyper_graph.cpp.

References _vertices, g2o::HyperGraph::Vertex::edges(), g2o::HyperGraph::Vertex::id(), removeVertex(), setEdgeVertex(), g2o::HyperGraph::Edge::vertex(), and g2o::HyperGraph::Edge::vertices().

◆ operator=()

HyperGraph & g2o::HyperGraph::operator= ( const HyperGraph & )
inlineprivate

Definition at line 303 of file hyper_graph.h.

References HyperGraph().

◆ removeEdge()

bool g2o::HyperGraph::removeEdge ( Edge * e)
virtual

removes a vertex from the graph. Returns true on success (edge was present)

Definition at line 188 of file hyper_graph.cpp.

References _edges, g2o::HyperGraph::Vertex::edges(), g2o::release(), and g2o::HyperGraph::Edge::vertices().

Referenced by removeVertex().

◆ removeVertex()

bool g2o::HyperGraph::removeVertex ( Vertex * v,
bool detach = false )
virtual

removes a vertex from the graph. Returns true on success (vertex was present)

Reimplemented in g2o::SparseOptimizer.

Definition at line 166 of file hyper_graph.cpp.

References _vertices, detachVertex(), g2o::HyperGraph::Vertex::edges(), g2o::HyperGraph::Vertex::id(), g2o::release(), and removeEdge().

Referenced by mergeVertices(), and g2o::SparseOptimizer::removeVertex().

◆ setEdgeVertex()

bool g2o::HyperGraph::setEdgeVertex ( HyperGraph::Edge * e,
int pos,
HyperGraph::Vertex * v )
virtual

Sets the vertex in position "pos" within the edge and keeps the bookkeeping consistent. If v ==0, the vertex is set to "invalid"

Reimplemented in g2o::OptimizableGraph.

Definition at line 123 of file hyper_graph.cpp.

References g2o::HyperGraph::Vertex::edges(), g2o::HyperGraph::Edge::setVertex(), and g2o::HyperGraph::Edge::vertex().

Referenced by detachVertex(), mergeVertices(), and g2o::OptimizableGraph::setEdgeVertex().

◆ vertex() [1/2]

HyperGraph::Vertex * g2o::HyperGraph::vertex ( int id)

returns a vertex id in the hyper-graph, or 0 if the vertex id is not present

Definition at line 63 of file hyper_graph.cpp.

References _vertices.

Referenced by changeId(), g2o::OptimizableGraph::vertex(), and g2o::OptimizableGraph::vertex().

◆ vertex() [2/2]

const HyperGraph::Vertex * g2o::HyperGraph::vertex ( int id) const

returns a vertex id in the hyper-graph, or 0 if the vertex id is not present

Definition at line 69 of file hyper_graph.cpp.

References _vertices.

◆ vertices() [1/2]

VertexIDMap & g2o::HyperGraph::vertices ( )
inline
Returns
the map id -> vertex where the vertices are stored

Definition at line 250 of file hyper_graph.h.

References _vertices.

◆ vertices() [2/2]

Member Data Documentation

◆ _edges

EdgeSet g2o::HyperGraph::_edges
protected

Definition at line 298 of file hyper_graph.h.

Referenced by addEdge(), clear(), edges(), edges(), and removeEdge().

◆ _vertices

◆ Data

class G2O_CORE_API g2o::HyperGraph::Data

Definition at line 72 of file hyper_graph.h.

◆ DataContainer

class G2O_CORE_API g2o::HyperGraph::DataContainer

Definition at line 73 of file hyper_graph.h.

◆ Edge

class G2O_CORE_API g2o::HyperGraph::Edge

Definition at line 75 of file hyper_graph.h.

◆ InvalidId

const int g2o::HyperGraph::InvalidId = -2
static

Definition at line 68 of file hyper_graph.h.

◆ UnassignedId

const int g2o::HyperGraph::UnassignedId = -1
static

Definition at line 67 of file hyper_graph.h.

Referenced by g2o::OptimizableGraph::saveEdge().

◆ Vertex

class G2O_CORE_API g2o::HyperGraph::Vertex

Definition at line 74 of file hyper_graph.h.


The documentation for this class was generated from the following files: