pub fn each_link<'a, N, L, EXTID, F>(
        &'a self,
        cppn: &'a mut Cppn<'a, N, L, EXTID>,
        callback: &mut F,
    ) where
        N: CppnNodeType,
        L: Copy + Debug + Send + Sized + Into<f64> + 'a,
        EXTID: Copy + Debug + Send + Sized + Ord + 'a,
        F: FnMut(Link<'a, P, T>),
    {
        for layer_link in self.layer_links.iter() {
            for (source_idx, source) in self.layers[layer_link.from_layer].nodes.iter().enumerate()
            {
                // Reject invalid connections.
                match source.node_connectivity {
                    NodeConnectivity::Out | NodeConnectivity::InOut => {}
                    NodeConnectivity::In => {
                        // Node does not allow outgoing connections
                        continue;
                    }
                }

                for (target_idx, target) in
                    self.layers[layer_link.to_layer].nodes.iter().enumerate()
                {
                    // Reject invalid connections.
                    match target.node_connectivity {
                        NodeConnectivity::In | NodeConnectivity::InOut => {}
                        NodeConnectivity::Out => {
                            // Node does not allow incoming connections
                            continue;
                        }
                    }

                    let distance_sq = source.position.distance_square(&target.position);

                    // reject a pair of nodes based on `max_distance_square`.
                    if let Some(max_d_sq) = layer_link.max_distance_square {
                        if distance_sq > max_d_sq {
                            continue;
                        }
                    }

                    // Calculate the weight between source and target using the CPPN.

                    let inputs_to_cppn = [source.position.coords(), target.position.coords()];

                    let outputs_from_cppn = cppn.calculate(&inputs_to_cppn);

                    let link = Link {
                        source: source,
                        target: target,
                        source_idx: (layer_link.from_layer, source_idx),
                        target_idx: (layer_link.to_layer, target_idx),
                        outputs: outputs_from_cppn,
                        distance_square: distance_sq,
                    };
                    callback(link);
                }
            }
        }
    }
/// Iterate over all produced links of Cppn.
Iterate over all produced links of Cppn.
Iterate over all produced links of Cppn .
pub fn each_link<'a, N, L, EXTID, F>(
        &'a self,
        cppn: &'a mut Cppn<'a, N, L, EXTID>,
        callback: &mut F,
    ) where
        N: CppnNodeType,
        L: Copy + Debug + Send + Sized + Into<f64> + 'a,
        EXTID: Copy + Debug + Send + Sized + Ord + 'a,
        F: FnMut(Link<'a, P, T>),
    {
        for layer_link in self.layer_links.iter() {
            for (source_idx, source) in self.layers[layer_link.from_layer].nodes.iter().enumerate()
            {
                // Reject invalid connections.
                match source.node_connectivity {
                    NodeConnectivity::Out | NodeConnectivity::InOut => {}
                    NodeConnectivity::In => {
                        // Node does not allow outgoing connections
                        continue;
                    }
                }
                for (target_idx, target) in
                    self.layers[layer_link.to_layer].nodes.iter().enumerate()
                {
                    // Reject invalid connections.
                    match target.node_connectivity {
                        NodeConnectivity::In | NodeConnectivity::InOut => {}
                        NodeConnectivity::Out => {
                            // Node does not allow incoming connections
                            continue;
                        }
                    }
                    let distance_sq = source.position.distance_square(&target.position);
                    // reject a pair of nodes based on `max_distance_square`.
                    if let Some(max_d_sq) = layer_link.max_distance_square {
                        if distance_sq > max_d_sq {
                            continue;
                        }
                    }
                    // Calculate the weight between source and target using the CPPN.
                    let inputs_to_cppn = [source.position.coords(), target.position.coords()];
                    let outputs_from_cppn = cppn.calculate(&inputs_to_cppn);
                    let link = Link {
                        source: source,
                        target: target,
                        source_idx: (layer_link.from_layer, source_idx),
                        target_idx: (layer_link.to_layer, target_idx),
                        outputs: outputs_from_cppn,
                        distance_square: distance_sq,
                    };
                    callback(link);
                }
            }
        }
    }
pub fn each_link < ' a , N , L , EXTID , F > ( & ' a self , cppn : & ' a mut Cppn < ' a , N , L , EXTID > , callback : & mut F , ) where N : CppnNodeType , L : Copy + Debug + Send + Sized + Into < f64 > + ' a , EXTID : Copy + Debug + Send + Sized + Ord + ' a , F : FnMut ( Link < ' a , P , T > ) , { for layer_link in self . layer_links . iter ( ) { for ( source_idx , source ) in self . layers [ layer_link . from_layer ] . nodes . iter ( ) . enumerate ( ) { // Reject invalid connections. match source . node_connectivity { NodeConnectivity :: Out | NodeConnectivity :: InOut => { } NodeConnectivity :: In => { // Node does not allow outgoing connections continue ; } } for ( target_idx , target ) in self . layers [ layer_link . to_layer ] . nodes . iter ( ) . enumerate ( ) { // Reject invalid connections. match target . node_connectivity { NodeConnectivity :: In | NodeConnectivity :: InOut => { } NodeConnectivity :: Out => { // Node does not allow incoming connections continue ; } } let distance_sq = source . position . distance_square ( & target . position ) ; // reject a pair of nodes based on `max_distance_square`. if let Some ( max_d_sq ) = layer_link . max_distance_square { if distance_sq > max_d_sq { continue ; } } // Calculate the weight between source and target using the CPPN. let inputs_to_cppn = [ source . position . coords ( ) , target . position . coords ( ) ] ; let outputs_from_cppn = cppn . calculate ( & inputs_to_cppn ) ; let link = Link { source : source , target : target , source_idx : ( layer_link . from_layer , source_idx ) , target_idx : ( layer_link . to_layer , target_idx ) , outputs : outputs_from_cppn , distance_square : distance_sq , } ; callback ( link ) ; } } } }
Iterate over all produced links of Cppn.
Iterate over all produced links of Cppn .
&'a self
cppn
&'a mut Cppn<'a, N, L, EXTID>
callback
&mut F
&'a self
cppn
&'a mut Cppn<'a, N, L, EXTID>
callback
&mut F