Skip to main content

NetworkGraphView

Trait NetworkGraphView 

pub trait NetworkGraphView {
    type Observed: EdgeObservable + Send;
    type NodeId: Send;

    // Required methods
    fn node_count(&self) -> usize;
    fn contains_node(&self, key: &Self::NodeId) -> bool;
    fn nodes(&self) -> Pin<Box<dyn Stream<Item = Self::NodeId> + Send>>;
    fn edge(
        &self,
        src: &Self::NodeId,
        dest: &Self::NodeId,
    ) -> Option<Self::Observed>;

    // Provided method
    fn has_edge(&self, src: &Self::NodeId, dest: &Self::NodeId) -> bool { ... }
}
Expand description

A trait specifying read-only graph view functionality.

Provides methods to inspect the graph topology: node membership, node count, edge existence, and edge observation retrieval.

Required Associated Types§

type Observed: EdgeObservable + Send

The concrete type of observations for peers.

type NodeId: Send

The identifier type used to reference nodes in the graph.

Required Methods§

fn node_count(&self) -> usize

Returns the number of nodes in the graph.

fn contains_node(&self, key: &Self::NodeId) -> bool

Checks whether the graph contains the given node.

fn nodes(&self) -> Pin<Box<dyn Stream<Item = Self::NodeId> + Send>>

Returns a stream of all known nodes in the network graph.

fn edge( &self, src: &Self::NodeId, dest: &Self::NodeId, ) -> Option<Self::Observed>

Returns the weight represented by the observations for the edge between the given source and destination, if available.

Provided Methods§

fn has_edge(&self, src: &Self::NodeId, dest: &Self::NodeId) -> bool

Checks whether a directed edge exists between two nodes.

The default implementation delegates to edge.

Implementations on Foreign Types§

§

impl<'a, T> NetworkGraphView for &'a T
where T: 'a + NetworkGraphView + ?Sized,

§

type Observed = <T as NetworkGraphView>::Observed

§

type NodeId = <T as NetworkGraphView>::NodeId

§

fn node_count(&self) -> usize

§

fn contains_node(&self, key: &<&'a T as NetworkGraphView>::NodeId) -> bool

§

fn nodes( &self, ) -> Pin<Box<dyn Stream<Item = <&'a T as NetworkGraphView>::NodeId> + Send>>

§

fn has_edge( &self, src: &<&'a T as NetworkGraphView>::NodeId, dest: &<&'a T as NetworkGraphView>::NodeId, ) -> bool

§

fn edge( &self, src: &<&'a T as NetworkGraphView>::NodeId, dest: &<&'a T as NetworkGraphView>::NodeId, ) -> Option<<&'a T as NetworkGraphView>::Observed>

§

impl<T> NetworkGraphView for Box<T>
where T: NetworkGraphView + ?Sized,

§

type Observed = <T as NetworkGraphView>::Observed

§

type NodeId = <T as NetworkGraphView>::NodeId

§

fn node_count(&self) -> usize

§

fn contains_node(&self, key: &<Box<T> as NetworkGraphView>::NodeId) -> bool

§

fn nodes( &self, ) -> Pin<Box<dyn Stream<Item = <Box<T> as NetworkGraphView>::NodeId> + Send>>

§

fn has_edge( &self, src: &<Box<T> as NetworkGraphView>::NodeId, dest: &<Box<T> as NetworkGraphView>::NodeId, ) -> bool

§

fn edge( &self, src: &<Box<T> as NetworkGraphView>::NodeId, dest: &<Box<T> as NetworkGraphView>::NodeId, ) -> Option<<Box<T> as NetworkGraphView>::Observed>

§

impl<T> NetworkGraphView for Arc<T>
where T: NetworkGraphView + ?Sized,

§

type Observed = <T as NetworkGraphView>::Observed

§

type NodeId = <T as NetworkGraphView>::NodeId

§

fn node_count(&self) -> usize

§

fn contains_node(&self, key: &<Arc<T> as NetworkGraphView>::NodeId) -> bool

§

fn nodes( &self, ) -> Pin<Box<dyn Stream<Item = <Arc<T> as NetworkGraphView>::NodeId> + Send>>

§

fn has_edge( &self, src: &<Arc<T> as NetworkGraphView>::NodeId, dest: &<Arc<T> as NetworkGraphView>::NodeId, ) -> bool

§

fn edge( &self, src: &<Arc<T> as NetworkGraphView>::NodeId, dest: &<Arc<T> as NetworkGraphView>::NodeId, ) -> Option<<Arc<T> as NetworkGraphView>::Observed>

Implementors§