MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / RelaxNode

Method RelaxNode

include/customizer/cell_customizer.hpp:139–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 private:
138 template <typename GraphT>
139 void RelaxNode(const GraphT &graph,
140 const partitioner::CellStorage &cells,
141 const std::vector<bool> &allowed_nodes,
142 const CellMetric &metric,
143 Heap &heap,
144 LevelID level,
145 NodeID node,
146 EdgeWeight weight,
147 EdgeDuration duration,
148 EdgeDistance distance) const
149 {
150 auto first_level = level == 1;
151 BOOST_ASSERT(heap.WasInserted(node));
152
153 if (!first_level)
154 {
155 // if we reaches this node from a clique arc we don't need to scan
156 // the clique arcs again because of the triangle inequality
157 //
158 // d(parent, node) + d(node, v) >= d(parent, v)
159 //
160 // And if there is a path (parent, node, v) there must also be a
161 // clique arc (parent, v) with d(parent, v).
162 if (!heap.GetData(node).from_clique)
163 {
164 // Relax sub-cell nodes
165 auto subcell_id = partition.GetCell(level - 1, node);
166 auto subcell = cells.GetCell(metric, level - 1, subcell_id);
167 auto subcell_destination = subcell.GetDestinationNodes().begin();
168 auto subcell_duration = subcell.GetOutDuration(node).begin();
169 auto subcell_distance = subcell.GetOutDistance(node).begin();
170 for (auto subcell_weight : subcell.GetOutWeight(node))
171 {
172 if (subcell_weight != INVALID_EDGE_WEIGHT)
173 {
174 const NodeID to = *subcell_destination;
175 if (!allowed_nodes[to])
176 {
177 continue;
178 }
179
180 const EdgeWeight to_weight = weight + subcell_weight;
181 const EdgeDuration to_duration = duration + *subcell_duration;
182 const EdgeDistance to_distance = distance + *subcell_distance;
183 if (!heap.WasInserted(to))
184 {
185 heap.Insert(to, to_weight, {true, to_duration, to_distance});
186 }
187 else if (std::tie(to_weight, to_duration, to_distance) <
188 std::tie(heap.GetKey(to),
189 heap.GetData(to).duration,
190 heap.GetData(to).distance))
191 {
192 heap.DecreaseKey(to, to_weight);
193 heap.GetData(to) = {true, to_duration, to_distance};
194 }
195 }
196

Callers

nothing calls this directly

Calls 11

WasInsertedMethod · 0.80
GetOutDurationMethod · 0.80
GetOutDistanceMethod · 0.80
DecreaseKeyMethod · 0.80
GetInternalEdgeRangeMethod · 0.80
GetCellMethod · 0.45
beginMethod · 0.45
GetDestinationNodesMethod · 0.45
GetOutWeightMethod · 0.45
InsertMethod · 0.45
GetTargetMethod · 0.45

Tested by

no test coverage detected