pub struct LeidenPartition {
pub assignments: BTreeMap<usize, usize>,
pub stability: BTreeMap<usize, f64>,
pub modularity: f64,
pub seed: u64,
}Expand description
Leiden community detection result — re-exported from sdivi-detection for WASM embedders.
The result of a Leiden community detection run.
Community IDs are stable integers starting at zero, assigned in ascending order of the lowest node index within each community. This guarantees deterministic JSON output given the same input graph and seed.
§Examples
use sdivi_detection::partition::LeidenPartition;
use std::collections::BTreeMap;
let p = LeidenPartition {
assignments: BTreeMap::from([(0, 0), (1, 0), (2, 1)]),
stability: BTreeMap::from([(0, 0.8), (1, 1.0)]),
modularity: 0.42,
seed: 42,
};
assert_eq!(p.assignments[&0], 0);
assert_eq!(p.community_count(), 2);Fields§
§assignments: BTreeMap<usize, usize>Node index → community ID.
stability: BTreeMap<usize, f64>Community ID → stability score (internal edge density, [0, 1]).
modularity: f64Overall modularity of the final partition.
seed: u64Seed used to produce this partition.
Implementations§
Source§impl LeidenPartition
impl LeidenPartition
Sourcepub fn community_count(&self) -> usize
pub fn community_count(&self) -> usize
Number of communities in the partition.
Sourcepub fn community_of(&self, node: usize) -> Option<usize>
pub fn community_of(&self, node: usize) -> Option<usize>
Returns the community ID for node index node.
Sourcepub fn largest_community_size(&self) -> usize
pub fn largest_community_size(&self) -> usize
Returns the file path associated with the largest community (most nodes).
Trait Implementations§
Source§impl Clone for LeidenPartition
impl Clone for LeidenPartition
Source§fn clone(&self) -> LeidenPartition
fn clone(&self) -> LeidenPartition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LeidenPartition
impl Debug for LeidenPartition
Source§impl<'de> Deserialize<'de> for LeidenPartition
impl<'de> Deserialize<'de> for LeidenPartition
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LeidenPartition, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LeidenPartition, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for LeidenPartition
impl PartialEq for LeidenPartition
Source§fn eq(&self, other: &LeidenPartition) -> bool
fn eq(&self, other: &LeidenPartition) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for LeidenPartition
impl Serialize for LeidenPartition
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for LeidenPartition
Auto Trait Implementations§
impl Freeze for LeidenPartition
impl RefUnwindSafe for LeidenPartition
impl Send for LeidenPartition
impl Sync for LeidenPartition
impl Unpin for LeidenPartition
impl UnsafeUnpin for LeidenPartition
impl UnwindSafe for LeidenPartition
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