Skip to content

Commit f55093e

Browse files
committed
mpl:
1) Don't take into account external connections when evaluating the connection signature between two clusters; 2) Avoid considering the weight of the target connection twice when evaluating if that connection is a strong one. Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
1 parent 8408e42 commit f55093e

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/mpl/src/clusterEngine.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,9 +1889,10 @@ std::vector<int> ClusteringEngine::findNeighbors(Cluster* target_cluster,
18891889
continue;
18901890
}
18911891

1892-
Cluster* other_cluster = tree_->maps.id_to_cluster.at(cluster_id);
1892+
const float connection_ratio
1893+
= connection_weight / target_cluster->allConnectionsWeight();
18931894

1894-
if (strongConnection(target_cluster, other_cluster, &connection_weight)) {
1895+
if (connection_ratio >= minimum_connection_ratio_) {
18951896
neighbors.push_back(cluster_id);
18961897
}
18971898
}
@@ -1911,24 +1912,25 @@ bool ClusteringEngine::strongConnection(Cluster* a,
19111912
a->getName());
19121913
}
19131914

1914-
const float minimum_connection_ratio = 0.1;
1915-
const float total_weight
1916-
= a->allConnectionsWeight() + b->allConnectionsWeight();
1917-
1915+
// Attention that we need to subtract the weight of the connection that
1916+
// we're evaluating otherwise we'll be taking it into account twice.
1917+
float total_weight = a->allConnectionsWeight() + b->allConnectionsWeight();
19181918
float connection_ratio = 0.0;
19191919
if (connection_weight) {
1920+
total_weight -= *connection_weight;
19201921
connection_ratio = *connection_weight / total_weight;
19211922
} else {
19221923
const ConnectionsMap& a_connections = a->getConnectionsMap();
19231924
auto itr = a_connections.find(b->getId());
19241925

19251926
if (itr != a_connections.end()) {
19261927
const float conn_weight = itr->second;
1928+
total_weight -= conn_weight;
19271929
connection_ratio = conn_weight / total_weight;
19281930
}
19291931
}
19301932

1931-
return connection_ratio >= minimum_connection_ratio;
1933+
return connection_ratio >= minimum_connection_ratio_;
19321934
}
19331935

19341936
Cluster* ClusteringEngine::findSingleWellFormedConnectedCluster(

src/mpl/src/clusterEngine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ class ClusteringEngine
312312
// them to be considered connected when creating data flow.
313313
const int max_num_of_hops_ = 5;
314314

315+
const float minimum_connection_ratio_{0.10};
316+
315317
int first_io_bundle_id_{-1};
316318
IOBundleSpans io_bundle_spans_;
317319
};

0 commit comments

Comments
 (0)