pub struct Graph<NodeData, DataType, ValueType> {
pub nodes: SlotMap<NodeId, Node<NodeData>>,
pub inputs: SlotMap<InputId, InputParam<DataType, ValueType>>,
pub outputs: SlotMap<OutputId, OutputParam<DataType>>,
pub connections: SecondaryMap<InputId, OutputId>,
}
Expand description
The graph, containing nodes, input parameters and output parameters. Because
graphs are full of self-referential structures, this type uses the slotmap
crate to represent all the inner references in the data.
Fields§
§nodes: SlotMap<NodeId, Node<NodeData>>
The Node
s of the graph
inputs: SlotMap<InputId, InputParam<DataType, ValueType>>
The InputParam
s of the graph
outputs: SlotMap<OutputId, OutputParam<DataType>>
The OutputParam
s of the graph
connections: SecondaryMap<InputId, OutputId>
Implementations§
Source§impl<NodeData, DataType, ValueType> Graph<NodeData, DataType, ValueType>where
DataType: PartialEq,
impl<NodeData, DataType, ValueType> Graph<NodeData, DataType, ValueType>where
DataType: PartialEq,
pub fn new() -> Self
pub fn add_node( &mut self, label: String, user_data: NodeData, f: impl FnOnce(&mut Graph<NodeData, DataType, ValueType>, NodeId), ) -> NodeId
pub fn add_input_param( &mut self, node_id: NodeId, name: String, typ: DataType, value: ValueType, kind: InputParamKind, shown_inline: bool, ) -> InputId
pub fn update_input_param( &mut self, input_id: InputId, name: Option<String>, typ: Option<DataType>, value: Option<ValueType>, kind: Option<InputParamKind>, shown_inline: Option<bool>, )
pub fn remove_input_param(&mut self, param: InputId)
pub fn add_output_param( &mut self, node_id: NodeId, name: String, typ: DataType, ) -> OutputId
pub fn update_output_param( &mut self, output_id: OutputId, name: Option<String>, typ: Option<DataType>, )
pub fn remove_output_param(&mut self, param: OutputId)
Sourcepub fn ensure_connection_types(&mut self, param_id: AnyParameterId)
pub fn ensure_connection_types(&mut self, param_id: AnyParameterId)
Deletes mistyped connection made with param_id
This is only needed connection param type is changed with means
other than Graph::update_input_param
.
Sourcepub fn remove_node(
&mut self,
node_id: NodeId,
) -> (Node<NodeData>, Vec<(InputId, OutputId)>)
pub fn remove_node( &mut self, node_id: NodeId, ) -> (Node<NodeData>, Vec<(InputId, OutputId)>)
Removes a node from the graph with given node_id
. This also removes
any incoming or outgoing connections from that node
This function returns the list of connections that has been removed
after deleting this node as input-output pairs. Note that one of the two
ids in the pair (the one on node_id
’s end) will be invalid after
calling this function.