pedant_graph/analysis/limits.rs
1//! The ceilings one caller states before an analysis is built.
2
3/// How much work one analysis of one graph may cost.
4///
5/// A graph describes a repository someone else supplied, so every superlinear
6/// operation and every indexed allocation is admitted against a stated ceiling
7/// first. There is no default: an interactive editor, a CI job, and a batch
8/// run have different acceptable budgets, and a library that picked one would
9/// make that policy implicit.
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11pub struct GraphAnalysisLimits {
12 max_nodes: u32,
13 max_selected_edges: u32,
14 max_depth: u32,
15 max_betweenness_work: u64,
16}
17
18impl GraphAnalysisLimits {
19 /// Ceilings for the admitted node count, the admitted selected-edge count,
20 /// the depth one query may walk, and the betweenness work bound.
21 pub fn new(
22 max_nodes: u32,
23 max_selected_edges: u32,
24 max_depth: u32,
25 max_betweenness_work: u64,
26 ) -> Self {
27 Self {
28 max_nodes,
29 max_selected_edges,
30 max_depth,
31 max_betweenness_work,
32 }
33 }
34
35 /// The node ceiling analysis construction refuses above.
36 pub fn max_nodes(self) -> u32 {
37 self.max_nodes
38 }
39
40 /// The selected-edge ceiling analysis construction refuses above.
41 pub fn max_selected_edges(self) -> u32 {
42 self.max_selected_edges
43 }
44
45 /// The depth ceiling a neighborhood or subgraph query refuses above.
46 pub fn max_depth(self) -> u32 {
47 self.max_depth
48 }
49
50 /// The betweenness work bound centrality refuses above.
51 pub fn max_betweenness_work(self) -> u64 {
52 self.max_betweenness_work
53 }
54}