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, Vec<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 Nodes of the graph
inputs: SlotMap<InputId, InputParam<DataType, ValueType>>The InputParams of the graph
outputs: SlotMap<OutputId, OutputParam<DataType>>The OutputParams of the graph
connections: SecondaryMap<InputId, Vec<OutputId>>Implementations§
Source§impl<NodeData, DataType, ValueType> Graph<NodeData, DataType, ValueType>
impl<NodeData, DataType, ValueType> Graph<NodeData, DataType, ValueType>
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_wide_input_param( &mut self, node_id: NodeId, name: String, typ: DataType, value: ValueType, kind: InputParamKind, max_connections: Option<NonZeroU32>, shown_inline: bool, ) -> InputId
pub fn add_input_param( &mut self, node_id: NodeId, name: String, typ: DataType, value: ValueType, kind: InputParamKind, shown_inline: bool, ) -> InputId
pub fn remove_input_param(&mut self, param: InputId)
pub fn remove_output_param(&mut self, param: OutputId)
pub fn add_output_param( &mut self, node_id: NodeId, name: String, typ: DataType, ) -> OutputId
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.
pub fn remove_connection( &mut self, input_id: InputId, output_id: OutputId, ) -> bool
pub fn iter_nodes(&self) -> impl Iterator<Item = NodeId> + '_
pub fn add_connection(&mut self, output: OutputId, input: InputId, pos: usize)
pub fn iter_connection_groups( &self, ) -> impl Iterator<Item = (InputId, Vec<OutputId>)> + '_
pub fn iter_connections(&self) -> impl Iterator<Item = (InputId, OutputId)> + '_
pub fn connections(&self, input: InputId) -> Vec<OutputId>
pub fn connection(&self, input: InputId) -> Option<OutputId>
pub fn any_param_type( &self, param: AnyParameterId, ) -> Result<&DataType, EguiGraphError>
pub fn try_get_input( &self, input: InputId, ) -> Option<&InputParam<DataType, ValueType>>
pub fn get_input(&self, input: InputId) -> &InputParam<DataType, ValueType>
pub fn try_get_output(&self, output: OutputId) -> Option<&OutputParam<DataType>>
pub fn get_output(&self, output: OutputId) -> &OutputParam<DataType>
Trait Implementations§
Source§impl<NodeData: Clone, DataType: Clone, ValueType: Clone> Clone for Graph<NodeData, DataType, ValueType>
impl<NodeData: Clone, DataType: Clone, ValueType: Clone> Clone for Graph<NodeData, DataType, ValueType>
Source§impl<NodeData: Debug, DataType: Debug, ValueType: Debug> Debug for Graph<NodeData, DataType, ValueType>
impl<NodeData: Debug, DataType: Debug, ValueType: Debug> Debug for Graph<NodeData, DataType, ValueType>
Auto Trait Implementations§
impl<NodeData, DataType, ValueType> Freeze for Graph<NodeData, DataType, ValueType>
impl<NodeData, DataType, ValueType> RefUnwindSafe for Graph<NodeData, DataType, ValueType>
impl<NodeData, DataType, ValueType> Send for Graph<NodeData, DataType, ValueType>
impl<NodeData, DataType, ValueType> Sync for Graph<NodeData, DataType, ValueType>
impl<NodeData, DataType, ValueType> Unpin for Graph<NodeData, DataType, ValueType>
impl<NodeData, DataType, ValueType> UnwindSafe for Graph<NodeData, DataType, ValueType>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more