pub struct NodeGraph<N, E> { /* private fields */ }Expand description
Pure node graph data model with typed ports.
Implementations§
Source§impl<N, E> NodeGraph<N, E>
impl<N, E> NodeGraph<N, E>
Sourcepub fn add_node(&mut self, payload: N) -> NodeId
pub fn add_node(&mut self, payload: N) -> NodeId
Adds a node without ports and returns its identifier.
Sourcepub fn add_node_with_ports(&mut self, payload: N, ports: Vec<Port>) -> NodeId
pub fn add_node_with_ports(&mut self, payload: N, ports: Vec<Port>) -> NodeId
Adds a node with declared ports and returns its identifier.
Sourcepub fn remove_node(&mut self, id: NodeId) -> Result<Node<N>, GraphError>
pub fn remove_node(&mut self, id: NodeId) -> Result<Node<N>, GraphError>
Removes a node and all connected edges.
Sourcepub fn add_edge(
&mut self,
from: (NodeId, PortId),
to: (NodeId, PortId),
payload: E,
) -> Result<EdgeId, GraphError>
pub fn add_edge( &mut self, from: (NodeId, PortId), to: (NodeId, PortId), payload: E, ) -> Result<EdgeId, GraphError>
Adds a validated directed edge between two ports.
Sourcepub fn remove_edge(&mut self, id: EdgeId) -> Result<Edge<E>, GraphError>
pub fn remove_edge(&mut self, id: EdgeId) -> Result<Edge<E>, GraphError>
Removes an edge by identifier.
Sourcepub fn node_mut(&mut self, id: NodeId) -> Option<&mut Node<N>>
pub fn node_mut(&mut self, id: NodeId) -> Option<&mut Node<N>>
Returns a mutable node reference.
Sourcepub fn nodes(&self) -> impl Iterator<Item = (&NodeId, &Node<N>)>
pub fn nodes(&self) -> impl Iterator<Item = (&NodeId, &Node<N>)>
Iterates over nodes in identifier order.
Sourcepub fn edges(&self) -> impl Iterator<Item = (&EdgeId, &Edge<E>)>
pub fn edges(&self) -> impl Iterator<Item = (&EdgeId, &Edge<E>)>
Iterates over edges in identifier order.
Sourcepub fn connected(&self, port: (NodeId, PortId)) -> Vec<EdgeId>
pub fn connected(&self, port: (NodeId, PortId)) -> Vec<EdgeId>
Returns all edges connected to the given port.
Trait Implementations§
impl<N: Eq, E: Eq> Eq for NodeGraph<N, E>
impl<N, E> StructuralPartialEq for NodeGraph<N, E>
Auto Trait Implementations§
impl<N, E> Freeze for NodeGraph<N, E>
impl<N, E> RefUnwindSafe for NodeGraph<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
impl<N, E> Send for NodeGraph<N, E>
impl<N, E> Sync for NodeGraph<N, E>
impl<N, E> Unpin for NodeGraph<N, E>
impl<N, E> UnsafeUnpin for NodeGraph<N, E>
impl<N, E> UnwindSafe for NodeGraph<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
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