The connectivity-1 (km1) objective for a given shard assignment: `Σ_net weight · (λ − 1)`, where `λ` is the number of distinct shards the net's pins fall into. This is the total cross-shard ingress in bytes.
(&self, shard_of: &[u32])
| 199 | /// `Σ_net weight · (λ − 1)`, where `λ` is the number of distinct shards the |
| 200 | /// net's pins fall into. This is the total cross-shard ingress in bytes. |
| 201 | pub fn connectivity_objective(&self, shard_of: &[u32]) -> u128 { |
| 202 | let mut total: u128 = 0; |
| 203 | let mut seen: FxHashSet<u32> = FxHashSet::default(); |
| 204 | for (i, pins) in self.net_pins.iter().enumerate() { |
| 205 | seen.clear(); |
| 206 | for &v in pins { |
| 207 | seen.insert(shard_of[v as usize]); |
| 208 | } |
| 209 | let lambda = seen.len() as u128; |
| 210 | if lambda > 1 { |
| 211 | total += u128::from(self.net_weight[i]) * (lambda - 1); |
| 212 | } |
| 213 | } |
| 214 | total |
| 215 | } |
| 216 | |
| 217 | /// Partition the blocks into `num_shards` shards via recursive bisection. |
| 218 | /// Returns the shard id (in `0..num_shards`) for every block id. `epsilon` is |