g2o
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
g2o::BackBoneTreeAction Struct Reference

#include <backbone_tree_action.h>

Inheritance diagram for g2o::BackBoneTreeAction:
Inheritance graph
[legend]
Collaboration diagram for g2o::BackBoneTreeAction:
Collaboration graph
[legend]

Public Member Functions

 BackBoneTreeAction (SparseOptimizer *optimizer, std::string vertexTag, int level, int step)
 
void init ()
 initializes the visit and clears the internal structures More...
 
VertexStarMapvertexStarMap ()
 map vertex->star. Contains the most recent vertex assignment More...
 
VertexStarMultimapvertexStarMultiMap ()
 multimap vertex->star. Contains all the vertex assignments to all stars More...
 
HyperGraph::EdgeSetfreeEdges ()
 edges that are not yet assigned to any star More...
 
virtual double perform (HyperGraph::Vertex *v, HyperGraph::Vertex *vParent, HyperGraph::Edge *e, double distance)
 
- Public Member Functions inherited from g2o::HyperDijkstra::TreeAction
virtual double perform (HyperGraph::Vertex *v, HyperGraph::Vertex *vParent, HyperGraph::Edge *e)
 

Protected Member Functions

void addToMap (Star *s, HyperGraph::Vertex *v)
 
StargetStar (HyperGraph::Vertex *v)
 
bool fillStar (Star *s, HyperGraph::Edge *e_)
 helper function that adds to a star an edge and all its vertices More...
 

Protected Attributes

SparseOptimizer_optimizer
 
std::string _vertexTag
 
int _level
 
int _step
 
VertexStarMap _vsMap
 
VertexStarMultimap _vsMmap
 
HyperGraph::EdgeSet _freeEdges
 
Factory_factory
 

Detailed Description

Dijkstra traversal action that constructs a backbone skeleton on the graph. It assumes that the traversal contains only edges and vertices belonging to classes that can be used to construct a backbone. After a visit is invoked, it returns vector of stars to which the backbone nodes have been assigned

Definition at line 20 of file backbone_tree_action.h.

Constructor & Destructor Documentation

g2o::BackBoneTreeAction::BackBoneTreeAction ( SparseOptimizer optimizer,
std::string  vertexTag,
int  level,
int  step 
)

creates a tree action for constructing the backbone

Parameters
optimizerthe optimizer on which the stars are constructed
vertexTagthe tag of the vertices to use as backbone nodes
levelthe level of the lowLevelEdges of the stars in the backbone
stepdepth in tree after which a new star is initialized

Definition at line 9 of file backbone_tree_action.cpp.

References _factory, init(), and g2o::Factory::instance().

9  :
10  _optimizer(optimizer),
11  _vertexTag(vertexTag),
12  _level(level),
13  _step(step) {
15  init();
16  }
static Factory * instance()
return the instance
Definition: factory.cpp:61
SparseOptimizer * _optimizer
void init()
initializes the visit and clears the internal structures
yylloc step()

Member Function Documentation

void g2o::BackBoneTreeAction::addToMap ( Star s,
HyperGraph::Vertex v 
)
protected

helper function for adding a vertex to a star. If the vertex is already in _vertexToEdgeMap it replaces the associated star. _vertexStarMultimap is only augmented, thus it contains all associations

Parameters
sthe star
vthe vertex

Definition at line 56 of file backbone_tree_action.cpp.

References g2o::Star::_lowLevelVertices, _vsMap, and _vsMmap.

Referenced by freeEdges(), and perform().

56  {
58  VertexStarMap::iterator it=_vsMap.find(v);
59  if (it!=_vsMap.end())
60  it->second = s;
61  else
62  _vsMap.insert(make_pair(v,s));
63  _vsMmap.insert(make_pair(v,s));
64  s->_lowLevelVertices.insert(v);
65  }
VertexStarMultimap _vsMmap
class G2O_CORE_API Vertex
bool g2o::BackBoneTreeAction::fillStar ( Star s,
HyperGraph::Edge e_ 
)
protected

helper function that adds to a star an edge and all its vertices

Definition at line 75 of file backbone_tree_action.cpp.

References _freeEdges, g2o::Star::_lowLevelEdges, g2o::Star::_lowLevelVertices, and g2o::HyperGraph::Edge::vertices().

Referenced by freeEdges(), and perform().

75  {
77  HyperGraph::EdgeSet::iterator it=_freeEdges.find(e);
78  if (it!=_freeEdges.end()) {
79  _freeEdges.erase(it);
80  s->_lowLevelEdges.insert(e);
81  for (size_t i=0; i<e->vertices().size(); i++){
82  s->_lowLevelVertices.insert(e->vertices()[i]);
83  }
84  return true;
85  }
86  return false;
87  }
class G2O_CORE_API Edge
HyperGraph::EdgeSet _freeEdges
HyperGraph::EdgeSet& g2o::BackBoneTreeAction::freeEdges ( )
inline

edges that are not yet assigned to any star

Definition at line 38 of file backbone_tree_action.h.

References _freeEdges, addToMap(), fillStar(), getStar(), and perform().

38 {return _freeEdges;}
HyperGraph::EdgeSet _freeEdges
Star * g2o::BackBoneTreeAction::getStar ( HyperGraph::Vertex v)
protected

