pub struct Hyperedge {
pub id: Option<i64>,
pub hyperedge_type: String,
pub entity_ids: Vec<i64>,
pub weight: f64,
pub arity: usize,
pub properties: HashMap<String, Value>,
pub created_at: Option<i64>,
pub updated_at: Option<i64>,
}Expand description
A hyperedge representing a higher-order relation among multiple entities.
Fields§
§id: Option<i64>§hyperedge_type: String§entity_ids: Vec<i64>§weight: f64§arity: usize§properties: HashMap<String, Value>§created_at: Option<i64>§updated_at: Option<i64>Implementations§
Source§impl Hyperedge
impl Hyperedge
Sourcepub fn new(
entity_ids: Vec<i64>,
hyperedge_type: impl Into<String>,
weight: f64,
) -> Result<Self>
pub fn new( entity_ids: Vec<i64>, hyperedge_type: impl Into<String>, weight: f64, ) -> Result<Self>
Create a new hyperedge.
Requires at least 2 entities and weight in [0.0, 1.0].
Sourcepub fn set_property(&mut self, key: impl Into<String>, value: Value)
pub fn set_property(&mut self, key: impl Into<String>, value: Value)
Set a property on the hyperedge.
Sourcepub fn get_property(&self, key: &str) -> Option<&Value>
pub fn get_property(&self, key: &str) -> Option<&Value>
Get a property value.
Sourcepub fn contains(&self, entity_id: i64) -> bool
pub fn contains(&self, entity_id: i64) -> bool
Check if an entity participates in this hyperedge.
Sourcepub fn entity_set(&self) -> HashSet<i64>
pub fn entity_set(&self) -> HashSet<i64>
Get the entity set for efficient set operations.
Sourcepub fn intersection(&self, other: &Hyperedge) -> Vec<i64>
pub fn intersection(&self, other: &Hyperedge) -> Vec<i64>
Compute intersection with another hyperedge - O(k1 + k2).
Sourcepub fn has_intersection(&self, other: &Hyperedge) -> bool
pub fn has_intersection(&self, other: &Hyperedge) -> bool
Check if this hyperedge shares any entity with another - O(k1 + k2).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Hyperedge
impl<'de> Deserialize<'de> for Hyperedge
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Hyperedge
impl RefUnwindSafe for Hyperedge
impl Send for Hyperedge
impl Sync for Hyperedge
impl Unpin for Hyperedge
impl UnsafeUnpin for Hyperedge
impl UnwindSafe for Hyperedge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.