NDEVR
API Documentation
hyper_dijkstra.h
1// g2o - General Graph Optimization
2// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright notice,
10// this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27#ifndef G2O_AIS_GENERAL_DIJKSTRA_HH
28#define G2O_AIS_GENERAL_DIJKSTRA_HH
29
30#include <limits>
31#include "Base/Headers/Dictionary.h"
32#include "hyper_graph.h"
33
34namespace NDEVR
35{
36
40 struct CostFunction {
47 virtual ~CostFunction() { }
48 };
49
51 struct TreeAction {
64 virtual g_type perform(HyperGraph::HGVertex* v, HyperGraph::HGVertex* vParent, HyperGraph::HGEdge* e, g_type distance);
65 };
66
67
99
110
120 g_type maxDistance=std::numeric_limits< g_type >::max(),
121 g_type comparisonConditioner=1e-3,
122 bool directed=false,
123 g_type maxEdgeCost=std::numeric_limits< g_type >::max());
124
134 g_type maxDistance=std::numeric_limits< g_type >::max(),
135 g_type comparisonConditioner=1e-3,
136 bool directed=false,
137 g_type maxEdgeCost=std::numeric_limits< g_type >::max());
138
139
142 static void computeTree(AdjacencyMap& amap);
147 static void visitAdjacencyMap(AdjacencyMap& amap, TreeAction* action, bool useDistance=false);
159 Set<HyperGraph::HGVertex*>& startingSet,
161 HyperDijkstra::CostFunction* cost, g_type distance, g_type comparisonConditioner,
162 g_type maxEdgeCost=std::numeric_limits< g_type >::max() );
163
164 protected:
166 void reset();
167
171 };
172
182
183}
184#endif
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Abstract Edge class.
Definition hyper_graph.h:54
abstract Vertex, your types must derive from that one
Definition hyper_graph.h:28
Class that models a directed Hyper-Graph.
Definition hyper_graph.h:20
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
Definition Set.h:59
The primary namespace for the NDEVR SDK.
HyperGraph::HGEdge * _edge
The edge connecting parent to child.
HyperGraph::HGEdge * edge() const
Returns the connecting edge.
g_type distance() const
Returns the distance from the source vertex.
AdjacencyMapEntry(HyperGraph::HGVertex *_child=0, HyperGraph::HGVertex *_parent=0, HyperGraph::HGEdge *_edge=0, g_type _distance=std::numeric_limits< g_type >::max())
Constructs an adjacency map entry.
Set< HyperGraph::HGVertex * > & children()
Returns the mutable set of child vertices.
HyperGraph::HGVertex * parent() const
Returns the parent vertex.
const Set< HyperGraph::HGVertex * > & children() const
Returns the const set of child vertices.
HyperGraph::HGVertex * _child
The child vertex in the shortest-path tree.
HyperGraph::HGVertex * child() const
Returns the child vertex.
HyperGraph::HGVertex * _parent
The parent vertex in the shortest-path tree.
g_type _distance
Accumulated distance from the source.
Set< HyperGraph::HGVertex * > _children
Set of child vertices reachable from this entry.
Abstract cost function for weighting edges during traversal.
virtual g_type operator()(HyperGraph::HGEdge *e, HyperGraph::HGVertex *from, HyperGraph::HGVertex *to)=0
Evaluates the cost of traversing an edge between two vertices.
Action interface executed when visiting the shortest-path tree.
virtual g_type perform(HyperGraph::HGVertex *v, HyperGraph::HGVertex *vParent, HyperGraph::HGEdge *e, g_type distance)
Performs an action on a vertex in the tree with distance information.
virtual g_type perform(HyperGraph::HGVertex *v, HyperGraph::HGVertex *vParent, HyperGraph::HGEdge *e)
Performs an action on a vertex in the tree.
void reset()
Resets the adjacency map and visited set.
static void connectedSubset(Set< HyperGraph::HGVertex * > &connected, Set< HyperGraph::HGVertex * > &visited, Set< HyperGraph::HGVertex * > &startingSet, HyperGraph *g, HyperGraph::HGVertex *v, HyperDijkstra::CostFunction *cost, g_type distance, g_type comparisonConditioner, g_type maxEdgeCost=std::numeric_limits< g_type >::max())
Finds the connected subset of vertices reachable from a given vertex within a distance.
static void computeTree(AdjacencyMap &amap)
Builds the tree structure from the adjacency map.
HyperGraph * _graph
The graph being searched.
void shortestPaths(Set< HyperGraph::HGVertex * > &vset, HyperDijkstra::CostFunction *cost, g_type maxDistance=std::numeric_limits< g_type >::max(), g_type comparisonConditioner=1e-3, bool directed=false, g_type maxEdgeCost=std::numeric_limits< g_type >::max())
Computes shortest paths from a set of source vertices.
Set< HyperGraph::HGVertex * > _visited
Set of visited vertices.
static void visitAdjacencyMap(AdjacencyMap &amap, TreeAction *action, bool useDistance=false)
Visits all entries in the adjacency map using the given tree action.
Set< HyperGraph::HGVertex * > & visited()
Returns the set of visited vertices.
Dictionary< HyperGraph::HGVertex *, AdjacencyMapEntry > AdjacencyMap
Map from vertex to its adjacency entry.
AdjacencyMap _adjacencyMap
Map from vertex to adjacency entry.
AdjacencyMap & adjacencyMap()
Returns the adjacency map.
HyperDijkstra(HyperGraph *g)
Constructs a HyperDijkstra for the given graph.
HyperGraph * graph()
Returns the underlying graph.
void shortestPaths(HyperGraph::HGVertex *v, HyperDijkstra::CostFunction *cost, g_type maxDistance=std::numeric_limits< g_type >::max(), g_type comparisonConditioner=1e-3, bool directed=false, g_type maxEdgeCost=std::numeric_limits< g_type >::max())
Computes shortest paths from a single source vertex.
Cost function that assigns uniform cost of 1.0 to every edge.
virtual g_type operator()(HyperGraph::HGEdge *edge, HyperGraph::HGVertex *from, HyperGraph::HGVertex *to)
Returns 1.0 for any edge, implementing uniform cost.