Fast map matching  0.1.0
composite_graph.hpp
1 
11 #ifndef FMM_COMPOSITEGRAPH_HPP
12 #define FMM_COMPOSITEGRAPH_HPP
13 
14 #include "network/network_graph.hpp"
15 
16 namespace FMM {
17 
18 namespace MM {
19 
23 typedef unsigned int DummyIndex;
24 
31 class DummyGraph {
32  public:
36  DummyGraph();
45  DummyGraph(const Traj_Candidates &traj_candidates);
46 
52 
57  const NETWORK::Graph_T &get_boost_graph() const;
58 
62  int get_num_vertices() const;
73  bool containNodeIndex(NETWORK::NodeIndex external_index) const;
74 
82 
92  DummyIndex get_internal_index(NETWORK::NodeIndex external_index) const;
102  NETWORK::NodeIndex target, double cost) const;
106  void print_node_index_map() const;
107  protected:
116  void add_edge(NETWORK::NodeIndex source, NETWORK::NodeIndex target,
117  NETWORK::EdgeIndex edge_index, double cost);
118  private:
119  static constexpr double DOUBLE_MIN = 1e-6;
121  std::vector<NETWORK::NodeIndex> external_index_vec;
122  std::unordered_map<NETWORK::NodeIndex, DummyIndex> internal_index_map;
123 };
124 
130  double cost;
131 };
132 
137  public:
144  const DummyGraph &dg);
149  unsigned int get_dummy_node_start_index() const;
155  NETWORK::NodeIndex v, double cost) const;
160  NETWORK::NodeIndex v, double cost) const;
164  std::vector<CompEdgeProperty> out_edges(NETWORK::NodeIndex u) const;
169  bool check_dummy_node(NETWORK::NodeIndex u) const;
170  private:
171  const NETWORK::NetworkGraph &g_;
172  const DummyGraph &dg_;
173  unsigned int num_vertices;
174 };
175 }
176 }
177 #endif
FMM::MM::DummyGraph::get_edge_index
int get_edge_index(NETWORK::NodeIndex source, NETWORK::NodeIndex target, double cost) const
Get the edge index in the original network graph.
Definition: composite_graph.cpp:64
FMM::MM::DummyGraph::print_node_index_map
void print_node_index_map() const
Print the mapping from dummy index to node index.
Definition: composite_graph.cpp:87
FMM::NETWORK::Graph_T
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::no_property, EdgeProperty > Graph_T
Boost graph type.
Definition: graph.hpp:36
FMM::MM::Traj_Candidates
std::vector< Point_Candidates > Traj_Candidates
trajectory candidates
Definition: mm_type.hpp:38
FMM::MM::DummyGraph::get_external_index
NETWORK::NodeIndex get_external_index(DummyIndex inner_index) const
Get the NodeIndex of a node according to the inner index of the dummy graph.
Definition: composite_graph.cpp:56
FMM::MM::DummyGraph::DummyGraph
DummyGraph()
Default constructor of dummy graph.
Definition: composite_graph.cpp:9
FMM::MM::DummyGraph::get_graph_ptr
NETWORK::Graph_T * get_graph_ptr()
Get the inner graph data.
Definition: composite_graph.cpp:40
FMM::MM::CompositeGraph::get_dummy_node_start_index
unsigned int get_dummy_node_start_index() const
Get the starting node index corresponding to the the first dummy node in the dummy graph.
Definition: composite_graph.cpp:128
FMM::MM::CompositeGraph::get_edge_index
int get_edge_index(NETWORK::NodeIndex u, NETWORK::NodeIndex v, double cost) const
Get edge index from node index u,v and cost.
Definition: composite_graph.cpp:132
FMM::MM::CompEdgeProperty::v
NETWORK::NodeIndex v
Target node index.
Definition: composite_graph.hpp:129
FMM::MM::DummyGraph::add_edge
void add_edge(NETWORK::NodeIndex source, NETWORK::NodeIndex target, NETWORK::EdgeIndex edge_index, double cost)
Add an edge to the dummy graph.
Definition: composite_graph.cpp:94
FMM
Fast map matching.
Definition: geom_algorithm.hpp:17
FMM::MM::CompositeGraph::out_edges
std::vector< CompEdgeProperty > out_edges(NETWORK::NodeIndex u) const
Get out edges leaving a node u in the composite graph.
Definition: composite_graph.cpp:146
FMM::NETWORK::EdgeID
int EdgeID
Edge ID in the network, can be discontinuous int.
Definition: type.hpp:23
FMM::MM::CompositeGraph::CompositeGraph
CompositeGraph(const NETWORK::NetworkGraph &g, const DummyGraph &dg)
Constructor.
Definition: composite_graph.cpp:123
FMM::NETWORK::NetworkGraph
Graph class of the network.
Definition: network_graph.hpp:33
FMM::MM::DummyGraph::get_boost_graph
const NETWORK::Graph_T & get_boost_graph() const
Get a const reference to the inner graph data.
Definition: composite_graph.cpp:44
FMM::MM::DummyGraph::get_internal_index
DummyIndex get_internal_index(NETWORK::NodeIndex external_index) const
Get the internal index of a node in dummy graph If the node is not contained in the dummy graph,...
Definition: composite_graph.cpp:60
FMM::MM::DummyGraph
A graph containing dummy nodes and edges used in map matching.
Definition: composite_graph.hpp:31
FMM::MM::CompositeGraph
Composite Graph as a wrapper of network graph and dummy graph.
Definition: composite_graph.hpp:136
FMM::MM::CompositeGraph::get_edge_id
NETWORK::EdgeID get_edge_id(NETWORK::NodeIndex u, NETWORK::NodeIndex v, double cost) const
Get edge id from node index u,v and cost.
Definition: composite_graph.cpp:141
FMM::MM::DummyGraph::containNodeIndex
bool containNodeIndex(NETWORK::NodeIndex external_index) const
Check if a node is contained in the dummy graph.
Definition: composite_graph.cpp:52
FMM::NETWORK::NodeIndex
unsigned int NodeIndex
Node Index in the network, range from [0,num_vertices-1 ].
Definition: type.hpp:24
FMM::NETWORK::EdgeIndex
unsigned int EdgeIndex
Edge Index in the network, range from [0,num_edges-1 ].
Definition: type.hpp:26
FMM::MM::DummyIndex
unsigned int DummyIndex
This is an index used in the dummy graph.
Definition: composite_graph.hpp:23
FMM::MM::DummyGraph::get_num_vertices
int get_num_vertices() const
Get the number of vertices in the dummy graph.
Definition: composite_graph.cpp:48
FMM::MM::CompEdgeProperty
Property of an edge in the composite graph.
Definition: composite_graph.hpp:128
FMM::MM::CompEdgeProperty::cost
double cost
Cost of an edge.
Definition: composite_graph.hpp:130
FMM::MM::CompositeGraph::check_dummy_node
bool check_dummy_node(NETWORK::NodeIndex u) const
Check if a node u is dummy node, namely representing a candidate point.
Definition: composite_graph.cpp:174