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: u8Maximum number of layers to produce; adjacent layers are merged until this cap is satisfied.
min_nodes_per_layer: u32Minimum node count per layer; tiny layers are absorbed into neighbours.
Implementations§
Source§impl LayerDetector
impl LayerDetector
Sourcepub fn new(max_layers: u8, min_nodes_per_layer: u32) -> Self
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.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a detector using DEFAULT_MAX_LAYERS and DEFAULT_MIN_NODES_PER_LAYER.
Sourcepub fn detect(
&self,
graph: &Graph,
scope: Option<&str>,
node_type_filter: &[NodeType],
exclude_tests: bool,
naming_strategy: &str,
) -> M1ndResult<LayerDetectionResult>
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: iftrue, 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.
Sourcepub fn layer_health(
&self,
graph: &Graph,
result: &LayerDetectionResult,
level: u8,
) -> M1ndResult<LayerHealth>
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 fordetect).result: theLayerDetectionResultto 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.