fix: do not add duplicate edges
Previously duplicate edges were added if their weight was worse.
This commit is contained in:
parent
4e897aad50
commit
a2a2cf84d1
@ -402,7 +402,7 @@ class GraphContractor
|
||||
|
||||
unsigned current_level = 0;
|
||||
bool flushed_contractor = false;
|
||||
while (number_of_nodes > 2 &&
|
||||
while (remaining_nodes.size() > 1 &&
|
||||
number_of_contracted_nodes < static_cast<NodeID>(number_of_nodes * core_factor))
|
||||
{
|
||||
if (!flushed_contractor && (number_of_contracted_nodes >
|
||||
@ -513,16 +513,20 @@ class GraphContractor
|
||||
{
|
||||
const EdgeID current_edge_ID =
|
||||
contractor_graph->FindEdge(edge.source, edge.target);
|
||||
if (current_edge_ID < contractor_graph->EndEdges(edge.source))
|
||||
if (current_edge_ID != SPECIAL_EDGEID)
|
||||
{
|
||||
ContractorGraph::EdgeData ¤t_data =
|
||||
contractor_graph->GetEdgeData(current_edge_ID);
|
||||
if (current_data.shortcut && edge.data.forward == current_data.forward &&
|
||||
edge.data.backward == current_data.backward &&
|
||||
edge.data.weight < current_data.weight)
|
||||
edge.data.backward == current_data.backward)
|
||||
{
|
||||
// found a duplicate edge with smaller weight, update it.
|
||||
current_data = edge.data;
|
||||
// we found a duplicate edge
|
||||
// if weight of new one is smaller, update old one
|
||||
if (edge.data.weight < current_data.weight)
|
||||
{
|
||||
current_data = edge.data;
|
||||
}
|
||||
// don't insert duplicates
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -559,7 +563,7 @@ class GraphContractor
|
||||
|
||||
if (remaining_nodes.size() > 2)
|
||||
{
|
||||
if (orig_node_id_from_new_node_id_map.size() > 0)
|
||||
if (flushed_contractor)
|
||||
{
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<NodeID>(0, remaining_nodes.size(), InitGrainSize),
|
||||
@ -727,7 +731,7 @@ class GraphContractor
|
||||
if (heap.GetData(node).target)
|
||||
{
|
||||
++number_of_targets_found;
|
||||
if (number_of_targets_found >= number_of_targets)
|
||||
if (number_of_targets_found == number_of_targets)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -808,7 +812,9 @@ class GraphContractor
|
||||
}
|
||||
const NodeID target = contractor_graph->GetTarget(out_edge);
|
||||
if (node == target)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const EdgeWeight path_weight = in_data.weight + out_data.weight;
|
||||
if (target == source)
|
||||
|
Loading…
Reference in New Issue
Block a user