Estimating the Minimum Vertex Cover with an approximation factor of 7/5 for large enough undirected graphs encoded as a Boolean adjacency matrix stored in a file.
Project description
Varela: Minimum Vertex Cover Solver
The Minimum Vertex Cover Problem
The Minimum Vertex Cover (MVC) problem is a classic optimization problem in computer science and graph theory. It involves finding the smallest set of vertices in a graph that covers all edges, meaning at least one endpoint of every edge is included in the set.
Formal Definition
Given an undirected graph $G = (V, E)$, a vertex cover is a subset $V' \subseteq V$ such that for every edge $(u, v) \in E$, at least one of $u$ or $v$ belongs to $V'$. The MVC problem seeks the vertex cover with the smallest cardinality.
Importance and Applications
- Theoretical Significance: MVC is a well-known NP-hard problem, central to complexity theory.
- Practical Applications:
- Network Security: Identifying critical nodes to disrupt connections.
- Bioinformatics: Analyzing gene regulatory networks.
- Wireless Sensor Networks: Optimizing sensor coverage.
Related Problems
- Maximum Independent Set: The complement of a vertex cover.
- Set Cover Problem: A generalization of MVC.
Problem Statement
Input: A Boolean Adjacency Matrix $M$.
Answer: Find a Minimum Vertex Cover.
Example Instance: 5 x 5 matrix
| c0 | c1 | c2 | c3 | c4 | |
|---|---|---|---|---|---|
| r0 | 0 | 0 | 1 | 0 | 1 |
| r1 | 0 | 0 | 0 | 1 | 0 |
| r2 | 1 | 0 | 0 | 0 | 1 |
| r3 | 0 | 1 | 0 | 0 | 0 |
| r4 | 1 | 0 | 1 | 0 | 0 |
A matrix is represented in a text file using the following string representation:
00101
00010
10001
01000
10100
This represents a 5x5 matrix where each line corresponds to a row, and '1' indicates a connection or presence of an element, while '0' indicates its absence.
Example Solution:
Vertex Cover Found 0, 1, 4: Nodes 0, 1, 4 form an optimal solution.
Our Algorithm - Polynomial Runtime
Algorithm Overview
-
Input Validation:
- Checks if the input is a valid SciPy sparse matrix.
- Ensures the matrix is square (representing an adjacency matrix).
-
Empty Graph Handling:
- Returns
Noneif the input graph is empty (no vertices or edges).
- Returns
-
Graph Conversion:
- Converts the sparse adjacency matrix to a NetworkX graph for easier manipulation.
-
Edge Graph Construction:
- Creates a new graph called the "edge graph."
- Each node in the edge graph represents an edge in the original graph.
- An edge is added between two nodes in the edge graph if the corresponding edges in the original graph share a vertex.
-
Minimum Edge Cover:
- Computes a minimum edge cover of the edge graph using
nx.min_edge_cover(). This function typically uses matching techniques.
- Computes a minimum edge cover of the edge graph using
-
Vertex Cover from Edge Cover:
- Iterates through the edges in the minimum edge cover of the edge graph.
- For each edge in the edge cover, identifies the corresponding edges in the original graph (using the computed mapping).
- Finds the common vertex between these two original edges.
- Adds this common vertex to the vertex cover.
-
Isolated Edge Handling (Heuristic):
- Iterates through the edges in the original graph.
- If an edge has both endpoints not in the current vertex cover, adds one of the endpoints to the vertex cover. This is intended to handle edges that might not have been covered by the edge cover step.
-
Redundancy Removal (Heuristic):
- Iterates through the vertices in the approximate vertex cover.
- For each vertex, checks if removing it still results in a valid vertex cover (using
utils.is_vertex_cover()). - If removing the vertex results in a valid cover, the vertex is removed. This step attempts to reduce the size of the cover.
Runtime Analysis
- Edge Graph Construction: $O(|E|^2)$ in the worst case.
- Minimum Edge Cover: The complexity of
nx.min_edge_cover()depends on the underlying algorithm used, but it's typically polynomial (e.g., $O(|V|^3)$ if based on matching). Here, $|V|$ refers to the number of nodes in the edge graph, which is equal to the number of edges in the original graph ($|E|$). So, this step is likely $O(|E|^3)$. - Vertex Cover Construction (from Edge Cover): $O(|E|)$, as it iterates through the edges in the edge cover.
- Isolated Edge Handling: $O(|E|)$.
- Redundancy Removal: $O(|V||E|)$.
Overall Runtime: The dominant factor is likely the minimum edge cover calculation on the edge graph, making the overall runtime likely $O(|E|^3)$. However, the $O(|E|^2)$ from the edge graph construction is also significant.
Important Note: The runtime analysis is based on the number of edges in the original graph ($|E|$) because the edge graph's size is proportional to $|E|$.
Compile and Environment
Prerequisites
- Python ≥ 3.10
Installation
pip install varela
Execution
-
Clone the repository:
git clone https://github.com/frankvegadelgado/varela.git cd varela
-
Run the script:
approx -i ./benchmarks/testMatrix1.txt
utilizing the
approxcommand provided by Varela's Library to execute the Boolean adjacency matrixvarela\benchmarks\testMatrix1.txt. The filetestMatrix1.txtrepresents the example described herein. We also support.xz,.lzma,.bz2, and.bzip2compressed.txtfiles.Example Output:
testMatrix1.txt: Vertex Cover Found 0, 1, 4This indicates nodes
0, 1, 4form a vertex cover.
Vertex Cover Size
Use the -c flag to count the nodes in the vertex cover:
approx -i ./benchmarks/testMatrix2.txt -c
Output:
testMatrix2.txt: Vertex Cover Size 5
Command Options
Display help and options:
approx -h
Output:
usage: approx [-h] -i INPUTFILE [-a] [-b] [-c] [-v] [-l] [--version]
Estimating the Minimum Vertex Cover with an approximation factor of 7/5 for large enough undirected graphs encoded as a Boolean adjacency matrix stored in a file.
options:
-h, --help show this help message and exit
-i INPUTFILE, --inputFile INPUTFILE
input file path
-a, --approximation enable comparison with a polynomial-time approximation approach within a factor of 2
-b, --bruteForce enable comparison with the exponential-time brute-force approach
-c, --count calculate the size of the vertex cover
-v, --verbose enable verbose output
-l, --log enable file logging
--version show program's version number and exit
Testing Application
A command-line utility named test_approx is provided for evaluating the Algorithm using randomly generated, large sparse matrices. It supports the following options:
usage: test_approx [-h] -d DIMENSION [-n NUM_TESTS] [-s SPARSITY] [-a] [-b] [-c] [-w] [-v] [-l] [--version]
The Varela Testing Application.
options:
-h, --help show this help message and exit
-d DIMENSION, --dimension DIMENSION
an integer specifying the dimensions of the square matrices
-n NUM_TESTS, --num_tests NUM_TESTS
an integer specifying the number of tests to run
-s SPARSITY, --sparsity SPARSITY
sparsity of the matrices (0.0 for dense, close to 1.0 for very sparse)
-a, --approximation enable comparison with a polynomial-time approximation approach within a factor of 2
-b, --bruteForce enable comparison with the exponential-time brute-force approach
-c, --count calculate the size of the vertex cover
-w, --write write the generated random matrix to a file in the current directory
-v, --verbose enable verbose output
-l, --log enable file logging
--version show program's version number and exit
Code
- Python implementation by Frank Vega.
Complexity
+ We present a polynomial-time algorithm achieving an approximation ratio of 7/5 for MVC, providing strong evidence that P = NP by efficiently solving a computationally hard problem with near-optimal solutions.
+ This result contradicts the Unique Games Conjecture, suggesting that many optimization problems may admit better solutions, revolutionizing theoretical computer science.
License
- MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file varela-0.0.1.tar.gz.
File metadata
- Download URL: varela-0.0.1.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d59e813211993edf22ac0825e113f25ecf28c6952912739ac4db751414a4b357
|
|
| MD5 |
4333a964c4d2bac7d24a4480b1d9a47d
|
|
| BLAKE2b-256 |
cd7b7ca06b4140166437417ac19683913d8b463f05ff0e4c8f97dacb9fc929c5
|
Provenance
The following attestation bundles were made for varela-0.0.1.tar.gz:
Publisher:
publish.yml on frankvegadelgado/varela
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varela-0.0.1.tar.gz -
Subject digest:
d59e813211993edf22ac0825e113f25ecf28c6952912739ac4db751414a4b357 - Sigstore transparency entry: 168921881
- Sigstore integration time:
-
Permalink:
frankvegadelgado/varela@c2e6b0f9323b4507a14e78be95c9374af522d365 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/frankvegadelgado
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2e6b0f9323b4507a14e78be95c9374af522d365 -
Trigger Event:
release
-
Statement type:
File details
Details for the file varela-0.0.1-py3-none-any.whl.
File metadata
- Download URL: varela-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b3efff0ed23ce955df04552b93fa2fad1c5e131526bd5c78641d3d9ca610932
|
|
| MD5 |
b6ce483833ad0b9e4aee655642b3ad4f
|
|
| BLAKE2b-256 |
b46457ba616146644303387d74ecd81fdeaf60613caba881d2ef5dd7807822c5
|
Provenance
The following attestation bundles were made for varela-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on frankvegadelgado/varela
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varela-0.0.1-py3-none-any.whl -
Subject digest:
0b3efff0ed23ce955df04552b93fa2fad1c5e131526bd5c78641d3d9ca610932 - Sigstore transparency entry: 168921883
- Sigstore integration time:
-
Permalink:
frankvegadelgado/varela@c2e6b0f9323b4507a14e78be95c9374af522d365 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/frankvegadelgado
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2e6b0f9323b4507a14e78be95c9374af522d365 -
Trigger Event:
release
-
Statement type: