modified Dijkstra
```rust []
use std::collections::{BinaryHeap, HashMap, HashSet};
use std::cmp::Reverse;

impl Solution {
    pub fn min_max_weight(n: i32, mut edges: Vec<Vec<i32>>, threshold: i32) -> i32 {
        let n = n as usize;
        let mut ad = HashMap::<usize, Vec<(usize, i32)>>::new();
        for e in edges.into_iter() {
            let u = e[0] as usize;
            let v = e[1] as usize;
            let w = e[2];
            ad.entry(v).or_default().push((u, w));
        }
        let mut seen = vec![i32::MAX; n];
        let mut nuse = vec![0; n];
        let mut q = BinaryHeap::new();
        for &(y, g) in ad.get(&0).unwrap_or(&vec![]).iter() {
            q.push((Reverse(g), 0, y));
        }
        if q.is_empty() {return -1}
        let mut w = 0;
        seen[0] = 0;
        let mut connected = HashSet::new();
        connected.insert(0);
        while let Some((Reverse(ww), x, y)) = q.pop() {
            if nuse[y] == threshold {continue}
            nuse[y] += 1;
            connected.insert(y);
            w = w.max(ww);
            if connected.len() == n {break}
            for &(z, g) in ad.get(&y).unwrap_or(&vec![]).iter() {
                if g < seen[z] {
                    seen[z] = g;
                    q.push((Reverse(g), y, z))
                }
            }
        }
        if connected.len() < n {return -1}
        w
    }
}
```
['Rust']