ixa::network

Trait ContextNetworkExt

Source
pub trait ContextNetworkExt {
    // Required methods
    fn add_edge<T: EdgeType + 'static>(
        &mut self,
        person: PersonId,
        neighbor: PersonId,
        weight: f32,
        inner: T::Value,
    ) -> Result<(), IxaError>;
    fn add_edge_bidi<T: EdgeType + 'static>(
        &mut self,
        person1: PersonId,
        person2: PersonId,
        weight: f32,
        inner: T::Value,
    ) -> Result<(), IxaError>;
    fn remove_edge<T: EdgeType + 'static>(
        &mut self,
        person: PersonId,
        neighbor: PersonId,
    ) -> Result<(), IxaError>;
    fn get_edge<T: EdgeType + 'static>(
        &self,
        person: PersonId,
        neighbor: PersonId,
    ) -> Option<&Edge<T::Value>>;
    fn get_edges<T: EdgeType + 'static>(
        &self,
        person: PersonId,
    ) -> Vec<Edge<T::Value>>;
    fn get_matching_edges<T: EdgeType + 'static>(
        &self,
        person: PersonId,
        filter: impl Fn(&Context, &Edge<T::Value>) -> bool + 'static,
    ) -> Vec<Edge<T::Value>>;
    fn find_people_by_degree<T: EdgeType + 'static>(
        &self,
        degree: usize,
    ) -> Vec<PersonId>;
    fn select_random_edge<T: EdgeType + 'static, R: RngId + 'static>(
        &self,
        rng_id: R,
        person_id: PersonId,
    ) -> Result<Edge<T::Value>, IxaError>
       where R::RngType: Rng;
}

Required Methods§

Source

fn add_edge<T: EdgeType + 'static>( &mut self, person: PersonId, neighbor: PersonId, weight: f32, inner: T::Value, ) -> Result<(), IxaError>

Add an edge of type T between person and neighbor with a given weight. inner is a value of whatever type is associated with T.

§Errors

Returns IxaError if:

  • person and neighbor are the same or an edge already exists between them.
  • weight is invalid
Source

fn add_edge_bidi<T: EdgeType + 'static>( &mut self, person1: PersonId, person2: PersonId, weight: f32, inner: T::Value, ) -> Result<(), IxaError>

Add a pair of edges of type T between person1 and neighbor2 with a given weight, one edge in each direction. inner is a value of whatever type is associated with T. This is syntactic sugar for calling add_edge() twice.

§Errors

Returns IxaError if:

  • person and neighbor are the same or an edge already exists between them.
  • weight is invalid
Source

fn remove_edge<T: EdgeType + 'static>( &mut self, person: PersonId, neighbor: PersonId, ) -> Result<(), IxaError>

Remove an edge of type T between person and neighbor if one exists.

§Errors

Returns IxaError if no edge exists.

Source

fn get_edge<T: EdgeType + 'static>( &self, person: PersonId, neighbor: PersonId, ) -> Option<&Edge<T::Value>>

Get an edge of type T between person and neighbor if one exists.

Source

fn get_edges<T: EdgeType + 'static>( &self, person: PersonId, ) -> Vec<Edge<T::Value>>

Get all edges of type T from person.

Source

fn get_matching_edges<T: EdgeType + 'static>( &self, person: PersonId, filter: impl Fn(&Context, &Edge<T::Value>) -> bool + 'static, ) -> Vec<Edge<T::Value>>

Get all edges of type T from person that match the predicate provided in filter. Note that because filter has access to both the edge, which contains the neighbor and Context, it is possible to filter on properties of the neighbor. The function context.matching_person() might be helpful here.

Source

fn find_people_by_degree<T: EdgeType + 'static>( &self, degree: usize, ) -> Vec<PersonId>

Find all people who have an edge of type T and degree degree.

Source

fn select_random_edge<T: EdgeType + 'static, R: RngId + 'static>( &self, rng_id: R, person_id: PersonId, ) -> Result<Edge<T::Value>, IxaError>
where R::RngType: Rng,

Select a random edge out of the list of outgoing edges of type T from person_id, weighted by the edge weights.

§Errors

Returns IxaError if there are no edges.

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.

Implementors§