pub struct CoreDecomposition {
pub core_numbers: Vec<usize>,
pub shell_index: Vec<usize>,
pub max_core: usize,
pub num_nodes: usize,
}Expand description
k-core decomposition and k-shell index for undirected graphs.
The k-core of a graph is the maximal subgraph in which every node has
degree at least k. The core number (or coreness) of a node is the
largest k for which the node belongs to the k-core.
The k-shell consists of nodes with core number exactly k
(in the k-core but not in the (k+1)-core).
§Algorithm
Iterative degree peeling: repeatedly remove nodes with degree < k, starting from k=1 upwards.
§Time complexity
O(m) where m is the number of edges.
Fields§
§core_numbers: Vec<usize>Core number (coreness) of each node.
shell_index: Vec<usize>Shell index = core number (same as core number; kept separately for clarity).
max_core: usizeMaximum core number (degeneracy of the graph).
num_nodes: usizeNumber of nodes.
Implementations§
Source§impl CoreDecomposition
impl CoreDecomposition
Sourcepub fn compute(adj: &Array2<f64>) -> Self
pub fn compute(adj: &Array2<f64>) -> Self
Compute k-core decomposition from an adjacency matrix.
Sourcepub fn k_core_nodes(&self, k: usize) -> Vec<usize>
pub fn k_core_nodes(&self, k: usize) -> Vec<usize>
Return the set of node indices in the k-core (core number >= k).
Sourcepub fn k_shell_nodes(&self, k: usize) -> Vec<usize>
pub fn k_shell_nodes(&self, k: usize) -> Vec<usize>
Return the set of node indices in the k-shell (core number == k).
Sourcepub fn main_core_nodes(&self) -> Vec<usize>
pub fn main_core_nodes(&self) -> Vec<usize>
Return the main core (nodes with maximum core number).
Sourcepub fn degeneracy_ordering(&self) -> Vec<usize>
pub fn degeneracy_ordering(&self) -> Vec<usize>
Compute the degeneracy ordering (nodes ordered by core number ascending).
Sourcepub fn shell_distribution(&self) -> Vec<(usize, usize)>
pub fn shell_distribution(&self) -> Vec<(usize, usize)>
Compute the coreness distribution: number of nodes at each shell level.
Trait Implementations§
Source§impl Clone for CoreDecomposition
impl Clone for CoreDecomposition
Source§fn clone(&self) -> CoreDecomposition
fn clone(&self) -> CoreDecomposition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CoreDecomposition
impl RefUnwindSafe for CoreDecomposition
impl Send for CoreDecomposition
impl Sync for CoreDecomposition
impl Unpin for CoreDecomposition
impl UnsafeUnpin for CoreDecomposition
impl UnwindSafe for CoreDecomposition
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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