ContextNetworkExt

Trait ContextNetworkExt 

Source
pub trait ContextNetworkExt: ContextBase + ContextRandomExt {
    // Provided methods
    fn add_edge<E: Entity, ET: EdgeType<E>>(
        &mut self,
        entity_id: EntityId<E>,
        neighbor: EntityId<E>,
        weight: f32,
        inner: ET,
    ) -> Result<(), IxaError> { ... }
    fn add_edge_bidi<E: Entity, ET: EdgeType<E>>(
        &mut self,
        entity1: EntityId<E>,
        entity2: EntityId<E>,
        weight: f32,
        inner: ET,
    ) -> Result<(), IxaError> { ... }
    fn remove_edge<E: Entity, ET: EdgeType<E>>(
        &mut self,
        entity_id: EntityId<E>,
        neighbor: EntityId<E>,
    ) -> Option<Edge<E, ET>> { ... }
    fn get_edge<E: Entity, ET: EdgeType<E>>(
        &self,
        entity_id: EntityId<E>,
        neighbor: EntityId<E>,
    ) -> Option<&Edge<E, ET>> { ... }
    fn get_edges<E: Entity, ET: EdgeType<E>>(
        &self,
        entity_id: EntityId<E>,
    ) -> Vec<Edge<E, ET>> { ... }
    fn get_matching_edges<E: Entity, ET: EdgeType<E>>(
        &self,
        entity_id: EntityId<E>,
        filter: impl Fn(&Self, &Edge<E, ET>) -> bool,
    ) -> Vec<Edge<E, ET>> { ... }
    fn find_entities_by_degree<E: Entity, ET: EdgeType<E>>(
        &self,
        degree: usize,
    ) -> Vec<EntityId<E>> { ... }
    fn select_random_edge<E: Entity, ET: EdgeType<E>, R: RngId + 'static>(
        &self,
        rng_id: R,
        entity_id: EntityId<E>,
    ) -> Result<Edge<E, ET>, IxaError>
       where R::RngType: Rng { ... }
}

Provided Methods§

Source

fn add_edge<E: Entity, ET: EdgeType<E>>( &mut self, entity_id: EntityId<E>, neighbor: EntityId<E>, weight: f32, inner: ET, ) -> Result<(), IxaError>

Add an edge of type ET between entity_id and neighbor with a given weight.

§Errors

Returns IxaError if:

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

fn add_edge_bidi<E: Entity, ET: EdgeType<E>>( &mut self, entity1: EntityId<E>, entity2: EntityId<E>, weight: f32, inner: ET, ) -> Result<(), IxaError>

Add a pair of edges of type ET between entity1 and entity2 with a given weight, one edge in each direction. This is syntactic sugar for calling add_edge twice.

§Errors

Returns IxaError if:

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

fn remove_edge<E: Entity, ET: EdgeType<E>>( &mut self, entity_id: EntityId<E>, neighbor: EntityId<E>, ) -> Option<Edge<E, ET>>

Remove the edge of type ET from entity_id to neighbor and return it, or None if the edge does not exist.

Source

fn get_edge<E: Entity, ET: EdgeType<E>>( &self, entity_id: EntityId<E>, neighbor: EntityId<E>, ) -> Option<&Edge<E, ET>>

Get an edge of type ET from entity_id to neighbor if one exists.

Source

fn get_edges<E: Entity, ET: EdgeType<E>>( &self, entity_id: EntityId<E>, ) -> Vec<Edge<E, ET>>

Get all outgoing edges of type ET from entity_id.

Source

fn get_matching_edges<E: Entity, ET: EdgeType<E>>( &self, entity_id: EntityId<E>, filter: impl Fn(&Self, &Edge<E, ET>) -> bool, ) -> Vec<Edge<E, ET>>

Get all edges of type ET from entity_id that match the predicate provided in filter.

Note that because filter has access to both the edge (which contains neighbor) and the calling context (self), it is possible to filter on properties of the neighbor.

Source

fn find_entities_by_degree<E: Entity, ET: EdgeType<E>>( &self, degree: usize, ) -> Vec<EntityId<E>>

Find all entities who have an edge of type ET and degree degree.

Source

fn select_random_edge<E: Entity, ET: EdgeType<E>, R: RngId + 'static>( &self, rng_id: R, entity_id: EntityId<E>, ) -> Result<Edge<E, ET>, IxaError>
where R::RngType: Rng,

Select a random outgoing edge of type ET from entity_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§