This work builds upon Mendive: Fast Claw Detection in Sparse Graphs.
The Claw-Free Graph Problem is a fundamental decision problem in graph theory. Given an undirected graph, the problem asks whether the graph is claw-free – meaning it contains no induced subgraph isomorphic to a claw (the complete bipartite graph $K_{1,3}$). A claw consists of:
This problem is important for various reasons:
Understanding this problem is essential for graph algorithm design and complexity theory.
Input: A Boolean Adjacency Matrix $M$.
Question: Does $M$ contain no claws?
Answer: True / False
c1 | c2 | c3 | c4 | c5 | |
---|---|---|---|---|---|
r1 | 0 | 0 | 1 | 1 | 1 |
r2 | 0 | 0 | 0 | 0 | 0 |
r3 | 1 | 0 | 0 | 0 | 1 |
r4 | 1 | 0 | 0 | 0 | 0 |
r5 | 1 | 0 | 1 | 0 | 0 |
The input for undirected graph is typically provided in DIMACS format. In this way, the previous adjacency matrix is represented in a text file using the following string representation:
p edge 5 4
e 1 3
e 1 5
e 1 4
e 2 5
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
e W V
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.
Example Solution:
Claw Found (1, {3, 4, 5})
: In Column 1
(Center)
and Rows 3
& 4
& 5
(Leaves)
This algorithm, implemented as find_claw_coordinates
, detects
claws (a $K_{1,3}$ subgraph with one central vertex connected to three
non-adjacent leaf vertices) in an undirected graph. It leverages the
aegypti package (developed
by the same author), which provides a
linear-time triangle detection algorithm claimed to run
in $O(n + m)$ time, where $n$ is the number of nodes and $m$ is the number
of edges. The claw detection process adapts this by applying triangle
finding to the complement of each node’s neighbor-induced subgraph.
Neighbor Subgraph and Complement:
Triangle Finding with Aegypti:
aegypti
package’s
find_triangle_coordinates
function to detect triangles
in the complement subgraph.
aegypti
algorithm employs Depth-First Search (DFS)
tailored for this subgraph, achieving efficiency based on its
claimed $O(n' + m')$ complexity, where $n'$ and $m'$ are the nodes
and edges in the complement subgraph.
Claw Storage:
The runtime of the find_claw_coordinates
algorithm depends on
the graph’s structure, particularly the maximum degree $\Delta$, and
varies based on the first_claw
parameter.
first_claw=True
(Find One Claw)aegypti
triangle detection: $O(\text{deg}(i)^2)$ for
the complement subgraph.
first_claw=False
(List All Claws)aegypti
lists all triangles: $O(\text{deg}(i)^2)$ plus
output time for each triangle.
This claw detection algorithm, built on the aegypti
package,
has significant implications:
Leveraging Aegypti’s Innovation:
aegypti
algorithm’s claimed $O(n + m)$ triangle
detection (potentially challenging the sparse triangle hypothesis,
$O(m^{4/3})$) enables efficient claw finding per node.
pip install aegypti
makes it
accessible for practical use.
Practical Applications:
Theoretical Significance:
aegypti
’s linear-time claim holds against 3SUM-hard
instances, this algorithm could contribute to breakthroughs in graph
theory, influencing related problems like independent set detection.
Limitations:
In summary, this algorithm extends the aegypti
breakthrough
to claw detection, offering a practical tool with theoretical promise.
Further testing on diverse graphs could solidify its impact, especially if
aegypti
’s claims are validated.
pip install mendive
git clone https://github.com/frankvegadelgado/mendive.git
cd mendive
claw -i .\benchmarks\testMatrix1
utilizing the claw
command provided by Mendive's Library to
execute the Boolean adjacency matrix
mendive\benchmarks\testMatrix1
. The file
testMatrix1
represents the example described herein. We also
support .xz, .lzma, .bz2, and .bzip2 compressed text files.
testMatrix1: Claw Found (1, {3, 4, 5})
which implies that the Boolean adjacency matrix
mendive\benchmarks\testMatrix1
contains a claw combining the
nodes (1, {3, 4, 5})
with center 1
and leaves
3, 4, 5
.
The -a
flag enables the discovery of all claws within the
graph.
Example:
claw -i .\benchmarks\testMatrix2 -a
Output:
testMatrix2: Claws Found (1, {6, 11, 12}); (1, {8, 9, 11}); (2, {6, 8, 9}); (1, {4, 6, 8}); (9, {2, 3, 5}); (1, {6, 8, 9}); (1, {3, 6, 12}); (1, {8, 9, 12}); (1, {3, 8, 12}); (2, {6, 8, 11}); (11, {2, 3, 5}); (2, {6, 9, 11}); (5, {8, 9, 11}); (1, {2, 3, 12}); (1, {6, 8, 11}); (1, {8, 11, 12}); (1, {9, 11, 12}); (1, {4, 6, 12}); (1, {4, 8, 12}); (1, {6, 9, 12}); (4, {2, 3, 5}); (1, {6, 9, 11}); (2, {8, 9, 11}); (2, {4, 6, 8}); (1, {6, 8, 12}); (1, {3, 6, 8})
When multiple claws exist, the output provides a list of their vertices.
Similarly, the -c
flag counts all claws in the graph.
Example:
claw -i .\benchmarks\testMatrix2 -c
Output:
testMatrix2: Claws Count 26
We employ the same algorithm used to solve the claw-free problem.
To display the help message and available options, run the following command in your terminal:
claw -h
This will output:
usage: claw [-h] -i INPUTFILE [-a] [-b] [-c] [-v] [-l] [--version]
Solve the Claw-Free Problem for an undirected graph encoded in DIMACS format.
options:
-h, --help show this help message and exit
-i INPUTFILE, --inputFile INPUTFILE
input file path
-a, --all identify all claws
-b, --bruteForce compare with a brute-force approach using matrix multiplication
-c, --count count the total amount of claws
-v, --verbose anable verbose output
-l, --log enable file logging
--version show program's version number and exit
This output describes all available options.
A command-line tool, test_claw
, has been developed for
testing algorithms on randomly generated, large sparse matrices. It
accepts the following options:
usage: test_claw [-h] -d DIMENSION [-n NUM_TESTS] [-s SPARSITY] [-a] [-b] [-c] [-w] [-v] [-l] [--version]
The Mendive Testing Application using randomly generated, large sparse matrices.
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, --all identify all claws
-b, --bruteForce compare with a brute-force approach using matrix multiplication
-c, --count count the total amount of claws
-w, --write write the generated random matrix to a file in the current directory
-v, --verbose anable verbose output
-l, --log enable file logging
--version show program's version number and exit
This tool is designed to benchmark algorithms for sparse matrix operations.
It generates random square matrices with configurable dimensions
(-d
), sparsity levels (-s
), and number of tests
(-n
). While a comparison with a brute-force matrix
multiplication approach is available, it's recommended to avoid this for
large datasets due to performance limitations. Additionally, the generated
matrix can be written to the current directory (-w
), and
verbose output or file logging can be enabled with the (-v
)
or (-l
) flag, respectively, to record test results.
+ This algorithm provides multiple of applications to other computational problems in combinatorial optimization and computational geometry.