alonso 0.0.3__tar.gz → 0.0.5__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.
- {alonso-0.0.3 → alonso-0.0.5}/PKG-INFO +3 -3
- {alonso-0.0.3 → alonso-0.0.5}/README.md +1 -1
- {alonso-0.0.3 → alonso-0.0.5}/alonso/algorithm.py +21 -23
- {alonso-0.0.3 → alonso-0.0.5}/alonso/app.py +1 -1
- {alonso-0.0.3 → alonso-0.0.5}/alonso/batch.py +1 -1
- {alonso-0.0.3 → alonso-0.0.5}/alonso/test.py +1 -1
- {alonso-0.0.3 → alonso-0.0.5}/alonso.egg-info/PKG-INFO +3 -3
- alonso-0.0.5/alonso.egg-info/requires.txt +1 -0
- {alonso-0.0.3 → alonso-0.0.5}/setup.py +2 -2
- alonso-0.0.3/alonso.egg-info/requires.txt +0 -1
- {alonso-0.0.3 → alonso-0.0.5}/LICENSE +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso/__init__.py +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso/applogger.py +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso/merge.py +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso/parser.py +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso/partition.py +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso/stable.py +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso/utils.py +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso.egg-info/SOURCES.txt +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso.egg-info/dependency_links.txt +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso.egg-info/entry_points.txt +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/alonso.egg-info/top_level.txt +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/pyproject.toml +0 -0
- {alonso-0.0.3 → alonso-0.0.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: alonso
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.5
|
4
4
|
Summary: Compute an Approximate Vertex Cover for undirected graph encoded in DIMACS format.
|
5
5
|
Home-page: https://github.com/frankvegadelgado/alonso
|
6
6
|
Author: Frank Vega
|
@@ -22,7 +22,7 @@ Classifier: Natural Language :: English
|
|
22
22
|
Requires-Python: >=3.10
|
23
23
|
Description-Content-Type: text/markdown
|
24
24
|
License-File: LICENSE
|
25
|
-
Requires-Dist: mendive>=0.0.
|
25
|
+
Requires-Dist: mendive>=0.0.5
|
26
26
|
Dynamic: author
|
27
27
|
Dynamic: author-email
|
28
28
|
Dynamic: classifier
|
@@ -69,7 +69,7 @@ Given an undirected graph $G = (V, E)$, a **vertex cover** is a subset $V' \subs
|
|
69
69
|
|
70
70
|
# Overview of the Algorithm and Its Running Time
|
71
71
|
|
72
|
-
The `find_vertex_cover` algorithm approximates a minimum vertex cover for an undirected graph $G = (V, E)$ by partitioning its edges into two claw-free subgraphs using the Burr-Erdős-Lovász (1976) method, computing exact vertex covers for these subgraphs with the Faenza, Oriolo, and Stauffer (2011) approach, and recursively refining the solution on residual edges. This process prevents the ratio from reaching 2, leveraging overlap between subgraphs and minimal additions in recursion. The algorithm begins by cleaning the graph (removing self-loops and isolates in
|
72
|
+
The `find_vertex_cover` algorithm approximates a minimum vertex cover for an undirected graph $G = (V, E)$ by partitioning its edges into two claw-free subgraphs using the Burr-Erdős-Lovász (1976) method, computing exact vertex covers for these subgraphs with the Faenza, Oriolo, and Stauffer (2011) approach, and recursively refining the solution on residual edges. This process prevents the ratio from reaching 2, leveraging overlap between subgraphs and minimal additions in recursion. The algorithm begins by cleaning the graph (removing self-loops and isolates in $O(n + m)$), checking for claw-free in $O(m \cdot \Delta)$, partitions edges in $O(m \cdot (m \cdot \Delta \cdot C + C^2))$ where $\Delta$ is the maximum degree and $C$ is the number of claws, computes vertex covers in $O(n^3)$ per subgraph (total $O(n^3)$), merges covers in $O(n \cdot \log n)$, and constructs the residual graph in $O(m)$. The recursive nature, with a worst-case depth of $O(m)$ if each step covers one edge, yields a total runtime of $O(n^3 m)$, dominated by the cubic cost across levels. For sparse graphs ($m = O(n)$), this simplifies to $O(n^4)$.
|
73
73
|
|
74
74
|
---
|
75
75
|
|
@@ -31,7 +31,7 @@ Given an undirected graph $G = (V, E)$, a **vertex cover** is a subset $V' \subs
|
|
31
31
|
|
32
32
|
# Overview of the Algorithm and Its Running Time
|
33
33
|
|
34
|
-
The `find_vertex_cover` algorithm approximates a minimum vertex cover for an undirected graph $G = (V, E)$ by partitioning its edges into two claw-free subgraphs using the Burr-Erdős-Lovász (1976) method, computing exact vertex covers for these subgraphs with the Faenza, Oriolo, and Stauffer (2011) approach, and recursively refining the solution on residual edges. This process prevents the ratio from reaching 2, leveraging overlap between subgraphs and minimal additions in recursion. The algorithm begins by cleaning the graph (removing self-loops and isolates in
|
34
|
+
The `find_vertex_cover` algorithm approximates a minimum vertex cover for an undirected graph $G = (V, E)$ by partitioning its edges into two claw-free subgraphs using the Burr-Erdős-Lovász (1976) method, computing exact vertex covers for these subgraphs with the Faenza, Oriolo, and Stauffer (2011) approach, and recursively refining the solution on residual edges. This process prevents the ratio from reaching 2, leveraging overlap between subgraphs and minimal additions in recursion. The algorithm begins by cleaning the graph (removing self-loops and isolates in $O(n + m)$), checking for claw-free in $O(m \cdot \Delta)$, partitions edges in $O(m \cdot (m \cdot \Delta \cdot C + C^2))$ where $\Delta$ is the maximum degree and $C$ is the number of claws, computes vertex covers in $O(n^3)$ per subgraph (total $O(n^3)$), merges covers in $O(n \cdot \log n)$, and constructs the residual graph in $O(m)$. The recursive nature, with a worst-case depth of $O(m)$ if each step covers one edge, yields a total runtime of $O(n^3 m)$, dominated by the cubic cost across levels. For sparse graphs ($m = O(n)$), this simplifies to $O(n^4)$.
|
35
35
|
|
36
36
|
---
|
37
37
|
|
@@ -24,54 +24,52 @@ def find_vertex_cover(graph):
|
|
24
24
|
# Validate that the input is a valid undirected NetworkX graph
|
25
25
|
if not isinstance(graph, nx.Graph):
|
26
26
|
raise ValueError("Input must be an undirected NetworkX Graph.")
|
27
|
-
|
27
|
+
|
28
28
|
# Handle trivial cases: return empty set for graphs with no nodes or no edges
|
29
29
|
if graph.number_of_nodes() == 0 or graph.number_of_edges() == 0:
|
30
30
|
return set() # No vertices or edges mean no cover is needed
|
31
|
-
|
31
|
+
|
32
32
|
# Create a working copy to avoid modifying the original graph
|
33
33
|
working_graph = graph.copy()
|
34
|
-
|
34
|
+
|
35
35
|
# Remove self-loops as they are irrelevant for vertex cover computation
|
36
36
|
working_graph.remove_edges_from(list(nx.selfloop_edges(working_graph)))
|
37
|
-
|
37
|
+
|
38
38
|
# Remove isolated nodes (degree 0) since they don't contribute to the vertex cover
|
39
39
|
working_graph.remove_nodes_from(list(nx.isolates(working_graph)))
|
40
|
-
|
40
|
+
|
41
41
|
# Return empty set if the cleaned graph has no nodes after removals
|
42
42
|
if working_graph.number_of_nodes() == 0:
|
43
43
|
return set()
|
44
|
-
|
45
|
-
# Structural analysis: detect presence of claw subgraphs
|
44
|
+
|
45
|
+
# Structural analysis: detect presence of claw subgraphs
|
46
46
|
# This determines which algorithmic approach to use
|
47
47
|
claw = algo.find_claw_coordinates(working_graph, first_claw=True)
|
48
|
-
|
48
|
+
|
49
49
|
if claw is None:
|
50
50
|
# CASE 1: Claw-free graph - use polynomial-time exact algorithm
|
51
51
|
# Apply Faenza-Oriolo-Stauffer algorithm for weighted stable set on claw-free graphs
|
52
52
|
# The maximum weighted stable set's complement gives us the minimum vertex cover
|
53
53
|
E = working_graph.edges()
|
54
54
|
approximate_vertex_cover = stable.minimum_vertex_cover_claw_free(E)
|
55
|
-
|
55
|
+
|
56
56
|
else:
|
57
57
|
# CASE 2: Graph contains claws - use divide-and-conquer approach
|
58
|
-
|
59
|
-
# Step 1: Edge partitioning using enhanced Burr-
|
60
|
-
# Partition edges E = E1
|
61
|
-
# Complexity: O(m * (m * Δ * C + C^2)), where m is edges, Δ is maximum degree, C is number of claws
|
58
|
+
|
59
|
+
# Step 1: Edge partitioning using enhanced Burr-Erdos-Lovasz technique
|
60
|
+
# Partition edges E = E1 union E2 such that both induced subgraphs G[E1] and G[E2] are claw-free
|
62
61
|
E1, E2 = partition.partition_edges_claw_free(working_graph)
|
63
|
-
|
62
|
+
|
64
63
|
# Step 2: Solve subproblems optimally on claw-free partitions
|
65
64
|
# Each partition can be solved exactly using polynomial-time algorithms
|
66
|
-
vertex_cover_1 = stable.minimum_vertex_cover_claw_free(E1)
|
67
|
-
vertex_cover_2 = stable.minimum_vertex_cover_claw_free(E2)
|
68
|
-
|
69
|
-
# Step 3: Intelligent merging with 1.
|
70
|
-
# Time complexity: O(|V| × log |V|)
|
65
|
+
vertex_cover_1 = stable.minimum_vertex_cover_claw_free(E1)
|
66
|
+
vertex_cover_2 = stable.minimum_vertex_cover_claw_free(E2)
|
67
|
+
|
68
|
+
# Step 3: Intelligent merging with 1.9-approximation guarantee
|
71
69
|
approximate_vertex_cover = merge.merge_vertex_covers(
|
72
70
|
working_graph, vertex_cover_1, vertex_cover_2
|
73
71
|
)
|
74
|
-
|
72
|
+
|
75
73
|
# Step 4: Handle residual uncovered edges through recursion
|
76
74
|
# Construct residual graph containing edges missed by current vertex cover
|
77
75
|
residual_graph = nx.Graph()
|
@@ -79,14 +77,14 @@ def find_vertex_cover(graph):
|
|
79
77
|
# Edge (u,v) is uncovered if neither endpoint is in our current cover
|
80
78
|
if u not in approximate_vertex_cover and v not in approximate_vertex_cover:
|
81
79
|
residual_graph.add_edge(u, v)
|
82
|
-
|
80
|
+
|
83
81
|
# Recursive call to handle remaining uncovered structure
|
84
82
|
# This ensures completeness: every edge in the original graph is covered
|
85
83
|
residual_vertex_cover = find_vertex_cover(residual_graph)
|
86
|
-
|
84
|
+
|
87
85
|
# Combine solutions: union of main cover and residual cover
|
88
86
|
approximate_vertex_cover = approximate_vertex_cover.union(residual_vertex_cover)
|
89
|
-
|
87
|
+
|
90
88
|
return approximate_vertex_cover
|
91
89
|
|
92
90
|
def find_vertex_cover_brute_force(graph):
|
@@ -82,7 +82,7 @@ def main():
|
|
82
82
|
helper.add_argument('-c', '--count', action='store_true', help='calculate the size of the vertex cover')
|
83
83
|
helper.add_argument('-v', '--verbose', action='store_true', help='anable verbose output')
|
84
84
|
helper.add_argument('-l', '--log', action='store_true', help='enable file logging')
|
85
|
-
helper.add_argument('--version', action='version', version='%(prog)s 0.0.
|
85
|
+
helper.add_argument('--version', action='version', version='%(prog)s 0.0.5')
|
86
86
|
|
87
87
|
# Initialize the parameters
|
88
88
|
args = helper.parse_args()
|
@@ -36,7 +36,7 @@ def main():
|
|
36
36
|
helper.add_argument('-c', '--count', action='store_true', help='calculate the size of the vertex cover')
|
37
37
|
helper.add_argument('-v', '--verbose', action='store_true', help='anable verbose output')
|
38
38
|
helper.add_argument('-l', '--log', action='store_true', help='enable file logging')
|
39
|
-
helper.add_argument('--version', action='version', version='%(prog)s 0.0.
|
39
|
+
helper.add_argument('--version', action='version', version='%(prog)s 0.0.5')
|
40
40
|
|
41
41
|
|
42
42
|
# Initialize the parameters
|
@@ -34,7 +34,7 @@ def main():
|
|
34
34
|
helper.add_argument('-w', '--write', action='store_true', help='write the generated random matrix to a file in the current directory')
|
35
35
|
helper.add_argument('-v', '--verbose', action='store_true', help='anable verbose output')
|
36
36
|
helper.add_argument('-l', '--log', action='store_true', help='enable file logging')
|
37
|
-
helper.add_argument('--version', action='version', version='%(prog)s 0.0.
|
37
|
+
helper.add_argument('--version', action='version', version='%(prog)s 0.0.5')
|
38
38
|
|
39
39
|
# Initialize the parameters
|
40
40
|
args = helper.parse_args()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: alonso
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.5
|
4
4
|
Summary: Compute an Approximate Vertex Cover for undirected graph encoded in DIMACS format.
|
5
5
|
Home-page: https://github.com/frankvegadelgado/alonso
|
6
6
|
Author: Frank Vega
|
@@ -22,7 +22,7 @@ Classifier: Natural Language :: English
|
|
22
22
|
Requires-Python: >=3.10
|
23
23
|
Description-Content-Type: text/markdown
|
24
24
|
License-File: LICENSE
|
25
|
-
Requires-Dist: mendive>=0.0.
|
25
|
+
Requires-Dist: mendive>=0.0.5
|
26
26
|
Dynamic: author
|
27
27
|
Dynamic: author-email
|
28
28
|
Dynamic: classifier
|
@@ -69,7 +69,7 @@ Given an undirected graph $G = (V, E)$, a **vertex cover** is a subset $V' \subs
|
|
69
69
|
|
70
70
|
# Overview of the Algorithm and Its Running Time
|
71
71
|
|
72
|
-
The `find_vertex_cover` algorithm approximates a minimum vertex cover for an undirected graph $G = (V, E)$ by partitioning its edges into two claw-free subgraphs using the Burr-Erdős-Lovász (1976) method, computing exact vertex covers for these subgraphs with the Faenza, Oriolo, and Stauffer (2011) approach, and recursively refining the solution on residual edges. This process prevents the ratio from reaching 2, leveraging overlap between subgraphs and minimal additions in recursion. The algorithm begins by cleaning the graph (removing self-loops and isolates in
|
72
|
+
The `find_vertex_cover` algorithm approximates a minimum vertex cover for an undirected graph $G = (V, E)$ by partitioning its edges into two claw-free subgraphs using the Burr-Erdős-Lovász (1976) method, computing exact vertex covers for these subgraphs with the Faenza, Oriolo, and Stauffer (2011) approach, and recursively refining the solution on residual edges. This process prevents the ratio from reaching 2, leveraging overlap between subgraphs and minimal additions in recursion. The algorithm begins by cleaning the graph (removing self-loops and isolates in $O(n + m)$), checking for claw-free in $O(m \cdot \Delta)$, partitions edges in $O(m \cdot (m \cdot \Delta \cdot C + C^2))$ where $\Delta$ is the maximum degree and $C$ is the number of claws, computes vertex covers in $O(n^3)$ per subgraph (total $O(n^3)$), merges covers in $O(n \cdot \log n)$, and constructs the residual graph in $O(m)$. The recursive nature, with a worst-case depth of $O(m)$ if each step covers one edge, yields a total runtime of $O(n^3 m)$, dominated by the cubic cost across levels. For sparse graphs ($m = O(n)$), this simplifies to $O(n^4)$.
|
73
73
|
|
74
74
|
---
|
75
75
|
|
@@ -0,0 +1 @@
|
|
1
|
+
mendive>=0.0.5
|
@@ -1 +0,0 @@
|
|
1
|
-
mendive>=0.0.4
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|