/// Create a new RandomGraph object using the given randomness generator.
/// It will panic if there are repeated failures in creating connected graph
/// due to
Create a new RandomGraph object using the given randomness generator.
It will panic if there are repeated failures in creating connected graph
due to
Create a new RandomGraph object using the given randomness generator . It will panic if there are repeated failures in creating connected graph due to
pub fn new<T: Rng>(num_nodes: usize, degree: usize, max_delta: u64, rng: &mut T) -> Box<Self> {
        assert!(degree < num_nodes);
        let mut tries = 0;
        loop {
            let mut distances = random_graph(num_nodes, degree, rng);
            if let Some(max_distance) = distance_vector(&mut distances) {
                let unit_latency =
                    Duration::from_millis(max_delta / (1 + std::cmp::max(1, max_distance)) as u64);
                return Box::new(RandomGraph {
                    degree,
                    unit_latency,
                    distances,
                });
            }
            tries += 1;
            assert!(
                tries < 10,
                "Insufficient degree {} for {} nodes",
                degree,
                num_nodes
            );
        }
    }
pub fn new < T : Rng > ( num_nodes : usize , degree : usize , max_delta : u64 , rng : & mut T ) -> Box < Self > { assert ! ( degree num_nodes ) ; let mut tries = 0 ; loop { let mut distances = random_graph ( num_nodes , degree , rng ) ; if let Some ( max_distance ) = distance_vector ( & mut distances ) { let unit_latency = Duration :: from_millis ( max_delta / ( 1 + std :: cmp :: max ( 1 , max_distance ) ) as u64 ) ; return Box :: new ( RandomGraph { degree , unit_latency , distances , } ) ; } tries += 1 ; assert ! ( tries 10 " " degree num_nodes ) ; } }
Create a new RandomGraph object using the given randomness generator.
Create a new RandomGraph object using the given randomness generator .
num_nodes
usize
degree
usize
max_delta
u64
rng
&mut T