Skip to content

Commit

Permalink
Add heuristic approach to assign edge-based partition IDs
Browse files Browse the repository at this point in the history
that minimize number of faked source/destination nodes in
the edge case: a single backward edge will be placed
in other than node u partion
  • Loading branch information
oxidase authored and Patrick Niklaus committed Mar 13, 2017
1 parent 40094ce commit c6e9cc8
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/partition/partitioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,46 @@ int Partitioner::Run(const PartitionConfig &config)
{
// Can use partition_ids[u/v] as partition for edge based graph `node_id`
edge_based_partition_ids[node] = node_based_partition_ids[u];

auto edges = edge_based_graph->GetAdjacentEdgeRange(node);
if (edges.size() == 1)
{ // Check the edge case with one adjacent edge-based backward edge
auto edge = edges.front();
auto other = edge_based_graph->GetTarget(edge);
auto &data = edge_based_graph->GetEdgeData(edge);
auto other_node_based_nodes = mapping.Lookup(other);
if (data.backward &&
node_based_partition_ids[other_node_based_nodes.u] !=
node_based_partition_ids[u])
{ // use id of other node if the edge [other_u, other_v] -> [u,v] is a single edge
// and nodes other_[u,v] are in different node-based partitions
edge_based_partition_ids[node] =
node_based_partition_ids[other_node_based_nodes.u];
}
}
}
else
{
// Border nodes u,v - need to be resolved.
// FIXME: just pick one side for now. See #3205.
edge_based_partition_ids[node] = node_based_partition_ids[u];

bool use_u = false;
for (auto edge : edge_based_graph->GetAdjacentEdgeRange(node))
{
auto other = edge_based_graph->GetTarget(edge);
auto &data = edge_based_graph->GetEdgeData(edge);
auto other_node_based_nodes = mapping.Lookup(other);

if (data.backward)
{ // can use id of u if [other_u, other_v] -> [u,v] is in the same partition as u
BOOST_ASSERT(u == other_node_based_nodes.v);
use_u |= node_based_partition_ids[u] ==
node_based_partition_ids[other_node_based_nodes.u];
}
}

// Use partition that introduce less cross cell connections
edge_based_partition_ids[node] = node_based_partition_ids[use_u ? u : v];
}
}

Expand Down

0 comments on commit c6e9cc8

Please sign in to comment.