Skip to main content

CommunityAssignment

Struct CommunityAssignment 

Source
pub struct CommunityAssignment {
    pub map: BTreeMap<NodeId, CommunityId>,
    pub members: BTreeMap<CommunityId, Vec<NodeId>>,
    pub modularity: f32,
    pub seed: u64,
}
Expand description

Result of a community-detection run over an AdjacencyIndex.

Fields§

§map: BTreeMap<NodeId, CommunityId>

Canonical NodeId -> CommunityId map. Keyed by BTreeMap so iteration is deterministic (ascending NodeId).

§members: BTreeMap<CommunityId, Vec<NodeId>>

Inverse map CommunityId -> [NodeId]. Each member vector is sorted ascending (derived from BTreeMap iteration order over map). Precomputed at construction so members_of is O(1) lookup + O(|C|) slice return; the CommunityExpander stage (C3 FIX-1) needs this on the retrieval hot path.

§modularity: f32

Modularity score of this partition (higher is better; range [-0.5, 1.0] for undirected graphs).

§seed: u64

Seed that produced this partition. Threaded into content_cid so distinct seeds produce distinct CIDs even when the partition map happens to collide.

Implementations§

Source§

impl CommunityAssignment

Source

pub fn community_of(&self, node: NodeId) -> Option<CommunityId>

Look up the community of node. Returns None for nodes not present in any edge of the underlying graph.

Source

pub fn members_of(&self, community: CommunityId) -> &[NodeId]

All nodes assigned to community. Sorted ascending by NodeId for determinism. Empty slice if the id is unknown.

Source

pub fn community_count(&self) -> usize

Number of distinct communities.

Source

pub fn content_cid(&self) -> Cid

Content-addressable identity of this assignment.

CID preimage:

b"mnem/community/v1" || seed_be_u64 || concat(node_id_bytes || cid_be_u32)

where the (node, community) pairs iterate in ascending NodeId order (guaranteed by BTreeMap). Wrapped in CIDv1(codec=raw, multihash=sha2-256). Domain-separated from other mnem object classes by the leading tag.

Trait Implementations§

Source§

impl Clone for CommunityAssignment

Source§

fn clone(&self) -> CommunityAssignment

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommunityAssignment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more