MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / set_main_graph

Method set_main_graph

ciphercore-base/src/graphs.rs:3990–4003  ·  view source on GitHub ↗

Promotes a graph to the main one in this context. # Arguments `graph` - graph # Returns This context # Example ``` # use ciphercore_base::graphs::create_context; # use ciphercore_base::data_types::{array_type, INT32}; let c = create_context().unwrap(); let g = c.create_graph().unwrap(); let t = array_type(vec![3, 2], INT32); let n = g.input(t).unwrap(); n.set_as_output().unwrap(); g.finalize

(&self, graph: Graph)

Source from the content-addressed store, hash-verified

3988 /// c.set_main_graph(g).unwrap();
3989 /// ```
3990 pub fn set_main_graph(&self, graph: Graph) -> Result<Context> {
3991 let current_main_graph = self.body.borrow().main_graph.clone();
3992 match current_main_graph {
3993 Some(_) => Err(runtime_error!("Main graph is already set")),
3994 None => {
3995 if graph.get_context() != *self {
3996 return Err(runtime_error!("Main graph is from the wrong context"));
3997 }
3998 graph.check_finalized()?;
3999 self.body.borrow_mut().main_graph = Some(graph.downgrade());
4000 Ok(self.clone())
4001 }
4002 }
4003 }
4004
4005 /// Returns the vector of graphs contained in this context in order of creation.
4006 ///

Callers 15

run_instantiation_passFunction · 0.45
test_notFunction · 0.45
test_orFunction · 0.45
test_instantiation_passFunction · 0.45
set_as_mainMethod · 0.45
call_iterate_testFunction · 0.45
test_malformed_contextsFunction · 0.45
test_unfinalized_graphsFunction · 0.45
context_generatorsFunction · 0.45
test_named_contextsFunction · 0.45

Calls 4

cloneMethod · 0.80
downgradeMethod · 0.80
get_contextMethod · 0.45
check_finalizedMethod · 0.45

Tested by 15

test_notFunction · 0.36
test_orFunction · 0.36
test_instantiation_passFunction · 0.36
call_iterate_testFunction · 0.36
test_malformed_contextsFunction · 0.36
test_unfinalized_graphsFunction · 0.36
test_named_contextsFunction · 0.36
test_mux_bitsFunction · 0.36
test_mux_broadcastFunction · 0.36