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§
Sourcefn add_edge<T: EdgeType + 'static>(
&mut self,
person: PersonId,
neighbor: PersonId,
weight: f32,
inner: T::Value,
) -> Result<(), IxaError>
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
andneighbor
are the same or an edge already exists between them.weight
is invalid
Sourcefn add_edge_bidi<T: EdgeType + 'static>(
&mut self,
person1: PersonId,
person2: 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>
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
andneighbor
are the same or an edge already exists between them.weight
is invalid
Sourcefn remove_edge<T: EdgeType + 'static>(
&mut self,
person: PersonId,
neighbor: PersonId,
) -> Result<(), IxaError>
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.
Sourcefn get_edge<T: EdgeType + 'static>(
&self,
person: PersonId,
neighbor: PersonId,
) -> Option<&Edge<T::Value>>
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.
Sourcefn get_edges<T: EdgeType + 'static>(
&self,
person: PersonId,
) -> Vec<Edge<T::Value>>
fn get_edges<T: EdgeType + 'static>( &self, person: PersonId, ) -> Vec<Edge<T::Value>>
Get all edges of type T
from person
.
Sourcefn get_matching_edges<T: EdgeType + 'static>(
&self,
person: PersonId,
filter: impl Fn(&Context, &Edge<T::Value>) -> bool + 'static,
) -> 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>>
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.
Sourcefn find_people_by_degree<T: EdgeType + 'static>(
&self,
degree: usize,
) -> Vec<PersonId>
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
.
Sourcefn select_random_edge<T: EdgeType + 'static, R: RngId + 'static>(
&self,
rng_id: R,
person_id: PersonId,
) -> Result<Edge<T::Value>, IxaError>
fn select_random_edge<T: EdgeType + 'static, R: RngId + 'static>( &self, rng_id: R, person_id: PersonId, ) -> Result<Edge<T::Value>, IxaError>
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.