1. Introduction
The matching theory is a major field in combinatorics and graph theory; see, e.g., the work of [
1,
2,
3,
4,
5,
6,
7]. The focus of this paper is the so-called
maximum acyclic matching in simple, connected, undirected graphs. Let
be an undirected graph with a set
V of
n vertices and a set
E of
m edges. A subset
M of
E is a
matching in
G if no two edges in
M share a common vertex. A matching
M in
G is
acyclic if the subgraph of
G induced by the set of vertices incident on the edges of
M is cycle-free.
M is a
maximum acyclic matching if for all acyclic matchings
S in
G,
. It is known that the problem of finding a maximum acyclic matching in an undirected graph is NP-complete, as shown by [
8,
9].
In this paper, we present new results concerning the time complexity of finding a maximum acyclic matching in an undirected graph. In particular, we show that a maximum acyclic matching in a given undirected graph (with n vertices and m edges) can be computed recursively with a recursion depth in expectation. Thus, employing a recursive computation of a maximum acyclic matching in a given graph, if the recursion depth meets the expectation , then a maximum acyclic matching can be computed in time and space . However, for the general case, the recursive computation of a maximum acyclic matching is in time and space.
The rest of this article is organized as follows: In
Section 2, we discuss related work. In
Section 3, we discuss a recursive algorithm (Algorithm 1) for computing a maximum acyclic matching in a given undirected graph. In
Section 4, we stress the correctness of the recursive algorithm in Theorem 1. In
Section 5, we analyze the time and space of the recursive algorithm, where our main results are stated in Theorems 2 and 3. We conclude our article in
Section 6.
2. Related Work
Restricted matchings and acyclic matchings in graphs have been extensively studied in the literature. In the following, we overview the existing work on the computation of restricted matchings and acyclic matchings in graphs. Ref. [
8] investigated generalized subgraph-restricted matchings in graphs. Ref. [
9] examined acyclic matchings in subclasses of bipartite graphs. Ref. [
10] studied degenerate matchings and edge colorings. Refs. [
11,
12] investigated the complexity of minimum maximal acyclic matchings. Refs. [
13,
14] discussed computing acyclic matching in certain subclasses of graphs. Ref. [
15] studied hard and certain tractable cases of the maximum acyclic matching problem. Ref. [
16] analyzed minimum maximal acyclic matching in proper interval graphs. Ref. [
17] discussed the parameterized complexity of the acyclic matching problem. Ref. [
18] presented further parameterized results on acyclic matchings. Ref. [
19] offered efficient computation of simplicial homology through acyclic matching. Ref. [
20] examined acyclic matching on hypercube networks. Ref. [
21] considered a lower bound on the acyclic matching number of subcubic graphs. Ref. [
20] researched acyclic matching in ladder graphs. Ref. [
22] utilized acyclic matching to enhance the current flow in diamond ladder structures. Ref. [
23] studied the complexity of minimum maximal uniquely restricted matching. Ref. [
24] considered approximating maximum acyclic matchings by greedy and local search strategies. Ref. [
25] thoroughly studied restricted matchings in graphs. Ref. [
26] examined acyclic matchings in graphs of bounded maximum degree.
However, the expected depth of the recursion tree of the recursive computation of a maximum acyclic matching has not been studied in the literature. Therefore, our results presented in this paper fill this gap, where we calculate the expected depth of the recursion tree of the recursive computation of a maximum acyclic matching and discuss the consequences for the space complexity and the overall time complexity of the concerned computations.
3. Algorithm
In Algorithm 1, we list our method for finding a maximum acyclic matching in a given undirected graph with a set V of n vertices and a set E of m edges. We go through Algorithm 1 line by line.
In lines 1–3, we start with an empty maximum acyclic matching M and an empty acyclic matching ; we also create a vertex status mapping . For a vertex v, the status is whenever the vertex v is adjacent to a vertex incident on an edge in an acyclic matching ; otherwise, the status of the vertex v is . As we start with an empty acyclic matching , the initial status is for all vertices v. In line 3, we create an edge status mapping , such that, for an edge e, the status indicates that the edge e is included in an acyclic matching ; the status implies that the edge e is forbidden to join an acyclic matching , whereas the status refers to the initial status of the edge e before being included in or excluded from an acyclic matching .
In lines 4–7, while there are edges e in the graph with status , randomly select an edge e with status . In line 6, we call routine F (defined at line 8) for constructing an acyclic matching passing on an empty acyclic matching , a vertex status , an edge status , and the vertices of the selected edge e. Afterward, in line 7, we change the status to prevent e from joining in the subsequent calls for routine F, because the algorithm aims to construct other possible acyclic matchings excluding this edge e.
In line 8, we list the routine F’s parameters: an acyclic matching , a vertex status , an edge status , and the edge that has been chosen to join the acyclic matching .
In line 9, we add the edge to the acyclic matching , and update the edge status , the vertex status and .
In lines 10–13, we process every vertex adjacent to the vertex x (see lines 10–11), such that we change the status . In addition, we update the status to prevent this edge from joining the acyclic matching , adhering to the condition that states matching have no two edges sharing a common vertex. Afterward, in lines 12–13, we check every vertex adjacent to the vertex . If the edge has a status and the vertex status , then we prevent the edge from joining the acyclic matching , to maintain acyclicity by excluding any edge whose vertices are adjacent to other vertices incident on certain edges in . This is true as we build an acyclic matching where the subgraph of G induced by the vertices incident on the edges of is connected; we elaborate further on this issue throughout the rest of the article. In lines 14–17, we repeat operations analogous to the actions of lines 10–13, but for y, the other vertex of e.
Concerning lines 18–21, as long as the set , we repeatedly perform the following actions. We select (in line 19) an edge (at random) with status and . This means we randomly select an edge for whom it is not decided yet whether to include or exclude it from the acyclic matching , where only one (not both) of the vertices of the edge is adjacent to a vertex incident on an edge in the acyclic matching . This tactic ensures connectivity of the subgraph induced by the vertices incident on the edges of . In line 20, we call routine F, passing on a copy of the acyclic matching , a copy of the vertex status , a copy of the edge status , and the selected edge . We stress that all invocations for routine F are made by calling it with a copy of the passed structures; that is, any changes made in these passed structures within the called instance of routine F do not affect the original copy of the caller instance of routine F. The last action within the while loop is to exclude the edge from any acyclic matchings that might be constructed in the subsequent rounds.
At last, in line 22, since we search for a maximum acyclic matching, we update
if
is more significant in size than
M.
Algorithm 1: Find a maximum acyclic matching, M, of a graph . |
- 1
; ; - 2
let be initially for all i; - 3
let be initially for all i; - 4
while do - 5
select at random an edge with ; - 6
F(,,,x,y); - 7
;
- 8
routine F(,β,α,x,y): - 9
; ; ; ; - 10
foreach with do; - 11
; ; - 12
foreach do - 13
; - 14
foreach with do - 15
; ; - 16
foreach do - 17
; - 18
while do - 19
select at random an edge with and ; - 20
F(,,,x,y); - 21
; - 22
if then ;
|
Example 1. Apply Algorithm 1 to a graph with a vertex set and an edge set . Initially, applying the actions in lines 1–3 in Algorithm 1, the state isSince the set , in line 5, we randomly select an edge, suppose it is . Then, in line 6, we invoke routine F by calling it withThen, we apply the actions of lines 9–17, and subsequently, the state of the algorithm becomesApplying line 18, since the set is empty, we proceed with applying line 22, and the state of the algorithm’s execution becomes By completing the execution of this instance of the routine F, we return to line 7; we now exclude the edge from any subsequent acyclic matching. Now the state of the execution of the algorithm isIn a second round of the while loop (at line 4), assume we randomly selected (in line 5) the edge . Thereby, we invoke routine F (in line 6) with the following call:Then, we apply the actions of lines 9–17, and subsequently, the state of the algorithm becomesApplying line 18, since the set is empty, we proceed with applying line 22 and the state of the algorithm’s execution remains By completing the execution of this instance of the routine F, we return to line 7; we now exclude the edge from any subsequent acyclic matching. The state of the execution of the algorithm is now In a third round of the while loop (at line 4), assume we randomly selected (in line 5) the edge . Thereby, we invoke routine F (in line 6) with the following call:Then, we apply the actions of lines 9–17, and subsequently, the state of the algorithm becomesApplying line 18, since the set is empty, we proceed with applying line 22 and the state of the algorithm’s execution remains By completing the execution of this instance of the routine F, we return to line 7; we now exclude the edge from any subsequent acyclic matching. The state of the execution of the algorithm is now In a fourth round of the while loop (at line 4), assume we randomly selected (in line 5) the edge . Thereby, we invoke routine F (in line 6) with the following call:Then, we apply the actions of lines 9–17, and subsequently, the state of the algorithm becomesApplying line 18, since the set is empty, we proceed with applying line 22 and the state of the algorithm’s execution remains By completing the execution of this instance of the routine F, we return to line 7; we now exclude the edge from any subsequent acyclic matching. The state of the execution of the algorithm is now In a fifth round of the while loop (at line 4), assume we randomly selected (in line 5) the edge . Thereby, we invoke routine F (in line 6) with the following call:Then, we apply the actions of lines 9–17, and subsequently, the state of the algorithm becomesApplying line 18, since the set is empty, we proceed with applying line 22 and the state of the algorithm’s execution remains By completing the execution of this instance of the routine F, we return to line 7; we now exclude the edge from any subsequent acyclic matching. The state of the execution of the algorithm is now In a sixth round of the while loop (at line 4), assume we randomly selected (in line 5) the edge . Thereby, we invoke routine F (in line 6) with the following call:Then, we apply the actions of lines 9–17, and subsequently, the state of the algorithm becomesApplying line 18, since the set is empty, we proceed with applying line 22 and the state of the algorithm’s execution remains By completing the execution of this instance of the routine F, we return to line 7; we now exclude the edge from any subsequent acyclic matching. The state of the execution of the algorithm is now In a seventh round of the while loop (at line 4), we select (in line 5) the edge . Thereby, we invoke routine F (in line 6) with the following call:Then, we apply the actions of lines 9–17, and subsequently, the state of the algorithm becomesApplying line 18, since the set is empty, we proceed with applying line 22 and the state of the algorithm’s execution remains By completing the execution of this instance of the routine F, we return to line 7; we now exclude the edge from any subsequent acyclic matching. The state of the execution of the algorithm is now Referring to line 4, since the set , the execution of the while loop is completed. The algorithm’s execution ends with the set being a maximum acyclic matching in the given graph.
4. Correctness
Our first lemma stresses that for a given graph , Algorithm 1 employs the vertex status to mark if a vertex is adjacent to a vertex incident on an edge in the set .
Lemma 1. Throughout the execution of Algorithm 1 on a given graph , for a vertex v in the graph, the vertex status whenever the vertex is adjacent to a vertex incident on an edge included in the set . Otherwise, the vertex status is .
Proof. In lines 1–2, the set is empty, and the vertex status for all v. Now, we show that whenever we change the status , this entails that v is adjacent to a vertex incident on an edge in the set . Referring to line 9 in Algorithm 1, once an edge joins the set , we label x and y with and , because both vertices are adjacent to a vertex incident on the edge . In addition, in line 11 (respectively 15), we label a vertex with , since the vertex is adjacent to the vertex x (respectively y) that is incident on the edge . □
The following lemma stresses that for a given graph , Algorithm 1 uses an edge status to indicate if an edge is in or out of a set .
Lemma 2. Throughout the execution of Algorithm 1 on a given graph , for an edge e in the graph, the edge status is if and only if e is in a set . The edge status is whenever the algorithm aims to construct a set excluding or whenever e shares a common vertex with an edge included in a set , or whenever every vertex of the edge e is adjacent to a vertex incident on an edge in a set . Otherwise, the edge status is .
Proof. Initially, the set is empty, and the edge status for all e; see lines 1 and 3 in Algorithm 1. Once an edge joins the set , we label it with ; see line 9. The algorithm labels an edge with in three cases. For the first case, the algorithm aims to construct a set excluding after the algorithm has constructed a set including , see lines 19–21. The second case of labeling an edge with is when there is another edge such that and share a common vertex, see lines 11 and 15 in Algorithm 1. The third case of labeling an edge with requires three conditions:
x is incident on an edge included in the set ,
y is incident to an edge included in the set , and
the edge status ; that is, the edge is not in ;
see lines 13 and 17. □
In the following lemma, we emphasize that Algorithm 1 constructs acyclic matchings for a given graph.
Lemma 3. Throughout the execution of Algorithm 1 on a given graph , the set is acyclic matching in G.
Proof. Initially, is acyclic matching because it is empty; see line 1 in Algorithm 1. Now, we show that whenever we add an edge to an acyclic matching , the set is acyclic matching. Referring to line 19–20, we include an edge in an acyclic matching if the two following conditions are satisfied:
- (i)
, which means, as shown in Lemma 2, that the vertices x and y are not incident on an edge in the acyclic matching , and
- (ii)
, which means, as shown in Lemma 2, that only x or only y is adjacent to a vertex incident on an edge in .
Thus, satisfying (i) ensures that the set is a matching, whereas satisfying (ii) ensures that the set is acyclic but also guarantees that the subgraph of G induced by the vertices of the edges in is connected. □
We are ready to demonstrate that Algorithm 1 finds a maximum acyclic matching of a given graph.
Theorem 1. Algorithm 1 finds a maximum acyclic matching M of a given graph .
Proof. Assume the opposite; that is, M is not acyclic matching or M is acyclic matching but not a maximum one. M being not acyclic matching is impossible, since we showed earlier that in all stages, i, of the execution of Algorithm 1, the set is acyclic matching, and is the only update on M, see line 22 in Algorithm 1. M being not maximum means that there is an acyclic matching S overlooked by the algorithm such that in all stages, i, of the execution of Algorithm 1. We note that at some stage, k, of the execution of Algorithm 1, an acyclic matching . This requires that there is a set of edges , but . As every edge , there are two cases: (i) the status or (ii) the status . For case (i), the status entails that the edge will join the acyclic matching (see lines 18–19 & 4–5), which contradicts the assumption that the algorithm overlooks the set S. For case (ii), where the status , as shown in Lemma 2, this implies one of the following:
The edge has already joined the acyclic matching , and now the algorithm intentionally aims to grow without the edge , see lines 19–21 in Algorithm 1. This contradicts the assumption that S is an acyclic matching overlooked by the algorithm.
The edge shares a common vertex with an edge in the acyclic matching (see lines 11 and 15 in Algorithm 1); thus, is not a matching, and subsequently, S is not a matching, since , contradicting the assumption that S is an acyclic matching overlooked by the algorithm.
The edge has its vertex x adjacent to a vertex incident on an edge in the acyclic matching and the edge has its vertex y adjacent to a vertex incident on an edge in (see lines 13 and 17). So, is cyclic, and subsequently is cyclic, contradicting the assumption that S is a acyclic matching overlooked by the algorithm. For this case, it is important to note that we showed earlier in Lemma 3 that for every stage i of the execution of Algorithm 1, the subgraph of G, induced by the vertices of the edges in the acyclic matching , is connected.
□
5. Complexity
In this section, we calculate the expected recursion depth of Algorithm 1. But let us first discuss the general time and space complexity of Algorithm 1. The nested loop in lines 10–13 (similarly, the loop in lines 14–17) runs in time. Note that the size of the execution tree of Algorithm 1 is in the order of the number of calls to routine F. For each edge e in the given graph, we call routine F twice, once with and another time with ; see lines 6–7 and 20–21. Thus, the size of the execution tree is . Thus, the overall time of Algorithm 1 is in .
For the running space of Algorithm 1, we note that at maximum, there are m instances of the routine F that are simultaneously active where every instance holds a copy of the structures: , and . So, the running space of Algorithm 1 is in .
Now, we calculate the expected recursion depth of Algorithm 1 in the following theorem.
Theorem 2. Let be a graph with n vertices and m edges. Algorithm 1 runs with a recursion depth in expectation.
Proof. The expected recursion depth of Algorithm 1 is equal to
where
is the expected number of times an edge
j is selected within a complete path from the root call (for routine F) to the leaf call (for routine F) in the execution tree of Algorithm 1.
is a random variable representing the number of times an edge
j is selected within a complete path from the root call (for routine F) to the leaf call (for routine F) in the execution tree of Algorithm 1. Thus,
is defined as
such that
if
and
if
. Therefore,
where
is the probability of having a set of
i edges and
is the probability of selecting an edge
from
. Hence, the expected recursion depth is
Since
it is the case that
□
We now state the space and time complexity of Algorithm 1 under the assumption that the recursion depth of Algorithm 1 running on a given graph meets the expectation .
Theorem 3. For a given graph with n vertices and m edges, if the recursion depth of Algorithm 1 meets the expectation , then the algorithm runs in time and space .
Proof. As discussed earlier, the running time of Algorithm 1 is the cost of the nested loop 10–13 (and 14–17) multiplied by the size of the execution tree of the algorithm, which is overall
. If the recursion depth of the algorithm is equal to the expected depth that is equal to (see the proof of Theorem 2)
then the size of the execution tree becomes
, and hence the running time of the algorithm becomes
Under the assumption that the recursion depth of Algorithm 1 is equal to the expected depth , the space complexity of Algorithm 1 becomes ; recall that the algorithm, in every call to the recursive routine F, makes a copy of the passed structures (i.e., , , and ). □
6. Conclusions
We presented new results on the complexity of computing a maximum acyclic matching in a given undirected graph. We demonstrated that a maximum acyclic matching in a graph can be computed recursively with a recursion depth in expectation. This implies that the complexity of recursively computing a maximum acyclic matching in a graph, such that the recursion depth meets the expectation , is time and space. However, for the general case, the time complexity of the discussed recursive computation for a maximum acyclic matching is in and the space complexity is in . Further investigations could consider diverse randomized strategies in the computation of a maximum acyclic matching with different probability distributions in particular classes of undirected graphs.