helper function to retrieve the most recent star of a vertex.

Parameters
vthe vertex

Definition at line 67 of file backbone_tree_action.cpp.

References _vsMap.

Referenced by freeEdges(), and perform().

67  {
69  VertexStarMap::iterator it=_vsMap.find(v);
70  if (it==_vsMap.end())
71  return 0;
72  return it->second;
73  }
class G2O_CORE_API Vertex
void g2o::BackBoneTreeAction::init ( )

initializes the visit and clears the internal structures

Definition at line 18 of file backbone_tree_action.cpp.

References _freeEdges, _level, _optimizer, _vsMap, _vsMmap, g2o::HyperGraph::edges(), and g2o::OptimizableGraph::Edge::level().

Referenced by BackBoneTreeAction().

18  {
19  _vsMap.clear();
20  _vsMmap.clear();
21  _freeEdges.clear();
22  for (HyperGraph::EdgeSet::iterator it=_optimizer->edges().begin(); it!=_optimizer->edges().end(); it++){
24  if (e->level()==_level) {
25  _freeEdges.insert(e);
26  }
27  }
28  }
VertexStarMultimap _vsMmap
SparseOptimizer * _optimizer
const EdgeSet & edges() const
Definition: hyper_graph.h:230
class G2O_CORE_API Edge
HyperGraph::EdgeSet _freeEdges
double g2o::BackBoneTreeAction::perform ( HyperGraph::Vertex v,
HyperGraph::Vertex vParent,
HyperGraph::Edge e,
double  distance 
)
virtual

action to be performed during the descent of the dijkstra tree. it constructs stars according to the dijkstra tree A new star is created every time the depth increases of _step.

Parameters
vthe vertex
vParentthe parent vertex
ethe edge between v and its parent
distancethe depth in the tree

Reimplemented from g2o::HyperDijkstra::TreeAction.

Definition at line 30 of file backbone_tree_action.cpp.

References _factory, g2o::Star::_gauge, _level, _optimizer, _step, _vertexTag, addToMap(), fillStar(), getStar(), and g2o::Factory::tag().

Referenced by freeEdges().

33  {
34  int depth=(int) distance;
35  if (_factory->tag(v)!= _vertexTag)
36  return 0;
37  Star* parentStar=getStar(vParent);
38  if (! parentStar){
39  parentStar=new Star(_level+1,_optimizer);
40  addToMap(parentStar, vParent);
41  parentStar->_gauge.insert(vParent);
42  }
43  addToMap(parentStar,v);
44  fillStar(parentStar, e);
45 
46  // every _step levels you go down in the tree, create a new star
47  if (depth && ! (depth%_step )){
48  Star* star=new Star(_level+1, _optimizer);
49  addToMap(star,v);
50  star->_gauge.insert(v);
51  }
52  return 1;
53  }
SparseOptimizer * _optimizer
const std::string & tag(const HyperGraph::HyperGraphElement *v) const
return the TAG given a vertex
Definition: factory.cpp:157
Star * getStar(HyperGraph::Vertex *v)
void addToMap(Star *s, HyperGraph::Vertex *v)
bool fillStar(Star *s, HyperGraph::Edge *e_)
helper function that adds to a star an edge and all its vertices
VertexStarMap& g2o::BackBoneTreeAction::vertexStarMap ( )
inline

map vertex->star. Contains the most recent vertex assignment

Definition at line 34 of file backbone_tree_action.h.

References _vsMap.

34 {return _vsMap;}
VertexStarMultimap& g2o::BackBoneTreeAction::vertexStarMultiMap ( )
inline

multimap vertex->star. Contains all the vertex assignments to all stars

Definition at line 36 of file backbone_tree_action.h.

References _vsMmap.

36 {return _vsMmap;}
VertexStarMultimap _vsMmap

Member Data Documentation

Factory* g2o::BackBoneTreeAction::_factory
protected

Definition at line 78 of file backbone_tree_action.h.

Referenced by BackBoneTreeAction(), and perform().

HyperGraph::EdgeSet g2o::BackBoneTreeAction::_freeEdges
protected

Definition at line 77 of file backbone_tree_action.h.

Referenced by fillStar(), freeEdges(), and init().

int g2o::BackBoneTreeAction::_level
protected

Definition at line 72 of file backbone_tree_action.h.

Referenced by init(), and perform().

SparseOptimizer* g2o::BackBoneTreeAction::_optimizer
protected

Definition at line 70 of file backbone_tree_action.h.

Referenced by init(), and perform().

int g2o::BackBoneTreeAction::_step
protected

Definition at line 73 of file backbone_tree_action.h.

Referenced by perform().

std::string g2o::BackBoneTreeAction::_vertexTag
protected

Definition at line 71 of file backbone_tree_action.h.

Referenced by perform().

VertexStarMap g2o::BackBoneTreeAction::_vsMap
protected

Definition at line 75 of file backbone_tree_action.h.

Referenced by addToMap(), getStar(), init(), and vertexStarMap().

VertexStarMultimap g2o::BackBoneTreeAction::_vsMmap
protected

Definition at line 76 of file backbone_tree_action.h.

Referenced by addToMap(), init(), and vertexStarMultiMap().


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