siriaisa 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- siriaisa-0.0.1/LICENSE +21 -0
- siriaisa-0.0.1/PKG-INFO +312 -0
- siriaisa-0.0.1/README.md +272 -0
- siriaisa-0.0.1/pyproject.toml +26 -0
- siriaisa-0.0.1/setup.cfg +4 -0
- siriaisa-0.0.1/setup.py +53 -0
- siriaisa-0.0.1/siriaisa/__init__.py +4 -0
- siriaisa-0.0.1/siriaisa/algorithm.py +151 -0
- siriaisa-0.0.1/siriaisa/app.py +99 -0
- siriaisa-0.0.1/siriaisa/applogger.py +80 -0
- siriaisa-0.0.1/siriaisa/approx.py +380 -0
- siriaisa-0.0.1/siriaisa/batch.py +53 -0
- siriaisa-0.0.1/siriaisa/parser.py +103 -0
- siriaisa-0.0.1/siriaisa/test.py +119 -0
- siriaisa-0.0.1/siriaisa/utils.py +242 -0
- siriaisa-0.0.1/siriaisa.egg-info/PKG-INFO +312 -0
- siriaisa-0.0.1/siriaisa.egg-info/SOURCES.txt +19 -0
- siriaisa-0.0.1/siriaisa.egg-info/dependency_links.txt +1 -0
- siriaisa-0.0.1/siriaisa.egg-info/entry_points.txt +4 -0
- siriaisa-0.0.1/siriaisa.egg-info/requires.txt +3 -0
- siriaisa-0.0.1/siriaisa.egg-info/top_level.txt +1 -0
siriaisa-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Frank Vega
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
siriaisa-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: siriaisa
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Compute the Approximate Independent Dominating Set for undirected graph encoded in DIMACS format.
|
|
5
|
+
Home-page: https://github.com/frankvegadelgado/mids
|
|
6
|
+
Author: Frank Vega
|
|
7
|
+
Author-email: vega.frank@gmail.com
|
|
8
|
+
License: MIT License
|
|
9
|
+
Project-URL: Source Code, https://github.com/frankvegadelgado/mids
|
|
10
|
+
Project-URL: Documentation Research, https://github.com/frankvegadelgado/mids
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Classifier: Topic :: Software Development
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: Education
|
|
19
|
+
Classifier: Intended Audience :: Information Technology
|
|
20
|
+
Classifier: Intended Audience :: Science/Research
|
|
21
|
+
Classifier: Natural Language :: English
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy>=2.2.1
|
|
26
|
+
Requires-Dist: scipy>=1.15.0
|
|
27
|
+
Requires-Dist: networkx[default]>=3.4.2
|
|
28
|
+
Dynamic: author
|
|
29
|
+
Dynamic: author-email
|
|
30
|
+
Dynamic: classifier
|
|
31
|
+
Dynamic: description
|
|
32
|
+
Dynamic: description-content-type
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: license
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: project-url
|
|
37
|
+
Dynamic: requires-dist
|
|
38
|
+
Dynamic: requires-python
|
|
39
|
+
Dynamic: summary
|
|
40
|
+
|
|
41
|
+
# Siriaisa: Approximate Independent Dominating Set Solver
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
This work builds upon [A 3-Approximation for Independent Dominating Sets: The Siriaisa Algorithm](https://github.com/frankvegadelgado/mids).
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
# Overview of the Minimum Independent Dominating Set (MIDS)
|
|
50
|
+
|
|
51
|
+
## Definition:
|
|
52
|
+
|
|
53
|
+
A **dominating set** in a graph $G = (V, E)$ is a subset $D \subseteq V$ such that every vertex not in $D$ is adjacent to at least one vertex in $D$. The **minimum independent dominating set (MIDS)** is the smallest possible dominating set in terms of the number of vertices.
|
|
54
|
+
|
|
55
|
+
## Key Concepts:
|
|
56
|
+
|
|
57
|
+
1. **Graph Representation**:
|
|
58
|
+
|
|
59
|
+
- $V$: Set of vertices.
|
|
60
|
+
- $E$: Set of edges connecting the vertices.
|
|
61
|
+
|
|
62
|
+
2. **Dominating Set**:
|
|
63
|
+
|
|
64
|
+
- A set $D$ where for every vertex $v \in V$, either $v \in D$ or $v$ is adjacent to some vertex in $D$.
|
|
65
|
+
|
|
66
|
+
3. **Minimum Independent Dominating Set**:
|
|
67
|
+
- The dominating set with the smallest cardinality (i.e., the fewest number of vertices).
|
|
68
|
+
|
|
69
|
+
## Applications:
|
|
70
|
+
|
|
71
|
+
- **Network Design**: Ensuring coverage in wireless sensor networks.
|
|
72
|
+
- **Social Networks**: Identifying influential nodes.
|
|
73
|
+
- **Game Theory**: Strategies in certain types of games.
|
|
74
|
+
- **Biology**: Modeling protein-protein interaction networks.
|
|
75
|
+
|
|
76
|
+
## Computational Complexity:
|
|
77
|
+
|
|
78
|
+
- **NP-Hard**: Finding the minimum independent dominating set is computationally intensive for large graphs.
|
|
79
|
+
- **Approximation Algorithms**: Used to find near-optimal solutions in polynomial time.
|
|
80
|
+
|
|
81
|
+
## Algorithms:
|
|
82
|
+
|
|
83
|
+
1. **Greedy Algorithm**:
|
|
84
|
+
|
|
85
|
+
- Iteratively selects the vertex that covers the most uncovered vertices.
|
|
86
|
+
- Provides a logarithmic approximation ratio.
|
|
87
|
+
|
|
88
|
+
2. **Integer Linear Programming (ILP)**:
|
|
89
|
+
|
|
90
|
+
- Formulates the problem as an optimization problem.
|
|
91
|
+
- Solvable using ILP solvers for exact solutions, though computationally expensive.
|
|
92
|
+
|
|
93
|
+
3. **Heuristics and Metaheuristics**:
|
|
94
|
+
- Genetic algorithms, simulated annealing, etc., for large-scale problems.
|
|
95
|
+
|
|
96
|
+
## Challenges:
|
|
97
|
+
|
|
98
|
+
- **Scalability**: Exact algorithms are infeasible for very large graphs.
|
|
99
|
+
- **Dynamic Graphs**: Maintaining a minimum independent dominating set in graphs that change over time.
|
|
100
|
+
|
|
101
|
+
## Research Directions:
|
|
102
|
+
|
|
103
|
+
- **Parallel Algorithms**: Leveraging multi-core processors and distributed computing.
|
|
104
|
+
- **Machine Learning**: Using learning-based approaches to predict dominating sets.
|
|
105
|
+
- **Hybrid Methods**: Combining exact and heuristic methods for better performance.
|
|
106
|
+
|
|
107
|
+
## Conclusion:
|
|
108
|
+
|
|
109
|
+
The minimum independent dominating set problem is a fundamental issue in graph theory with wide-ranging applications. While it is computationally challenging, various algorithms and heuristics provide practical solutions for different scenarios. Ongoing research continues to improve the efficiency and applicability of these methods.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Problem Statement
|
|
114
|
+
|
|
115
|
+
Input: A Boolean Adjacency Matrix $M$.
|
|
116
|
+
|
|
117
|
+
Answer: Find a Minimum Independent Dominating Set.
|
|
118
|
+
|
|
119
|
+
### Example Instance: 5 x 5 matrix
|
|
120
|
+
|
|
121
|
+
| | c1 | c2 | c3 | c4 | c5 |
|
|
122
|
+
| ------ | --- | --- | --- | --- | --- |
|
|
123
|
+
| **r1** | 0 | 0 | 1 | 0 | 1 |
|
|
124
|
+
| **r2** | 0 | 0 | 0 | 1 | 0 |
|
|
125
|
+
| **r3** | 1 | 0 | 0 | 0 | 1 |
|
|
126
|
+
| **r4** | 0 | 1 | 0 | 0 | 0 |
|
|
127
|
+
| **r5** | 1 | 0 | 1 | 0 | 0 |
|
|
128
|
+
|
|
129
|
+
The input for undirected graph is typically provided in [DIMACS](http://dimacs.rutgers.edu/Challenges) format. In this way, the previous adjacency matrix is represented in a text file using the following string representation:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
p edge 5 4
|
|
133
|
+
e 1 3
|
|
134
|
+
e 1 5
|
|
135
|
+
e 2 4
|
|
136
|
+
e 3 5
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This represents a 5x5 matrix in DIMACS format such that each edge $(v,w)$ appears exactly once in the input file and is not repeated as $(w,v)$. In this format, every edge appears in the form of
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
e W V
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
where the fields W and V specify the endpoints of the edge while the lower-case character `e` signifies that this is an edge descriptor line.
|
|
146
|
+
|
|
147
|
+
_Example Solution:_
|
|
148
|
+
|
|
149
|
+
Independent Dominating Set Found `1, 4`: Nodes `1` and `4` constitute an optimal solution.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
# Compile and Environment
|
|
154
|
+
|
|
155
|
+
## Prerequisites
|
|
156
|
+
|
|
157
|
+
- Python >= 3.12
|
|
158
|
+
|
|
159
|
+
## Installation
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pip install siriaisa
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Execution
|
|
166
|
+
|
|
167
|
+
1. Clone the repository:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
git clone https://github.com/frankvegadelgado/mids.git
|
|
171
|
+
cd mids
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. Run the script:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
iris -i ./benchmarks/testMatrix1
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
utilizing the `iris` command provided by Siriaisa's library to execute the Boolean adjacency matrix `mids\benchmarks\testMatrix1`. The file `testMatrix1` represents the example described herein. We also support `.xz`, `.lzma`, `.bz2`, and `.bzip2` compressed text files.
|
|
181
|
+
|
|
182
|
+
**Example Output:**
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
testMatrix1: Independent Dominating Set Found 1, 4
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
This indicates nodes `1, 4` form a Independent Dominating Set.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Independent Dominating Set Size
|
|
193
|
+
|
|
194
|
+
Use the `-c` flag to count the nodes in the Independent Dominating Set:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
iris -i ./benchmarks/testMatrix2 -c
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Output:**
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
testMatrix2: Independent Dominating Set Size 2
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
# Command Options
|
|
209
|
+
|
|
210
|
+
Display help and options:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
iris -h
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Output:**
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
usage: iris [-h] -i INPUTFILE [-a] [-b] [-c] [-v] [-l] [--version]
|
|
220
|
+
|
|
221
|
+
Solve the Approximate Independent Dominating Set for undirected graph encoded in DIMACS format.
|
|
222
|
+
|
|
223
|
+
options:
|
|
224
|
+
-h, --help show this help message and exit
|
|
225
|
+
-i INPUTFILE, --inputFile INPUTFILE
|
|
226
|
+
input file path
|
|
227
|
+
-a, --approximation enable comparison with a polynomial-time approximation approach within a maximum degree factor
|
|
228
|
+
-b, --bruteForce enable comparison with the exponential-time brute-force approach
|
|
229
|
+
-c, --count calculate the size of the Independent Dominating Set
|
|
230
|
+
-v, --verbose enable verbose output
|
|
231
|
+
-l, --log enable file logging
|
|
232
|
+
--version show program's version number and exit
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
# Batch Execution
|
|
238
|
+
|
|
239
|
+
Batch execution allows you to solve multiple graphs within a directory consecutively.
|
|
240
|
+
|
|
241
|
+
To view available command-line options for the `batch_iris` command, use the following in your terminal or command prompt:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
batch_iris -h
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
This will display the following help information:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
usage: batch_iris [-h] -i INPUTDIRECTORY [-a] [-b] [-c] [-v] [-l] [--version]
|
|
251
|
+
|
|
252
|
+
Solve the Approximate Independent Dominating Set for all undirected graphs encoded in DIMACS format and stored in a directory.
|
|
253
|
+
|
|
254
|
+
options:
|
|
255
|
+
-h, --help show this help message and exit
|
|
256
|
+
-i INPUTDIRECTORY, --inputDirectory INPUTDIRECTORY
|
|
257
|
+
Input directory path
|
|
258
|
+
-a, --approximation enable comparison with a polynomial-time approximation approach within a maximum degree factor
|
|
259
|
+
-b, --bruteForce enable comparison with the exponential-time brute-force approach
|
|
260
|
+
-c, --count calculate the size of the Independent Dominating Set
|
|
261
|
+
-v, --verbose enable verbose output
|
|
262
|
+
-l, --log enable file logging
|
|
263
|
+
--version show program's version number and exit
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
# Testing Application
|
|
269
|
+
|
|
270
|
+
A command-line utility named `test_iris` is provided for evaluating the Algorithm using randomly generated, large sparse matrices. It supports the following options:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
usage: test_iris [-h] -d DIMENSION [-n NUM_TESTS] [-s SPARSITY] [-a] [-b] [-c] [-w] [-v] [-l] [--version]
|
|
274
|
+
|
|
275
|
+
The Siriaisa Testing Application using randomly generated, large sparse matrices.
|
|
276
|
+
|
|
277
|
+
options:
|
|
278
|
+
-h, --help show this help message and exit
|
|
279
|
+
-d DIMENSION, --dimension DIMENSION
|
|
280
|
+
an integer specifying the dimensions of the square matrices
|
|
281
|
+
-n NUM_TESTS, --num_tests NUM_TESTS
|
|
282
|
+
an integer specifying the number of tests to run
|
|
283
|
+
-s SPARSITY, --sparsity SPARSITY
|
|
284
|
+
sparsity of the matrices (0.0 for dense, close to 1.0 for very sparse)
|
|
285
|
+
-a, --approximation enable comparison with a polynomial-time approximation approach within a maximum degree factor
|
|
286
|
+
-b, --bruteForce enable comparison with the exponential-time brute-force approach
|
|
287
|
+
-c, --count calculate the size of the Independent Dominating Set
|
|
288
|
+
-w, --write write the generated random matrix to a file in the current directory
|
|
289
|
+
-v, --verbose enable verbose output
|
|
290
|
+
-l, --log enable file logging
|
|
291
|
+
--version show program's version number and exit
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
# Code
|
|
297
|
+
|
|
298
|
+
- Python implementation by **Frank Vega**.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
# Complexity
|
|
303
|
+
|
|
304
|
+
```diff
|
|
305
|
+
+ Siriaisa separates feasibility from the approximation certificate: every returned set is verified as independent and dominating, while a universal proof of the 3-approximation certificate would imply P = NP by known MIDS inapproximability results.
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
# License
|
|
311
|
+
|
|
312
|
+
- MIT License.
|
siriaisa-0.0.1/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Siriaisa: Approximate Independent Dominating Set Solver
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
This work builds upon [A 3-Approximation for Independent Dominating Sets: The Siriaisa Algorithm](https://github.com/frankvegadelgado/mids).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Overview of the Minimum Independent Dominating Set (MIDS)
|
|
10
|
+
|
|
11
|
+
## Definition:
|
|
12
|
+
|
|
13
|
+
A **dominating set** in a graph $G = (V, E)$ is a subset $D \subseteq V$ such that every vertex not in $D$ is adjacent to at least one vertex in $D$. The **minimum independent dominating set (MIDS)** is the smallest possible dominating set in terms of the number of vertices.
|
|
14
|
+
|
|
15
|
+
## Key Concepts:
|
|
16
|
+
|
|
17
|
+
1. **Graph Representation**:
|
|
18
|
+
|
|
19
|
+
- $V$: Set of vertices.
|
|
20
|
+
- $E$: Set of edges connecting the vertices.
|
|
21
|
+
|
|
22
|
+
2. **Dominating Set**:
|
|
23
|
+
|
|
24
|
+
- A set $D$ where for every vertex $v \in V$, either $v \in D$ or $v$ is adjacent to some vertex in $D$.
|
|
25
|
+
|
|
26
|
+
3. **Minimum Independent Dominating Set**:
|
|
27
|
+
- The dominating set with the smallest cardinality (i.e., the fewest number of vertices).
|
|
28
|
+
|
|
29
|
+
## Applications:
|
|
30
|
+
|
|
31
|
+
- **Network Design**: Ensuring coverage in wireless sensor networks.
|
|
32
|
+
- **Social Networks**: Identifying influential nodes.
|
|
33
|
+
- **Game Theory**: Strategies in certain types of games.
|
|
34
|
+
- **Biology**: Modeling protein-protein interaction networks.
|
|
35
|
+
|
|
36
|
+
## Computational Complexity:
|
|
37
|
+
|
|
38
|
+
- **NP-Hard**: Finding the minimum independent dominating set is computationally intensive for large graphs.
|
|
39
|
+
- **Approximation Algorithms**: Used to find near-optimal solutions in polynomial time.
|
|
40
|
+
|
|
41
|
+
## Algorithms:
|
|
42
|
+
|
|
43
|
+
1. **Greedy Algorithm**:
|
|
44
|
+
|
|
45
|
+
- Iteratively selects the vertex that covers the most uncovered vertices.
|
|
46
|
+
- Provides a logarithmic approximation ratio.
|
|
47
|
+
|
|
48
|
+
2. **Integer Linear Programming (ILP)**:
|
|
49
|
+
|
|
50
|
+
- Formulates the problem as an optimization problem.
|
|
51
|
+
- Solvable using ILP solvers for exact solutions, though computationally expensive.
|
|
52
|
+
|
|
53
|
+
3. **Heuristics and Metaheuristics**:
|
|
54
|
+
- Genetic algorithms, simulated annealing, etc., for large-scale problems.
|
|
55
|
+
|
|
56
|
+
## Challenges:
|
|
57
|
+
|
|
58
|
+
- **Scalability**: Exact algorithms are infeasible for very large graphs.
|
|
59
|
+
- **Dynamic Graphs**: Maintaining a minimum independent dominating set in graphs that change over time.
|
|
60
|
+
|
|
61
|
+
## Research Directions:
|
|
62
|
+
|
|
63
|
+
- **Parallel Algorithms**: Leveraging multi-core processors and distributed computing.
|
|
64
|
+
- **Machine Learning**: Using learning-based approaches to predict dominating sets.
|
|
65
|
+
- **Hybrid Methods**: Combining exact and heuristic methods for better performance.
|
|
66
|
+
|
|
67
|
+
## Conclusion:
|
|
68
|
+
|
|
69
|
+
The minimum independent dominating set problem is a fundamental issue in graph theory with wide-ranging applications. While it is computationally challenging, various algorithms and heuristics provide practical solutions for different scenarios. Ongoing research continues to improve the efficiency and applicability of these methods.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Problem Statement
|
|
74
|
+
|
|
75
|
+
Input: A Boolean Adjacency Matrix $M$.
|
|
76
|
+
|
|
77
|
+
Answer: Find a Minimum Independent Dominating Set.
|
|
78
|
+
|
|
79
|
+
### Example Instance: 5 x 5 matrix
|
|
80
|
+
|
|
81
|
+
| | c1 | c2 | c3 | c4 | c5 |
|
|
82
|
+
| ------ | --- | --- | --- | --- | --- |
|
|
83
|
+
| **r1** | 0 | 0 | 1 | 0 | 1 |
|
|
84
|
+
| **r2** | 0 | 0 | 0 | 1 | 0 |
|
|
85
|
+
| **r3** | 1 | 0 | 0 | 0 | 1 |
|
|
86
|
+
| **r4** | 0 | 1 | 0 | 0 | 0 |
|
|
87
|
+
| **r5** | 1 | 0 | 1 | 0 | 0 |
|
|
88
|
+
|
|
89
|
+
The input for undirected graph is typically provided in [DIMACS](http://dimacs.rutgers.edu/Challenges) format. In this way, the previous adjacency matrix is represented in a text file using the following string representation:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
p edge 5 4
|
|
93
|
+
e 1 3
|
|
94
|
+
e 1 5
|
|
95
|
+
e 2 4
|
|
96
|
+
e 3 5
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This represents a 5x5 matrix in DIMACS format such that each edge $(v,w)$ appears exactly once in the input file and is not repeated as $(w,v)$. In this format, every edge appears in the form of
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
e W V
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
where the fields W and V specify the endpoints of the edge while the lower-case character `e` signifies that this is an edge descriptor line.
|
|
106
|
+
|
|
107
|
+
_Example Solution:_
|
|
108
|
+
|
|
109
|
+
Independent Dominating Set Found `1, 4`: Nodes `1` and `4` constitute an optimal solution.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
# Compile and Environment
|
|
114
|
+
|
|
115
|
+
## Prerequisites
|
|
116
|
+
|
|
117
|
+
- Python >= 3.12
|
|
118
|
+
|
|
119
|
+
## Installation
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pip install siriaisa
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Execution
|
|
126
|
+
|
|
127
|
+
1. Clone the repository:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
git clone https://github.com/frankvegadelgado/mids.git
|
|
131
|
+
cd mids
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
2. Run the script:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
iris -i ./benchmarks/testMatrix1
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
utilizing the `iris` command provided by Siriaisa's library to execute the Boolean adjacency matrix `mids\benchmarks\testMatrix1`. The file `testMatrix1` represents the example described herein. We also support `.xz`, `.lzma`, `.bz2`, and `.bzip2` compressed text files.
|
|
141
|
+
|
|
142
|
+
**Example Output:**
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
testMatrix1: Independent Dominating Set Found 1, 4
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This indicates nodes `1, 4` form a Independent Dominating Set.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Independent Dominating Set Size
|
|
153
|
+
|
|
154
|
+
Use the `-c` flag to count the nodes in the Independent Dominating Set:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
iris -i ./benchmarks/testMatrix2 -c
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Output:**
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
testMatrix2: Independent Dominating Set Size 2
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
# Command Options
|
|
169
|
+
|
|
170
|
+
Display help and options:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
iris -h
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Output:**
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
usage: iris [-h] -i INPUTFILE [-a] [-b] [-c] [-v] [-l] [--version]
|
|
180
|
+
|
|
181
|
+
Solve the Approximate Independent Dominating Set for undirected graph encoded in DIMACS format.
|
|
182
|
+
|
|
183
|
+
options:
|
|
184
|
+
-h, --help show this help message and exit
|
|
185
|
+
-i INPUTFILE, --inputFile INPUTFILE
|
|
186
|
+
input file path
|
|
187
|
+
-a, --approximation enable comparison with a polynomial-time approximation approach within a maximum degree factor
|
|
188
|
+
-b, --bruteForce enable comparison with the exponential-time brute-force approach
|
|
189
|
+
-c, --count calculate the size of the Independent Dominating Set
|
|
190
|
+
-v, --verbose enable verbose output
|
|
191
|
+
-l, --log enable file logging
|
|
192
|
+
--version show program's version number and exit
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# Batch Execution
|
|
198
|
+
|
|
199
|
+
Batch execution allows you to solve multiple graphs within a directory consecutively.
|
|
200
|
+
|
|
201
|
+
To view available command-line options for the `batch_iris` command, use the following in your terminal or command prompt:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
batch_iris -h
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
This will display the following help information:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
usage: batch_iris [-h] -i INPUTDIRECTORY [-a] [-b] [-c] [-v] [-l] [--version]
|
|
211
|
+
|
|
212
|
+
Solve the Approximate Independent Dominating Set for all undirected graphs encoded in DIMACS format and stored in a directory.
|
|
213
|
+
|
|
214
|
+
options:
|
|
215
|
+
-h, --help show this help message and exit
|
|
216
|
+
-i INPUTDIRECTORY, --inputDirectory INPUTDIRECTORY
|
|
217
|
+
Input directory path
|
|
218
|
+
-a, --approximation enable comparison with a polynomial-time approximation approach within a maximum degree factor
|
|
219
|
+
-b, --bruteForce enable comparison with the exponential-time brute-force approach
|
|
220
|
+
-c, --count calculate the size of the Independent Dominating Set
|
|
221
|
+
-v, --verbose enable verbose output
|
|
222
|
+
-l, --log enable file logging
|
|
223
|
+
--version show program's version number and exit
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
# Testing Application
|
|
229
|
+
|
|
230
|
+
A command-line utility named `test_iris` is provided for evaluating the Algorithm using randomly generated, large sparse matrices. It supports the following options:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
usage: test_iris [-h] -d DIMENSION [-n NUM_TESTS] [-s SPARSITY] [-a] [-b] [-c] [-w] [-v] [-l] [--version]
|
|
234
|
+
|
|
235
|
+
The Siriaisa Testing Application using randomly generated, large sparse matrices.
|
|
236
|
+
|
|
237
|
+
options:
|
|
238
|
+
-h, --help show this help message and exit
|
|
239
|
+
-d DIMENSION, --dimension DIMENSION
|
|
240
|
+
an integer specifying the dimensions of the square matrices
|
|
241
|
+
-n NUM_TESTS, --num_tests NUM_TESTS
|
|
242
|
+
an integer specifying the number of tests to run
|
|
243
|
+
-s SPARSITY, --sparsity SPARSITY
|
|
244
|
+
sparsity of the matrices (0.0 for dense, close to 1.0 for very sparse)
|
|
245
|
+
-a, --approximation enable comparison with a polynomial-time approximation approach within a maximum degree factor
|
|
246
|
+
-b, --bruteForce enable comparison with the exponential-time brute-force approach
|
|
247
|
+
-c, --count calculate the size of the Independent Dominating Set
|
|
248
|
+
-w, --write write the generated random matrix to a file in the current directory
|
|
249
|
+
-v, --verbose enable verbose output
|
|
250
|
+
-l, --log enable file logging
|
|
251
|
+
--version show program's version number and exit
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
# Code
|
|
257
|
+
|
|
258
|
+
- Python implementation by **Frank Vega**.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
# Complexity
|
|
263
|
+
|
|
264
|
+
```diff
|
|
265
|
+
+ Siriaisa separates feasibility from the approximation certificate: every returned set is verified as independent and dominating, while a universal proof of the 3-approximation certificate would imply P = NP by known MIDS inapproximability results.
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
# License
|
|
271
|
+
|
|
272
|
+
- MIT License.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[tool.ruff]
|
|
2
|
+
exclude = [".git", ".vscode", ".pytest_cache", ".mypy_cache", ".env"]
|
|
3
|
+
line-length = 125
|
|
4
|
+
|
|
5
|
+
[tool.ruff.lint]
|
|
6
|
+
ignore = ["B008", "ISC001", "E501", "W191"]
|
|
7
|
+
select = [
|
|
8
|
+
"B",
|
|
9
|
+
"E",
|
|
10
|
+
"F",
|
|
11
|
+
"W",
|
|
12
|
+
"I",
|
|
13
|
+
"N",
|
|
14
|
+
"C4",
|
|
15
|
+
"EXE",
|
|
16
|
+
"ISC",
|
|
17
|
+
"ICN",
|
|
18
|
+
"PIE",
|
|
19
|
+
"PT",
|
|
20
|
+
"RET",
|
|
21
|
+
"SIM",
|
|
22
|
+
"ERA",
|
|
23
|
+
"PLC",
|
|
24
|
+
"RUF",
|
|
25
|
+
"ARG",
|
|
26
|
+
]
|
siriaisa-0.0.1/setup.cfg
ADDED
siriaisa-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import setuptools
|
|
4
|
+
|
|
5
|
+
VERSION = "0.0.1"
|
|
6
|
+
|
|
7
|
+
NAME = "siriaisa"
|
|
8
|
+
|
|
9
|
+
INSTALL_REQUIRES = [
|
|
10
|
+
"numpy>=2.2.1",
|
|
11
|
+
"scipy>=1.15.0",
|
|
12
|
+
"networkx[default]>=3.4.2"
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
setuptools.setup(
|
|
16
|
+
name=NAME,
|
|
17
|
+
version=VERSION,
|
|
18
|
+
description="Compute the Approximate Independent Dominating Set for undirected graph encoded in DIMACS format.",
|
|
19
|
+
url="https://github.com/frankvegadelgado/mids",
|
|
20
|
+
project_urls={
|
|
21
|
+
"Source Code": "https://github.com/frankvegadelgado/mids",
|
|
22
|
+
"Documentation Research": "https://github.com/frankvegadelgado/mids",
|
|
23
|
+
},
|
|
24
|
+
author="Frank Vega",
|
|
25
|
+
author_email="vega.frank@gmail.com",
|
|
26
|
+
license="MIT License",
|
|
27
|
+
classifiers=[
|
|
28
|
+
"Topic :: Scientific/Engineering",
|
|
29
|
+
"Topic :: Software Development",
|
|
30
|
+
"Development Status :: 5 - Production/Stable",
|
|
31
|
+
"License :: OSI Approved :: MIT License",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"Environment :: Console",
|
|
34
|
+
"Intended Audience :: Developers",
|
|
35
|
+
"Intended Audience :: Education",
|
|
36
|
+
"Intended Audience :: Information Technology",
|
|
37
|
+
"Intended Audience :: Science/Research",
|
|
38
|
+
"Natural Language :: English",
|
|
39
|
+
],
|
|
40
|
+
python_requires=">=3.12",
|
|
41
|
+
# Requirements
|
|
42
|
+
install_requires=INSTALL_REQUIRES,
|
|
43
|
+
packages=["siriaisa"],
|
|
44
|
+
long_description=Path("README.md").read_text(),
|
|
45
|
+
long_description_content_type="text/markdown",
|
|
46
|
+
entry_points={
|
|
47
|
+
'console_scripts': [
|
|
48
|
+
'iris = siriaisa.app:main',
|
|
49
|
+
'test_iris = siriaisa.test:main',
|
|
50
|
+
'batch_iris = siriaisa.batch:main'
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
)
|