Skip to main content

LayerDetector

Struct LayerDetector 

Source
pub struct LayerDetector {
    pub max_layers: u8,
    pub min_nodes_per_layer: u32,
}
Expand description

Architectural layer detector.

Runs a multi-phase pipeline: Tarjan SCC → BFS depth assignment → layer grouping + merging → utility-node detection → violation detection.

Fields§

§max_layers: u8

Maximum number of layers to produce; adjacent layers are merged until this cap is satisfied.

§min_nodes_per_layer: u32

Minimum node count per layer; tiny layers are absorbed into neighbours.

Implementations§

Source§

impl LayerDetector

Source

pub fn new(max_layers: u8, min_nodes_per_layer: u32) -> Self

Create a detector with the given parameters.

§Parameters
  • max_layers: upper bound on the number of output layers.
  • min_nodes_per_layer: layers smaller than this are merged into an adjacent layer.
Source

pub fn with_defaults() -> Self

Create a detector using DEFAULT_MAX_LAYERS and DEFAULT_MIN_NODES_PER_LAYER.

Source

pub fn detect( &self, graph: &Graph, scope: Option<&str>, node_type_filter: &[NodeType], exclude_tests: bool, naming_strategy: &str, ) -> M1ndResult<LayerDetectionResult>

Detect architectural layers from graph topology.

Algorithm: Tarjan SCC → BFS depth assignment → layer grouping + merging → utility-node detection → violation detection.

§Parameters
  • graph: the connectivity graph to analyse.
  • scope: optional path prefix to restrict which nodes are considered.
  • node_type_filter: if non-empty, only nodes of these types are included.
  • exclude_tests: if true, nodes whose labels contain “test” are dropped.
  • naming_strategy: one of "heuristic", "path_prefix", or "pagerank".
§Errors

Returns M1ndError::EmptyGraph if no candidate nodes match the filters.

Source

pub fn layer_health( &self, graph: &Graph, result: &LayerDetectionResult, level: u8, ) -> M1ndResult<LayerHealth>

Compute cohesion, coupling, and violation-density metrics for one layer.

§Parameters
  • graph: the connectivity graph (must be the same graph used for detect).
  • result: the LayerDetectionResult to pull layer membership from.
  • level: zero-based layer level to analyse.
§Errors

Returns M1ndError::LayerNotFound { level } if no layer with that level exists in result.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.