MCPcopy Create free account
hub / github.com/argumentcomputer/ix / connectivity_objective

Method connectivity_objective

crates/kernel/src/shard.rs:201–215  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

iterMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected