Creates an empty computation graph in this context. # Returns New computation graph # Example ``` # use ciphercore_base::graphs::create_context; let c = create_context().unwrap(); let g = c.create_graph().unwrap(); ```
(&self)
| 3907 | /// let g = c.create_graph().unwrap(); |
| 3908 | /// ``` |
| 3909 | pub fn create_graph(&self) -> Result<Graph> { |
| 3910 | if self.body.borrow().finalized { |
| 3911 | return Err(runtime_error!("Can't add a graph to a finalized context")); |
| 3912 | } |
| 3913 | let id = self.body.borrow().graphs.len() as u64; |
| 3914 | let result = Graph { |
| 3915 | body: Arc::new(AtomicRefCell::new(GraphBody { |
| 3916 | finalized: false, |
| 3917 | nodes: vec![], |
| 3918 | output_node: None, |
| 3919 | id, |
| 3920 | context: self.downgrade(), |
| 3921 | })), |
| 3922 | }; |
| 3923 | self.body.borrow_mut().graphs.push(result.clone()); |
| 3924 | Ok(result) |
| 3925 | } |
| 3926 | |
| 3927 | /// Finalizes the context if all its graphs are finalized and the main graph is set. |
| 3928 | /// |