pub fn add_edge(&mut self, outlet: OutletId, inlet: InletId) -> TractResult<()> {
        if let Some(previous) = self.nodes[inlet.node].inputs.get(inlet.slot).cloned() {
            self.nodes[previous.node].outputs[previous.slot]
                .successors
                .retain(|&mut succ| succ != inlet);
        }
        {
            let prec = &mut self.nodes[outlet.node];
            prec.outputs[outlet.slot].successors.push(inlet);
            self.outputs.retain(|&o| o != outlet);
        }
        let succ = &mut self.nodes[inlet.node];
        if inlet.slot == succ.inputs.len() {
            succ.inputs.push(outlet);
        } else if inlet.slot < succ.inputs.len() {
            succ.inputs[inlet.slot] = outlet;
        } else {
            bail!("Edges must be added in order and consecutive. Trying to connect input {:?} of node {:?} ", inlet.slot, succ)
        }
        Ok(())
    }
/// Connect a node outlet to a node inlet.
Connect a node outlet to a node inlet.
Connect a node outlet to a node inlet .
pub fn add_edge(&mut self, outlet: OutletId, inlet: InletId) -> TractResult<()> {
        if let Some(previous) = self.nodes[inlet.node].inputs.get(inlet.slot).cloned() {
            self.nodes[previous.node].outputs[previous.slot]
                .successors
                .retain(|&mut succ| succ != inlet);
        }
        {
            let prec = &mut self.nodes[outlet.node];
            prec.outputs[outlet.slot].successors.push(inlet);
            self.outputs.retain(|&o| o != outlet);
        }
        let succ = &mut self.nodes[inlet.node];
        if inlet.slot == succ.inputs.len() {
            succ.inputs.push(outlet);
        } else if inlet.slot < succ.inputs.len() {
            succ.inputs[inlet.slot] = outlet;
        } else {
            bail!("Edges must be added in order and consecutive. Trying to connect input {:?} of node {:?} ", inlet.slot, succ)
        }
        Ok(())
    }
pub fn add_edge ( & mut self , outlet : OutletId , inlet : InletId ) -> TractResult < ( ) > { if let Some ( previous ) = self . nodes [ inlet . node ] . inputs . get ( inlet . slot ) . cloned ( ) { self . nodes [ previous . node ] . outputs [ previous . slot ] . successors . retain ( | & mut succ | succ != inlet ) ; } { let prec = & mut self . nodes [ outlet . node ] ; prec . outputs [ outlet . slot ] . successors . push ( inlet ) ; self . outputs . retain ( | & o | o != outlet ) ; } let succ = & mut self . nodes [ inlet . node ] ; if inlet . slot == succ . inputs . len ( ) { succ . inputs . push ( outlet ) ; } else if inlet . slot < succ . inputs . len ( ) { succ . inputs [ inlet . slot ] = outlet ; } else { bail ! ( " " inlet slot succ ) } Ok ( ( ) ) }
Connect a node outlet to a node inlet.
Connect a node outlet to a node inlet .
&mut self
outlet
OutletId
inlet
InletId
&mut self
outlet
OutletId
inlet
InletId