pub fn add_node_to_dag(&mut self, mut r: Resource) {
        let resource_id = r.id.clone();
        let resource_dependencies = r.dependencies.take();

        let root_index = if self.id_map.contains_key(&r.id) {
            *self.id_map.get(&r.id).unwrap()
        } else {
            let rid = self.graph.add_node(r);
            self.id_map.insert(resource_id.clone(), rid);
            rid
        };

        if let Some(dependencies) = resource_dependencies {
            for dep in dependencies {
                let dep_id = dep.id.clone();
                let dep_index = if self.id_map.contains_key(&dep.id) {
                    let tid = *self.id_map.get(&dep.id).unwrap();

                    if let Some(node) = self.graph.node_weight_mut(tid) {
                        // Replace the existing resource with dependent's state
                        node.state = dep.state;
                    }

                    tid
                } else {
                    let rid = self.graph.add_node(dep);
                    self.id_map.insert(dep_id.clone(), rid);
                    rid
                };

                self.graph
                    .add_edge(dep_index, root_index, Relation::Depends);
            }
        }
    }
/// Add a given Resource to the DAG
Add a given Resource to the DAG
Add a given Resource to the DAG
pub fn add_node_to_dag(&mut self, mut r: Resource) {
        let resource_id = r.id.clone();
        let resource_dependencies = r.dependencies.take();
        let root_index = if self.id_map.contains_key(&r.id) {
            *self.id_map.get(&r.id).unwrap()
        } else {
            let rid = self.graph.add_node(r);
            self.id_map.insert(resource_id.clone(), rid);
            rid
        };
        if let Some(dependencies) = resource_dependencies {
            for dep in dependencies {
                let dep_id = dep.id.clone();
                let dep_index = if self.id_map.contains_key(&dep.id) {
                    let tid = *self.id_map.get(&dep.id).unwrap();
                    if let Some(node) = self.graph.node_weight_mut(tid) {
                        // Replace the existing resource with dependent's state
                        node.state = dep.state;
                    }
                    tid
                } else {
                    let rid = self.graph.add_node(dep);
                    self.id_map.insert(dep_id.clone(), rid);
                    rid
                };
                self.graph
                    .add_edge(dep_index, root_index, Relation::Depends);
            }
        }
    }
pub fn add_node_to_dag ( & mut self , mut r : Resource ) { let resource_id = r . id . clone ( ) ; let resource_dependencies = r . dependencies . take ( ) ; let root_index = if self . id_map . contains_key ( & r . id ) { * self . id_map . get ( & r . id ) . unwrap ( ) } else { let rid = self . graph . add_node ( r ) ; self . id_map . insert ( resource_id . clone ( ) , rid ) ; rid } ; if let Some ( dependencies ) = resource_dependencies { for dep in dependencies { let dep_id = dep . id . clone ( ) ; let dep_index = if self . id_map . contains_key ( & dep . id ) { let tid = * self . id_map . get ( & dep . id ) . unwrap ( ) ; if let Some ( node ) = self . graph . node_weight_mut ( tid ) { // Replace the existing resource with dependent's state node . state = dep . state ; } tid } else { let rid = self . graph . add_node ( dep ) ; self . id_map . insert ( dep_id . clone ( ) , rid ) ; rid } ; self . graph . add_edge ( dep_index , root_index , Relation :: Depends ) ; } } }
Add a given Resource to the DAG
Add a given Resource to the DAG
&mut self
r
Resource