pub trait GraphNode: Sized + Clone {
type NodeId: PartialEq + Eq + Hash + Clone;
// Required methods
fn get_neighbors(&self) -> Vec<Self>;
fn get_id(&self) -> Self::NodeId;
// Provided method
fn get_neighbors_in_given_scc(&self, scc: Vec<Self::NodeId>) -> Vec<Self> { ... }
}
Expand description
A trait for a node in a graph. Note that a GraphNode has to be able to provide its neighbors by itself, without additional information.
Required Associated Types§
Required Methods§
sourcefn get_neighbors(&self) -> Vec<Self>
fn get_neighbors(&self) -> Vec<Self>
Returns a list of the node’s neighbors. Must be stable for the SCC result to be stable. i.e. if the output for a node here doesn’t change between different runs, the computed SCC of the node is guaranteed to also not change.
Provided Methods§
sourcefn get_neighbors_in_given_scc(&self, scc: Vec<Self::NodeId>) -> Vec<Self>
fn get_neighbors_in_given_scc(&self, scc: Vec<Self::NodeId>) -> Vec<Self>
Helper function to get the neighbors of the node, given its SCC. Default-implemented and thus can be used in simple implementations of get_neighbors_in_scc.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.