Coverage for src/abcd_graph/params.py: 100%
34 statements
« prev ^ index » next coverage.py v7.5.3, created at 2024-11-17 23:31 +0100
« prev ^ index » next coverage.py v7.5.3, created at 2024-11-17 23:31 +0100
1# Copyright (c) 2024 Jordan Barrett & Aleksander Wojnarowicz
2#
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included in all
11# copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
21__all__ = ["ABCDParams"]
23from dataclasses import dataclass
26@dataclass
27class ABCDParams:
28 vcount: int = 1000
29 gamma: float = 2.5
30 beta: float = 1.5
31 xi: float = 0.25
32 min_degree: int = 5
33 max_degree: int = 30
34 min_community_size: int = 20
35 max_community_size: int = 250
36 num_outliers: int = 0
38 def __post_init__(self) -> None:
39 if self.vcount < 1 or not isinstance(self.vcount, int):
40 raise ValueError("vcount must be a positive integer")
42 if self.gamma < 2 or self.gamma > 3:
43 raise ValueError("gamma must be between 2 and 3")
45 if self.beta < 1 or self.beta > 2:
46 raise ValueError("beta must be between 1 and 2")
48 if self.xi < 0 or self.xi > 1:
49 raise ValueError("xi must be between 0 and 1")
51 if self.min_degree < 1 or self.min_degree > self.max_degree:
52 raise ValueError("min_degree must be between 1 and max_degree")
54 if self.max_degree >= self.max_community_size:
55 raise ValueError("max_degree must be less than max_community_size")
57 if self.min_community_size < self.min_degree or self.min_community_size > self.max_community_size:
58 raise ValueError("min_community_size must be between min_degree and max_community_size")
60 if self.num_outliers < 0:
61 raise ValueError("num_outliers must be non-negative")
63 if self.num_outliers > self.vcount:
64 raise ValueError("num_outliers must be less than vcount")
66 if self.max_community_size > self.vcount - self.num_outliers:
67 raise ValueError("max_community_size must be less than n")