pub enum Direction {
Forward,
Backward,
}Expand description
Represents the direction of connections in a graph node.
The Direction enum is used to specify whether a node’s connections follow the normal forward direction or create a backward (recurrent) connection. This is particularly important for creating cyclic graphs and recurrent neural networks.
§Variants
Forward- The default direction for normal graph connections. In a forward connection, data flows from input nodes through intermediate nodes to output nodes.Backward- Indicates a recurrent connection where data can flow backwards, creating cycles in the graph. This is used to implement recurrent neural networks and other cyclic graph structures.
§Examples
use radiate_gp::collections::{graphs::Direction, GraphNode, NodeType};
let mut node = GraphNode::new(0, NodeType::Vertex, 42);
assert_eq!(node.direction(), Direction::Forward);
// Create a recurrent connection
node.set_direction(Direction::Backward);
assert!(node.is_recurrent());§Usage in Graphs
- By default, graphs are directed acyclic graphs (DAGs) with all connections in the
Forwarddirection - Setting a node’s direction to
Backwardallows for cyclic connections - The
Graph::set_cyclesmethod automatically sets appropriate nodes toBackwarddirection when cycles are detected
§Implementation Details
- Implements
Debug,Clone,Copy,PartialEq,Eq, andHash - When the “serde” feature is enabled, implements
SerializeandDeserialize
Variants§
Trait Implementations§
impl Copy for Direction
impl Eq for Direction
impl StructuralPartialEq for Direction
Auto Trait Implementations§
impl Freeze for Direction
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnsafeUnpin for Direction
impl UnwindSafe for Direction
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.