pub struct SocialNetwork { /* private fields */ }Expand description
Social network for a single organization
Manages members, relationships, factions, and network analysis.
Implementations§
Source§impl SocialNetwork
impl SocialNetwork
Sourcepub fn add_member(&mut self, member: SocialMember)
pub fn add_member(&mut self, member: SocialMember)
Add a member to the network
Sourcepub fn get_member(&self, member_id: &MemberId) -> Option<&SocialMember>
pub fn get_member(&self, member_id: &MemberId) -> Option<&SocialMember>
Get a member by ID (immutable)
Sourcepub fn get_member_mut(
&mut self,
member_id: &MemberId,
) -> Option<&mut SocialMember>
pub fn get_member_mut( &mut self, member_id: &MemberId, ) -> Option<&mut SocialMember>
Get a member by ID (mutable)
Sourcepub fn remove_member(&mut self, member_id: &MemberId) -> Option<SocialMember>
pub fn remove_member(&mut self, member_id: &MemberId) -> Option<SocialMember>
Remove a member from the network
Sourcepub fn has_member(&self, member_id: &MemberId) -> bool
pub fn has_member(&self, member_id: &MemberId) -> bool
Check if a member exists
Sourcepub fn all_members(&self) -> impl Iterator<Item = (&MemberId, &SocialMember)>
pub fn all_members(&self) -> impl Iterator<Item = (&MemberId, &SocialMember)>
Get all members
Sourcepub fn all_members_mut(
&mut self,
) -> impl Iterator<Item = (&MemberId, &mut SocialMember)>
pub fn all_members_mut( &mut self, ) -> impl Iterator<Item = (&MemberId, &mut SocialMember)>
Get all members (mutable)
Sourcepub fn member_count(&self) -> usize
pub fn member_count(&self) -> usize
Get number of members
Sourcepub fn add_relation(
&mut self,
from: MemberId,
to: MemberId,
relation: RelationType,
) -> Result<(), SocialError>
pub fn add_relation( &mut self, from: MemberId, to: MemberId, relation: RelationType, ) -> Result<(), SocialError>
Add a relationship between two members
Sourcepub fn get_relations(
&self,
from: &MemberId,
to: &MemberId,
) -> Option<&Vec<RelationType>>
pub fn get_relations( &self, from: &MemberId, to: &MemberId, ) -> Option<&Vec<RelationType>>
Get all relations between two members
Sourcepub fn remove_relation(
&mut self,
from: &MemberId,
to: &MemberId,
relation_type_name: &str,
) -> bool
pub fn remove_relation( &mut self, from: &MemberId, to: &MemberId, relation_type_name: &str, ) -> bool
Remove a specific relation type between two members
Sourcepub fn all_relations(
&self,
) -> impl Iterator<Item = (&(MemberId, MemberId), &Vec<RelationType>)>
pub fn all_relations( &self, ) -> impl Iterator<Item = (&(MemberId, MemberId), &Vec<RelationType>)>
Get all relations in the network
Sourcepub fn relation_count(&self) -> usize
pub fn relation_count(&self) -> usize
Get relations count
Sourcepub fn get_neighbors(&self, member_id: &MemberId) -> Vec<MemberId> ⓘ
pub fn get_neighbors(&self, member_id: &MemberId) -> Vec<MemberId> ⓘ
Get neighbors (members with direct connections)
Sourcepub fn add_faction(&mut self, faction: Faction)
pub fn add_faction(&mut self, faction: Faction)
Add a faction
Sourcepub fn get_faction(&self, faction_id: &FactionId) -> Option<&Faction>
pub fn get_faction(&self, faction_id: &FactionId) -> Option<&Faction>
Get a faction by ID (immutable)
Sourcepub fn get_faction_mut(
&mut self,
faction_id: &FactionId,
) -> Option<&mut Faction>
pub fn get_faction_mut( &mut self, faction_id: &FactionId, ) -> Option<&mut Faction>
Get a faction by ID (mutable)
Sourcepub fn remove_faction(&mut self, faction_id: &FactionId) -> Option<Faction>
pub fn remove_faction(&mut self, faction_id: &FactionId) -> Option<Faction>
Remove a faction
Sourcepub fn all_factions(&self) -> impl Iterator<Item = (&FactionId, &Faction)>
pub fn all_factions(&self) -> impl Iterator<Item = (&FactionId, &Faction)>
Get all factions
Sourcepub fn all_factions_mut(
&mut self,
) -> impl Iterator<Item = (&FactionId, &mut Faction)>
pub fn all_factions_mut( &mut self, ) -> impl Iterator<Item = (&FactionId, &mut Faction)>
Get all factions (mutable)
Sourcepub fn faction_count(&self) -> usize
pub fn faction_count(&self) -> usize
Get faction count
Sourcepub fn invalidate_centrality_cache(&mut self)
pub fn invalidate_centrality_cache(&mut self)
Invalidate centrality cache (call when network structure changes)
Sourcepub fn is_centrality_cache_valid(&self) -> bool
pub fn is_centrality_cache_valid(&self) -> bool
Check if centrality cache is valid
Sourcepub fn mark_centrality_cache_valid(&mut self, current_turn: u64)
pub fn mark_centrality_cache_valid(&mut self, current_turn: u64)
Mark centrality cache as valid (call after recalculation)
Sourcepub fn last_centrality_update(&self) -> u64
pub fn last_centrality_update(&self) -> u64
Get last centrality update turn
Sourcepub fn is_operational(&self) -> bool
pub fn is_operational(&self) -> bool
Check if network is operational (has sufficient members and connections)
Sourcepub fn calculate_graph_connectivity(&self) -> f32
pub fn calculate_graph_connectivity(&self) -> f32
Calculate graph connectivity (simple metric: relations / possible_relations)
Trait Implementations§
Source§impl Clone for SocialNetwork
impl Clone for SocialNetwork
Source§fn clone(&self) -> SocialNetwork
fn clone(&self) -> SocialNetwork
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SocialNetwork
impl Debug for SocialNetwork
Source§impl Default for SocialNetwork
impl Default for SocialNetwork
Source§fn default() -> SocialNetwork
fn default() -> SocialNetwork
Source§impl<'de> Deserialize<'de> for SocialNetwork
impl<'de> Deserialize<'de> for SocialNetwork
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>,
Auto Trait Implementations§
impl Freeze for SocialNetwork
impl RefUnwindSafe for SocialNetwork
impl Send for SocialNetwork
impl Sync for SocialNetwork
impl Unpin for SocialNetwork
impl UnsafeUnpin for SocialNetwork
impl UnwindSafe for SocialNetwork
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Component for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more