hyper_dijkstra.h
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
00003 // 
00004 // g2o is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as published
00006 // by the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // g2o is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef _AIS_GENERAL_DIJKSTRA_HH
00018 #define _AIS_GENERAL_DIJKSTRA_HH
00019 
00020 #include <map>
00021 #include <set>
00022 #include <limits>
00023 #include "hyper_graph.h"
00024 
00025 namespace g2o{
00026 
00027   struct HyperDijkstra{
00028     struct CostFunction {
00029       virtual double operator() (HyperGraph::Edge* e, HyperGraph::Vertex* from, HyperGraph::Vertex* to)=0;
00030     };
00031 
00032     struct TreeAction {
00033       virtual double perform(HyperGraph::Vertex* v, HyperGraph::Vertex* vParent, HyperGraph::Edge* e);
00034       virtual double perform(HyperGraph::Vertex* v, HyperGraph::Vertex* vParent, HyperGraph::Edge* e, double distance);
00035     };
00036 
00037     
00038     struct AdjacencyMapEntry{
00039       friend struct HyperDijkstra;
00040       AdjacencyMapEntry(HyperGraph::Vertex* _child=0, 
00041           HyperGraph::Vertex* _parent=0, 
00042           HyperGraph::Edge* _edge=0, 
00043           double _distance=std::numeric_limits<double>::max());
00044       HyperGraph::Vertex* child() const {return _child;}
00045       HyperGraph::Vertex* parent() const {return _parent;}
00046       HyperGraph::Edge* edge() const {return _edge;}
00047       double distance() const {return _distance;}
00048       HyperGraph::VertexSet& children() {return _children;}
00049       const HyperGraph::VertexSet& children() const {return _children;}
00050       protected:
00051       HyperGraph::Vertex* _child;
00052       HyperGraph::Vertex* _parent;
00053       HyperGraph::Edge* _edge;
00054       double _distance;
00055       HyperGraph::VertexSet _children;
00056     };
00057 
00058     typedef std::map<HyperGraph::Vertex*, AdjacencyMapEntry> AdjacencyMap;
00059     HyperDijkstra(HyperGraph* g);
00060     HyperGraph::VertexSet& visited() {return _visited; }
00061     AdjacencyMap& adjacencyMap() {return _adjacencyMap; }
00062     HyperGraph* graph() {return _graph;} 
00063 
00064     void shortestPaths(HyperGraph::Vertex* v, 
00065            HyperDijkstra::CostFunction* cost, 
00066            double maxDistance=std::numeric_limits< double >::max(), 
00067            double comparisonConditioner=1e-3, 
00068            bool directed=false,
00069            double maxEdgeCost=std::numeric_limits< double >::max());
00070 
00071     void shortestPaths(HyperGraph::VertexSet& vset, 
00072            HyperDijkstra::CostFunction* cost, 
00073            double maxDistance=std::numeric_limits< double >::max(), 
00074            double comparisonConditioner=1e-3, 
00075            bool directed=false,
00076            double maxEdgeCost=std::numeric_limits< double >::max());
00077 
00078 
00079     static void computeTree(AdjacencyMap& amap);
00080     static void visitAdjacencyMap(AdjacencyMap& amap, TreeAction* action, bool useDistance=false);
00081 
00082   protected:
00083     void reset();
00084 
00085     AdjacencyMap _adjacencyMap;
00086     HyperGraph::VertexSet _visited;
00087     HyperGraph* _graph;
00088   };
00089 
00090   void connectedSubset(HyperGraph::VertexSet& connected, HyperGraph::VertexSet& visited, 
00091            HyperGraph::VertexSet& startingSet, 
00092            HyperGraph* g, HyperGraph::Vertex* v,
00093            HyperDijkstra::CostFunction* cost, double distance, double comparisonConditioner,
00094            double maxEdgeCost=std::numeric_limits< double >::max() );
00095 
00096 
00097 
00098   struct UniformCostFunction: public HyperDijkstra::CostFunction {
00099     virtual double operator ()(HyperGraph::Edge* edge, HyperGraph::Vertex* from, HyperGraph::Vertex* to);
00100   };
00101 
00102   
00103 
00104 }
00105 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:24