The Pennsylvania State University The Graduate School Capital College
On Tutte’s Algorithm for Recognizing Binary Graphic Matroids A Master’s Paper in Computer Science by Zhaoxia Qu
c
2002 Zhaoxia Qu
Submitted in Partial Fulfillment of the Requirements for the Degree of Master of Science
April 2002
Abstract This paper gives a formal description of Tutte’s algorithm for recognizing binary graphic matroids, provides a proof of correctness and a running time analysis. The paper also provides a Java implementation of the algorithm. The program takes as input a binary matrix representing a binary matroid. If the matroid is graphic, it outputs a step-by-step construction and a drawing of a graph whose bond matroid is the matroid. Otherwise, it gives an explanation for why the matroid is not graphic.
i
Table of Contents
Abstract
i
Acknowledgement
iv
List of Figures
v
1 Introduction
1
2 Definitions and Theorems
2
2.1
Matroid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
2.2
Chain Group . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
2.3
The Matroid of A Chain Group . . . . . . . . . . . . . . . . .
4
2.4
Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
2.5
Graphic Matroid . . . . . . . . . . . . . . . . . . . . . . . . .
5
2.6
Rank of A Chain Group . . . . . . . . . . . . . . . . . . . . .
8
2.7
Representative Matrix . . . . . . . . . . . . . . . . . . . . . .
8
2.8
Minors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
2.9
Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.10 Bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3 Recognizing Binary Graphic Matroids
17
3.1
Row Grouping Algorithm
. . . . . . . . . . . . . . . . . . . . 19
3.2
Graphic Test Algorithm . . . . . . . . . . . . . . . . . . . . . 19
3.3
Break Down Algorithm . . . . . . . . . . . . . . . . . . . . . . 21
3.4
Partition Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 24
3.5
Classification Algorithm . . . . . . . . . . . . . . . . . . . . . 25
3.6
Incidence Matrix Construction Algorithm . . . . . . . . . . . . 25
3.7
Switch Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 27
4 Correctness Proof of the Algorithm 4.1
27
The Main Algorithm . . . . . . . . . . . . . . . . . . . . . . . 27 ii
4.2
The Graphic Test Algorithm . . . . . . . . . . . . . . . . . . . 31
4.3
The Break Down Algorithm . . . . . . . . . . . . . . . . . . . 33
4.4
The Partition Algorithm . . . . . . . . . . . . . . . . . . . . . 34
4.5
The Classification Algorithm . . . . . . . . . . . . . . . . . . . 35
4.6
Incidence Matrix Construction . . . . . . . . . . . . . . . . . . 36
5 Running Time Analysis of the Algorithm
42
5.1
The Break Down Algorithm . . . . . . . . . . . . . . . . . . . 43
5.2
The Partition Algorithm . . . . . . . . . . . . . . . . . . . . . 43
5.3
The Classification Algorithm . . . . . . . . . . . . . . . . . . . 44
5.4
The Switch Algorithm . . . . . . . . . . . . . . . . . . . . . . 44
5.5
The Incidence Matrix Construction Algorithm . . . . . . . . . 44
5.6
The Graphic Test Algorithm . . . . . . . . . . . . . . . . . . . 45
5.7
The Main Algorithm . . . . . . . . . . . . . . . . . . . . . . . 45
6 The Java Program 6.1
46
Test of The Program . . . . . . . . . . . . . . . . . . . . . . . 47 6.1.1
Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1.2
Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.1.3
Example 3 . . . . . . . . . . . . . . . . . . . . . . . . . 52
6.1.4
Example 4 . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.1.5
Example 5 . . . . . . . . . . . . . . . . . . . . . . . . . 55
7 Conclusion
58
References
61
iii
Acknowledgement I would like to thank Dr. Thang N. Bui for his input and guidance. He spent a tremendous amount of time and insight in guiding me for the project and the paper. I also would like to thank Dr. Sandra Kingan and Dr. Robert Kingan, for all the help they have given me. I am grateful to Dr. Pavel Naumov, Dr. Linda Null for reviewing this paper. I am also grateful to Mr. Nathan Fiedler, for the graph drawing part in my program is developed based on his GraphMaker package. Finally, I would like to thank my husband Gutian Xiao and my child Sean Xiao for their support.
iv
List of Figures 1
The Main Algorithm . . . . . . . . . . . . . . . . . . . . . . . 18
2
Row Grouping Algorithm (RGA) . . . . . . . . . . . . . . . . 20
3
Graphic Test Algorithm (GTA) . . . . . . . . . . . . . . . . . 22
4
Break Down Algorithm (BDA)
5
Partition Algorithm (PA)
6
Classification Algorithm (CA) . . . . . . . . . . . . . . . . . . 26
7
Incidence Matrix Construction Algorithm (IMCA)
8
Switch Algorithm (SA)
9
The Petersen graph constructed by the program
10
The Petersen graph after rearrangement of the vertices of Figure 9
. . . . . . . . . . . . . . . . . 23
. . . . . . . . . . . . . . . . . . . . 24 . . . . . . 28
. . . . . . . . . . . . . . . . . . . . . 29 . . . . . . . 56
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
11
The graph constructed by the program . . . . . . . . . . . . . 59
12
The graph after rearragement of the vertices of Figure 11
v
. . 60
1
1
INTRODUCTION
1
Introduction
The concept of matroids originates from Whitney’s paper in matroid theory [7]. When working in the field of graph theory, Whitney noticed several similarities between the ideas of independence and dimension in the study of vector spaces. He used the concept of matroid to formalize these similarities in his paper. Unfortunately, his work was ignored until a breakthrough occurred in 1958 when Tutte characterized those matroids which arise from graphs [3] [4]. Later, in 1965, many mathmaticians recognized the importance of matroids in transversal theory. Since then, interest in matroid theory has exploded, and the study of matroid theory has become an important branch of combinatorial mathematics. Matroid theory draws heavily on both graph theory and linear algebra. One important aspect of matroid theory is to characterize the graphicness of matroids. In 1960, Tutte published a paper describing an algorithm for determining whether a given binary matroid is graphic [2]. We are interested in implementing his algorithm, so that we can have a visual tool for recognizing binary graphic matroids. However, his description of the algorithm is informal and not easy to follow. So we also provide a formal description of the algorithm so that it is straightforward to follow and implement. As many of Tutte’s terminologies are different from the current terminology, his terminology will also be explained in this paper. The rest of this paper is organized as follows: Section 2 introduces the definitions and some theorems that are necessary to establish the correctness proof of the algorithm. Section 3 describes the algorithm. A correctness proof of the algorithm is provided in Section 4. A running time analysis of the algorithm is given in Section 5. The Java program is described in Section 6. A conclusion is drawn in the last section.
2
DEFINITIONS AND THEOREMS
2
2
Definitions and Theorems
This section introduces some of Tutte’s terminology and theorems. Most of them can be found in Tutte’s papers and book [2] [3] [4] [5] [6]. The proofs of the theorems are mostly from the same place where the theorem is cited. Some theorems may be stated a little differently and the proofs of some theorems may also be slightly different from the original proofs. But they all convey the same idea. The reader should note that some terminology is different from the current terminology.
2.1
Matroid
A matroid M is an ordered pair (E, Q), where E is a finite set, Q is a class of subsets of E such that the following two axioms hold ([6], p1): Axiom 1: No member of Q is a proper subset of another. Axiom 2: Let a and b be distinct members of E. Let X and Y be members of Q such that a ∈ X ∩ Y and b ∈ X − Y . Then there exists Z ∈ Q such that Z ⊆ (X ∪ Y ) − {a} and b ∈ Z. The members of E are called the cells of M . The members of Q are called the circuits of M . Theorem 2.1.1 ([6], 1.11) Let L be a class of non-null subsets of E. Suppose L satisfies matroid Axiom 2. If a ∈ X and X ∈ L then there is a minimal member Y of L such that a ∈ Y and Y ⊆ X. A member of L is called minimal if does not contain another member of L as a proper subset. Proof: If a ∈ X and X ∈ L, then there exists Y ∈ L such that a ∈ Y and Y ⊆ X. Choose such a Y so that |Y |, the number of elements in Y , is as small as possible. If Y is minimal, then the theorem is proved. And indeed Y is a minimal member of L. The reason for this is as follows: Suppose Y
2
DEFINITIONS AND THEOREMS
3
is not minimal, then there exists Z ∈ L such that Z ⊆ Y − {a}, by the definition of Y . Choose an element b ∈ Z. Since L satisfies matroid Axiom 2, there exists Z 0 ∈ L such that a ∈ Z 0 and Z 0 ⊆ (Y ∪ Z) − {b}. This implies that Z 0 is a proper subset of Y that contains a, which contradicts the choice of Y . Theorem 2.1.2 ([6], 1.12) Let L be a class of non-null subsets of E. Let Q be the class of minimal members of L. Suppose L satisfies matroid Axiom 2. Then M = (E, Q) is a matroid. Proof: Since Q is the class of minimal members of L, Q must satisfy matroid Axiom 1. Let a, b be distinct members of E, and X, Y be members of Q such that a ∈ X ∩ Y and b ∈ X − Y . Since L satisfies matroid Axiom 2, there exists Z in L such that b ∈ Z and Z ⊆ (X ∪ Y ) − {a}. By Theorem 2.1.1, there exists a minimal member Z 0 of L, which implies Z 0 ∈ Q, such that b ∈ Z 0 and Z 0 ⊆ Z. Hence we conclude that Q also satisfies matroid Axiom 2. Since Q satisfies both matroid Axioms 1 and 2, M = (E, Q) is a matroid.
2.2
Chain Group
Let E be a finite set. Let R be a commutative ring with a unit element and no divisors of zero. A chain on E over R is a mapping f of E into R. Let a be an element of E. Then f (a) is referred to as the coefficient of a in f . The domain or support of f , written as kf k, is the class of all members of E having nonzero coefficients in f . The chain on E in which every coefficient is zero is called the zero chain on E and is denoted in formulas by the symbol 0 ([6], p2). A chain group N on E over R is a class of chains on E over R that is closed under the operations of addition and multiplication by an element of R. A chain f ∈ N is an elementary chain of N if it is nonzero and if there is no nonzero chain g of N such that kgk is a proper subset of kf k ([6], p2).
2
DEFINITIONS AND THEOREMS
2.3
4
The Matroid of A Chain Group
Theorem 2.3.1 ([6], 1.22) Let N be a chain group on E over R. Let Q be the class of supports of elementary chains of N . Then M (N ) = (E, Q) is a matroid. Proof: Clearly Q satisfies matroid Axiom 1. Let L be the class of supports of nonzero chains of N . Then Q is a subset of L. Let a and b be distinct elements of E, and X and Y be members of L such that a ∈ (X ∩ Y ) and b ∈ X − Y . Then there exist chains f and g of N such that kf k = X and kgk = Y . Let h = g(a)f − f (a)g. Then h(a) = g(a)f (a) − f (a)g(a) = 0, and hence a 6∈ khk. As b ∈ X − Y , f (b) 6= 0, g(b) = 0, hence h(b) = g(a)f (b) − f (a)g(b) 6= 0 and b ∈ khk. Thus h is a nonzero chain of N satisfying b ∈ khk and khk ⊆ (X ∪ Y ) − {a}. Thus we conclude that L satisfies matroid Axiom 2. Since Q is the class of supports of elementary chains of N , Q is the class of minimal members of L, by the definition of elementary chain. Hence M (N ) = (E, Q) is a matroid, by Theorem 2.1.2. We refer to M (N ) as the matroid of the chain group N . A binary chain group is a chain group over the field of residues mod 2. A binary matroid is the matroid of a binary chain group ([6], p3). An integral chain group is a chain group over the ring of integers. Let N be an integral chain group. We define a primitive chain of N as an elementary chain of N whose coefficients are restricted to the values 0, 1, and −1. A regular chain group is an integral chain group in which every elementary chain is an integral multiple of a primitive chain. A regular matroid is the matroid of a regular chain group ([6], p3).
2.4
Graph
A graph G is an ordered pair (V (G), E(G)) where V (G) is a nonempty finite set of elements (called vertices), and E(G) is a finite family of unordered pairs of elements of V (G) (called edges). The two ends of a given edge may
2
DEFINITIONS AND THEOREMS
5
be distinct, in which case the edge is called a link; or, they may be coincident, in which case the edge is called a loop. Let G be a graph. A (u, v)-chain in G is a sequence u = v0 , e1 , v1 , e2 , . . . , vn−1 , en , vn = v where n ≥ 0, each vi is a vertex in V (G), and each ei is the edge {vi−1 , vi } in E(G). A graph G is called connected if there is a (u, v)-chain for all u, v ∈ V (G), u 6= v. Let G be a graph. A subgraph H of G is a graph in which V (H) ⊆ V (G) and E(H) ⊆ E(G). H is said to be a subgraph of G generated or induced by V (H) if E(H) = {(u, v)|u ∈ V (H), v ∈ V (H), (u, v) ∈ E(G)}. A connected component or component of G is a connected, generated subgraph H of G which is maximal in the sense that no larger connected generated subgraph K of G contains all the vertices of H.
2.5
Graphic Matroid
Let G be a graph. A bond of G is a minimal set of edges of E(G) whose removal increases the number of connected components in G. Let the vertices of V (G) be partitioned into two disjoint sets V1 and V2 . Let G1 and G2 be the subgraphs of G induced by V1 , V2 , respectively. Let H1 be a component of G1 and H2 be a component of G2 . If there is an edge e = (u, v) such that u ∈ V (H1 ) and v ∈ V (H2 ). Then the set S of all edges in G that have one end in V (H1 ) and the other end in V (H2 ), including e, is a bond of G. H1 and H2 are referred to as the two end-graphs of S in G. We orient G by distinguishing one end of each edge as positive and the other as negative. For each e ∈ E(G) and each v ∈ V (G), we define an integer η(e, v) as follows. If e and v are not incident, or if e is a loop, then η(e, v) = 0. Otherwise η(e, v) = 1 or −1 according to whether v is the positive or the negative end of e. Chains on V (G) or E(G) over a ring R are called 0-chains and 1-chains, respectively, of G over R ([6], p6).
2
6
DEFINITIONS AND THEOREMS
To each 0-chain f of G over R there correponds a 1-chain of G over R, which is denoted by δf , and is called the coboundary of f . It is defined as follows: (δf )(e) =
X
η(e, v)f (v),
v∈V (G)
for each e ∈ E(G). Thus if u is the positive and v the negative end of e we have (δf )(e) = f (u) − f (v). We note that δ0 = 0. Moreover, coboundaries satisfy the laws δ(f + g) = δ(f ) + δ(g), δ(λf ) = λδ(f ). Hence the coboundaries of the 0-chains of G over R are the elements of a chain group on E(G) over R. We denote this chain group ∆R (G) and call it the coboundary group of the oriented graph G, over R ([6], p8). Theorem 2.5.1 ([6], 1.33) Let G be a graph. Let S be a subset of E(G). There exists an elementary chain g of ∆R (G) such that S = kgk if and only if S is a bond of G. Proof: (⇐) Assume that S is a bond of G. We show that there exists an elementary chain g of ∆R (G) such that S = kgk. Let H1 and H2 be the two end-graphs of S. We define a 0-chain h of G over R as follows. h(x) = 1 if x ∈ V (H1 ), and h(x) = 0 otherwise. Let g = δh. Clearly, kgk = S. Claim: g is an elementary chain in ∆R (G). Proof of the claim: Suppose, to the contrary, that g is not an elementary chain in ∆R (G). Then there exists a nonzero chain f = δh1 of ∆R (G) such that kf k ⊂ kgk = S, where h1 is a 0-chain of G. The edges of both H1 and H2 must have 0 coefficients in f , which implies that the coefficients of the vertices of H1 in h1 are the same and so are the coefficients of the vertices of H2 in h1 . Let e be an edge in S − kf k. Since f (e) = 0, the two ends of e, one
2
DEFINITIONS AND THEOREMS
7
in H1 , the other in H2 , must have the same coefficients in h1 . But this implies that all the vertices of both H1 and H2 have the same coefficients in h1 , which in turn implies that all other edges of S must also have 0 coefficients in f as e. Thus f must be a zero chain, a contradiction. (⇒) Assume that there exists an elementary chain g of ∆R (G) such that S = kgk. We show that S is a bond of G. There exists a 0-chain h of G such that g = δh, by definition. Since g is nonzero, there exists an edge e = (u, v) such that g(e) = h(u) − h(v) 6= 0. Let H be a graph derived from G by deleting the edges of S. Let H1 be the component of H containing u, and H2 be the component of H containing v. Then for every vertex x in H1 , h(x) = h(u); and for every vertex y in H2 , h(y) = h(v). Let h1 be a 0-chain of G such that h1 (x) = 1 if x ∈ H1 , and h1 (x) = 0 otherwise. Then each edge of kδh1 k has one end in H1 . In addition, kδh1 k ⊆ S = kgk. Since g is elementary, kδh1 k = S. Hence each edge of S has one end in H1 . Let h2 be a 0-chain of G such that h2 (x) = 1 if x ∈ H2 , and h2 (x) = 0 otherwise. Similarly, we can deduce that kδh2 k = S and each edge of S has one end in H2 . Since each edge of S has one end in H1 and the other end in H2 , S is a bond of G. Let I be the ring of integers. In the above proof, it is easy to see that the coefficients of δh1 and δh2 are restricted to the values 0, 1 and −1. Hence these two 0-chains of G are primitive chains of ∆I (G). In addition, δh1 = −δh2 , g = (g(e))(δh1 ), where g(e) ∈ I. Hence we can deduce the follwing theorem: Theorem 2.5.2 ([6], 1.34) ∆I (G) is a regular chain group. From Theorem 2.5.1, we can deduce that the circuits of the matroid of ∆R (G) are defined by the bonds of G, and that this matroid is neither dependent of the ring R, nor dependent of the orientation assigned to G. We call this matroid the bond matroid of G, and denote it by B(G).
2
DEFINITIONS AND THEOREMS
8
A matroid is called graphic if it can be represented as the bond matroid of a graph. Note this definition is different from the current terminology. In the current terminology, a matroid is called cographic if it can be represented as the bond matroid of a graph. Since ∆I (G) is a regular chain group, Theorem 2.5.3 follows clearly: Theorem 2.5.3 ([6], 1.34) Every graphic matroid is regular.
2.6
Rank of A Chain Group
Let N be a chain group on E over R. Chains f1 , . . . , fk in N are linearly P dependent if ki=1 ri fi = 0 where the coefficients ri are elements of R and not all zero. If no such condition holds then the chains are linearly independent. The rank of N , denoted by r(N ), is the maximum number of linearly independent chains of N [2].
2.7
Representative Matrix
A representative matrix R of a chain group N on E, and hence its matroid M (N ), is a matrix of |E| columns and r(N ) rows, where the columns correspond to the elements of E, the rows correspond to the members of a set of r(N ) linearly independent chains of N and each element Rij is the coefficient of the jth element of E in chain fi ([6], p57). In the case of a binary chain group, Rij only has value 0 or 1. By standard results of linear algebra, the property of R being a representative matrix of N is invariant under the following “elementary operations”: 1. Permuting the rows 2. Adding to one row a multiple of another by an element of R 3. Multiplying a row by −1
2
DEFINITIONS AND THEOREMS
9
Through elementary operations on R and possibly a permutation of the columns, a matrix called a standard representative matrix of N , in which the first r(N ) columns constitute a unit matrix, can be obtained. Theorem 2.7.1 ([2], Theorem 1) In a standard representative matrix R of a binary chain group N , each row represents an elementary chain. Proof: In a representative matrix of a binary chain group N , the chains of N correspond to a linear combination of the rows of the matrix, and the total number of chains of N is 2r(N ) . Suppose in the matrix R there exists one row that represents a non-elementary chain f of N . Then there exist nonzero chains g and h of N such that f = g + h, one of which has zero coefficients for all the elements of E corresponding to the first r(N ) columns of matrix R. But this is impossible, since g and h must correspond to linear combinations of the rows of R.
2.8
Minors
Let G be a graph. Let S be a subset of E(G). We define G : S as a subgraph of G where V (G : S) = V (G) and E(G : S) = S. We define G · S, called the reduction of G to S, as a subgraph of G where V (G · S) = {u, v | (u, v) ∈ S} and E(G · S) = S. Clearly, G : S is obtained from G by deleting all the edges of E − S, and G · S is obtained from G : S by deleting all the isolated vertices. We define another graph G ctr S, called the contraction of G to S with V (G ctr S) = {A| A is a component of G : (E(G) − S)}, and E(G ctr S) = {(A, B) | (u, v) ∈ S, u ∈ V (A), v ∈ V (B)}. By deleting the isolated vertices of G ctr S, we obtain the reduced contraction G × S = (G ctr S) · S of G to S. If G is oriented, we will assume that G : S, G · S, G ctr S, and G × S to be correspondingly oriented ([6], p13). Let N be a chain group on a set E over R. Let S be any subset of E. A resriction of a chain f of N to S is a chain g on S such that g(x) = f (x) for every x ∈ S. The restrictions to S of the chains of N constitute a chain
2
DEFINITIONS AND THEOREMS
10
group on S. We denote this chain group by N · S, and call it the reduction of N to S. The restrictions to S of those chains f of N for which kf k ⊆ S also constitute a chain group. We denote this chain group by N × S, and call it the contraction of N to S. Let g be the restriction to S of a chain f of N . If f (x) = 0 for every x ∈ E − S, we say that f is the zero-extension of g ([6], p14). Consider the oriented graph G · S. If f is the coboundary of a 0-chain h in G, it is clear that the restriction of f to S is the coboundary, in G · S, of the restriction of h to V (G · S). It follows that: Theorem 2.8.1 ([6], 2.211) The reduction to S of the coboundary group of G over R, (∆R (G)) · S, is the coboundary group of the reduction to S of G over R, ∆R (G · S). Now consider the oriented graph G × S. Suppose that g = δh is a chain of ∆R (G×S), and f is the zero-extension of g in ∆R (G). We define a 0-chain h1 of G as follows: h1 (x) = h(X) for every x ∈ X if X ∈ V (G × S), and h1 (x) = 0 otherwise. Clearly, f = δh1 . Now suppose that f = δh1 is a chain in ∆R (G) where kf k ⊆ S and g is the restriction of f to S. Then h1 has the same coefficient for the vertices in the same component of G : (E − S). We could define a 0-chain h of G × S as follows: h(X) = h1 (x) for x ∈ X. Clearly g = δh. Hence the following theorem could be deduced: Theorem 2.8.2 ([6], 2.213) The contraction to S of the coboundary group of G over R, (∆R (G))×S is the coboundary group of the reduced contraction to S of G over R, ∆R (G×S). Let M = (E, Q) be a matroid. Let S be any subset of E. Let L be the class of all non-null intersections of S with members of Q. Let L0 be the set of all minimal members of L. Clearly, L satisfies matroid Axiom 2 as does Q. Hence (S, L0 ) is a matroid, by Theorem 2.1.2. We denote this matroid by M · S, and call it the reduction of M to S. Let Q0 be the class of all members
2
DEFINITIONS AND THEOREMS
11
of Q that are subsets of S. It is easy to see that (S, Q0 ) is also a matroid. We denote it by M × S, and call it the contraction of M to S ([6], p17). Let N be a chain group on S, then by a comparison of the definitions, we can deduce the following theorem: Theorem 2.8.3 ([6], 2.31) 1. M (N · S) = M (N ) · S 2. M (N × S) = M (N ) × S Let G be a graph. Let S be any subset of E(G). By Theorem 2.8.3, Theorem 2.8.1, and Theorem 2.8.2, we can easily deduce the following two theorems: Theorem 2.8.4 ([6], 2.321) The reduction to S of the bond matroid of G, B(G)·S, is the bond matroid of the reduction to S of G, B(G · S). Theorem 2.8.5 ([6], 2.322) The contraction to S of the bond matroid of G, B(G) × S, is the bond matroid of the reduced contration to S of G, B(G × S). By the above two theorems, we can deduce that: Theorem 2.8.6 ([5], 4.10) A minor of a graphic matroid is graphic. Let M = (E, Q) be a matroid. Let S be a subset of E and T be a subset of S. Then we have the following theorem ([6], p18): Theorem 2.8.7 ([6], p18) 1. (M × S) × T = M × T, 2. (M · S) · T = M · T, 3. (M · S) × T = (M × (E − (S − T ))) · T,
2
DEFINITIONS AND THEOREMS
12
4. (M × S) · T = (M · (E − (S − T ))) × T. Proof: Theorem 2.8.7, 1: Can be easily deduced from the definitions. For Theorem 2.8.7, 2: Let X be a circuit of (M · S) · T . Then X is the intersection with T of a circuit of M · S, and therefore of a circuit of M . Hence there exists a circuit Y of M · T such that Y ⊆ X. Conversely, suppose Y is a circuit of M · T . Then there is a circuit Z of M such that Z ∩ T = Y . But Z contains a circuit Z1 of M · S which meets Y , by theorem 1. Hence there is a circuit X of (M · S) · T such that X ⊆ Z1 ∩ Y ⊆ Z ∩ T = Y . Applying matroid Axiom 1 to (M · S) · T and M · T , we deduce that these matroids are identical. For Theorem 2.8.7, 3: Let X be a circuit of (M · S) × T . Then X is a circuit of M · S contained in T . It follows that there is a circuit X1 of M such that X1 ∩ T = X, and X1 ∩ (S − T ) is null. But then X1 is a circuit of M × (E − (S − T )). Hence there is a circuit Y of (M × (E − (S − T ))) · T such that Y ⊆ X1 ∩ T = X. Conversely, suppose Y is a circuit of (M × (E − (S − T ))) · T . Then there is a circuit Y1 of M × (E − (S − T )) such that Y = Y1 ∩ T . But then Y1 is a circuit of M such that Y1 ∩ (S − T ) is null. Hence there is a circuit X of M · S such that X ⊆ Y1 ∩ S = Y1 ∩ T = Y . But then X ⊆ Y , and so X is a circuit of (M · S) × Y . Applying matroid Axiom 1 to (M · S) × T and (M × (E − (S − T ))) · T , we deduce that these matroids are identical. For Theorem 2.8.7, 4: It is obtained by writing E − (S − T ) for S in Theorem 2.8.7, 3. A chain group of the form (N · S) × T is called a minor of N ([6], p16). Similarly, a matroid of the form (M · S) × T is called a minor of M ([6], p19). Minors of M include M itself and all the reductions and contractions of M , since M = (M · E) × E, M · S = (M · S) × S, and M × S = (M · E) × S.
2
DEFINITIONS AND THEOREMS
2.9
13
Connectivity
Let M = (E, Q) be a matroid. A separator of M is a subset S of E such that no circuit of M meets both S and E − S. A separator is elementary if it is non-null and contains no other non-null separator. Clearly, the elementary separators of M are disjoint and their union is E ([6], p27). A matroid M = (E, Q) is connected if it has no separator other than E and its null subset ([6], p28). Theorem 2.9.1 ([6], 3.12) A subset S of E is a separator of a matroid M = (E, Q) if and only if M · S = M × S. Proof: Suppose S is a separator of M . Then a circuit of M has a nonnull intersection with S if and only if it is itself a subset of S. This implies M · S = M × S. Conversely, suppose M · S = M × S. Let Y be any circuit of M . If it meets S, it contains a circuit Y1 of M · S, that is, of M × S. But then Y1 is a circuit of M . Hence, Y = Y1 ⊆ S by matroid Axiom 1. We deduce that S is a separator of M . Let M = (E, Q) be a matroid. If S is an elementary separator of M , then we call the matroid M · S, that is, M × S, a component of M ([6], p28). Theorem 2.9.2 ([6], 3.13) Let S be a separator of a matroid M = (E, Q). Then, for each T ⊆ E, S ∩ T is a separator of both M · T and M × T . Proof: Let Y be a circuit of M · T or M × T . Then there is a circuit Z of M such that Y = Z ∩ T . But either Z ⊆ S or Z ⊆ E − S. Hence either Y ⊆ S ∩ T , or Y ⊆ T − (S ∩ T ). Let G be a graph. Let S be a subset of E(G). The vertices of attachment of S, denoted by W (S), is the common vertices of G · S and G · [E(G) − S]. If |W (S)| = 1, then the single vertex of attachment of S is called a cutvertex of G. The graph G is called separable if it either has a cut-vertex or is
2
DEFINITIONS AND THEOREMS
14
disconnected. The maximal non-null nonseparable subgrpahs of a graph G are called separates of G. Theorem 2.9.3 ([6], 3.24) If G · E(G) is nonseparable, then B(G) is a connected matroid.
2.10
Bridges
Let Y be a circuit of a matroid M = (E, Q). The bridges of Y in M are defined as the elementary separators of the matroid M · (E − Y ). To each such bridge B there corresponds a matroid M × (B ∪ Y ). We refer to this matroid as a Y -component of M . Theorem 2.10.1 ([6], 4.13) Let Y be a circuit of a matroid M = (E, Q). Let B be a bridge of Y in M . Then the Y -component M × (B ∪ Y ) is connected unless [M · (E − Y )] × B = M × B. If this condition holds, however, then B and Y are the elementary separators of M × (B ∪ Y ). Proof: Let Z be a separator of M × (B ∪ Y ). Then either Y ⊆ Z or Y ∩Z = φ. Moreover Z ∩B is a separator of the matroid [M ×(B ∪Y )]·B, by Theorem 2.9.2; and this matroid is [M ·(E −Y )]×B, by Theorem 2.8.7 4. But B is an elementary separator of M · (E − Y ). Hence B ⊆ Z or B ∩ Z = φ, by hypothesis. Accordingly, B and Y are the only possible nontrivial separators of M × (B ∪ Y ). The necessary and sufficient condition for B and Y to be separators of M × (B ∪ Y ) is [M × (B ∪ Y )] · B = [M × (B ∪ Y )] × B, by Theorem 2.9.1. Since [M × (B ∪ Y )] · B = [M · (E − Y )] × B,
2
DEFINITIONS AND THEOREMS
15
by Theorem 2.8.7 4, and [M × (B ∪ Y )] × B = M × B, by Theorem 2.8.7 1, this condition is equivalent to [M · (E − Y )] × B = M × B. Theorem 2.10.2 ([2], Theorem 2) If the matroid M = (E, Q) is connected then each Y -component of M is connected. Proof: Let B be a bridge of Y in M . Suppose the Y -component of M , M × (B ∪ Y ) is disconnected. Then M × B = [M · (E − Y )] × B, by Theorem 2.10.1. Since [M · (E − Y )] × B = [M · (E − Y )] · B, by Theorem 2.9.1, and [M · (E − Y )] · B = M · B, by Theorem 2.8.7 2, we have M ×B =M ·B Hence B is a separator of M , by Theorem 2.9.1, which implies that M is disconnected, which contradicts the fact that M is connected. Theorem 2.10.3 ([6], 4.51) Let M be the bond matroid of a graph G. Let Y be a circuit of M having at most one bridge in M . Then there is a vertex a of G such that Y is the set of all edges of G joining a to other vertices.
2
DEFINITIONS AND THEOREMS
16
Proof: Let H be the graph obtained from G by deleting the edges of Y . Then H = G : (E(G) − Y ), and we can write the bond matroid of H, B(H) as: B(H) = B(G : (E(G) − Y )) = B(G · (E(G) − Y )) = B(G) · (E(G) − Y ), by Theorem 2.8.4. Clearly, for each component C of H, E(C) is a separator of B(H). So it must be a superset of an elementary separator B of B(H) if it is non-null. If Y has at most one bridge in B(G), that is, B(H) has just one elementary separator, then at most one component of H contains edges, other components are edgeless. Thus for the two end-graphs of Y , at least one of them must be edgeless, i.e., it just contains one single vertex. Let’s refer to this single vertex as a. Since a is one end-graph of Y in G, Y is the set of all edges of G joining a to other vertices. For a bridge B of a circuit Y in a binary matroid M , if the circuits of the matroid M ×(B ∪Y )·Y are disjoint subsets S1 , S2 , . . . , Sk of Y whose union is Y , we say that B partitions Y , and that {S1 , S2 , . . . , Sk } is the partition of Y determined by B. Then the standard representative matrix of M ×(B ∪Y )·Y has just one nonzero element in each column, and its rows corresponds to the circuits Si . Add to the matrix an extra row which has a 1 in each column, we obtain the incidence matrix of a graph GY corresponding to this matroid M × (B ∪ Y ) · Y . Theorem 2.10.4 If the matroid M × (B ∪ Y ) is graphic, and let GBY be a graph whose bond matroid represents M × (B ∪ Y ). Then GY = GBY · Y . Proof: Since Y has only one bridge in the matroid M × (B ∪ Y ), by Theorem 2.10.3, there must be a vertex a in graph GBY such that Y is the set of all edges joining a to other vertices in GBY . Hence all GBY · Y contains are the vertex a, all the edges incident on a, and the other ends of these edges. Each set of edges incident on a and another vertex is a bond in GBY ·Y . Since B(GBY · Y ) = M × (B ∪ Y ) · Y = B(GY ) and GY also contains a vertex with all the edges in GY incident on it. It is easy to see that GBY · Y = GY , by a comparison of them.
3
RECOGNIZING BINARY GRAPHIC MATROIDS
17
Theorem 2.10.5 ([2], Theorem 3) If M is regular then each bridge of Y in M partitions Y . Let B1 and B2 be bridges of Y in M which determine partitions P1 = {P11 , P12 , . . . , P1m } and P2 = {P21 , P22 , . . . , P2n } of Y , respectively. We say B1 and B2 do not overlap if there exists P1i and P2j such that P1i ∪ P2j = Y . Otherwise, we say they overlap. Y is an even circuit of M if the following two conditions hold: 1. Each bridge of Y in M partitions Y . 2. The bridges of Y in M can be arranged into two disjoint classes so that no two members of the same class overlap. Theorem 2.10.6 ([2], Theorem 5) In a graphic matroid every circuit is even. Theorem 2.10.7 ([2], Theorem 8) Let Y be an even circuit of a connected binary matroid M such that every Y -component of M is graphic. Then M is graphic.
3
Recognizing Binary Graphic Matroids
This section describes the algorithm for recognizing binary graphic matroids in detail. The main algorithm is described first, then the sub-algorithms that are used in the algorithm are described in the subsections of this section. Given as input a binary matrix R, representing a binary matroid M , the main algorithm breaks down the matrix R into a list LR of matrices, each representing a component of M . Then for each matrix Ri in LR , it calls the Graphic Test Algorithm (GTA) with Ri as input. If the GTA returns null for a matrix Ri in LR , indicating that the component of M represented by Ri is not graphic, it returns a null matrix indicating that M is not graphic. Otherwise, for each matrix Ri in LR , the GTA returns a matrix Ii , which is the incidence matrix of a graph whose bond matroid is the component of M
3
RECOGNIZING BINARY GRAPHIC MATROIDS
18
Figure 1: The Main Algorithm 1 2
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Input: a binary matrix R representing a binary matroid M Output: NULL or an incidence matrix of a graph whose bond matroid is M Check if R is a zero matrix if R is a zero matrix return R Check if R is in standard form if R is not in standard form Convert R to standard form through elementary row operations Run the Row Grouping Algorithm (RGA) using R as input. Let Lρ be the list of row groups that RGA returns. Initialize an empty matrix I for each row group ρi in Lρ Initialize an empty matrix Ri : for each row index j ∈ ρi Append the row rj of R to Ri endfor Run the Graphic Test Algorithm (GTA) using Ri as input Let Ii be the output of GTA if Ii is NULL return NULL else for each row rj of matrix Ii Append row rj to matrix I endelse endfor return I
represented by Ri . The main algorithm then returns a matrix I, whose rows are the rows of each Ii altogether. The returned matrix I is the incidence matrix of a graph whose bond matroid is M . The main algorithm is described in detail in Figure 1. We follow the standard convention that after a return statement is executed in an algorithm, the algorithm terminates immediately. We assume that the row index and column index of a matrix start at 1. We define a matrix in standard form as a matrix that is in or can be in the form [U |X] within a permutation of columns, where U is a unit matrix.
3
RECOGNIZING BINARY GRAPHIC MATROIDS
3.1
19
Row Grouping Algorithm
Let R be a binary matrix. A row group ρ of R is a set of row indices of R such that if i and j are in ρ then there exists a column index k such that R[i][k] = R[j][k] = 1. For each row group ρ, the corresponding column group is the set {j | R[i][j] = 1, i ∈ ρ}. The Row Grouping Algorithm takes as input a binary matrix R. It uses breath-first search to find an ordered list of row groups, and a corresponding ordered list of column groups. The detailed algorithm is described in Figure 2.
3.2
Graphic Test Algorithm
Given as input a binary matrix R in standard form, representing a binary connected matroid M , The Graphic Test Algorithm (GTA) returns NULL if it determines that M is not graphic. Otherwise, it returns a matrix, which is the incidence matrix of a graph whose bond matroid is M . The Graphic Test Algorithm is basically a divide and conquer algorithm. In the base case when R has no more than two 1s in each column, it constructs and returns a matrix I, whose rows are all the rows of R in addition to a row r, which is the mod 2 sum of all the rows of R. When the base condition is not satisfied, GTA breaks the problem down into smaller subproblems by running the Break Down Algorithm (BDA) using as input the matrix R and a column index j, where the column cj of R has at least three 1s. It returns NULL if BDA returns NULL. Otherwise, BDA returns an ordered list of matrices, LR , each has less rows than R, in company with a corresponding list of column groups, Lκ , and a set Y of column indices. In the conquer step, the algorithm calls itself recursively with each matrix Ri in LR as input. It returns NULL if the recursive algorithm returns NULL for a matrix Ri in LR . Otherwise, the recursive algorithm returns a matrix Ii for each input matrix Ri in LR . Let LI denote the list of Ii . In the combine step, the algorithm calls the Partition Algorithm (PA) with LR and Y as input. It returns NULL if PA returns NULL. Otherwise,
3
RECOGNIZING BINARY GRAPHIC MATROIDS
20
Figure 2: Row Grouping Algorithm (RGA) 1 2 3
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Input: a binary matrix R Output: an ordered list of row groups and a corresponding ordered list of column groups where each row/column group is a set of row/column indices of R Initialize an empty ordered list of row groups, Lρ Initialize an empty ordered list of column groups, Lκ Mark each row and column of R unvisited for each row ri in matrix R if ri is not visited Mark ri visited if ri is not a zero row Initialize an empty queue Q ρ ← ø //ρ: a row group, which is a set of row indices of R κ ← ø //κ: a column group, which is a set of column indices of R Enqueue (i, Q) while Q is not empty j ← Dequeue(Q) ρ ← ρ ∪ {j} for each column ck of R if ck is not visited and R[j][k] = 1 Mark ck visited κ ← κ ∪ {k} for each row rl of R if rl is not visited and R[l][k] = 1 Mark rl visited Enqueue (l, Q) endfor endfor endwhile Append(ρ, Lρ ) Append(κ, Lκ ) endif endif endfor return Lρ and Lκ
3
RECOGNIZING BINARY GRAPHIC MATROIDS
21
PA returns an ordered list LP of partitions of Y , where each Pi in LP is obtained from the matrix Ri in LR . Then the algorithm runs the Classification Algorithm (CA) using LP , Y , Lκ and LI as input. It returns NULL if CA returns NULL. Otherwise, the output C of CA includes two lists for each list LP , Lκ , and LI , and two correponding lists of partition element pair lists. The algorithm then calls the Incidence Matrix Construction Algorithm (IMCA) with C and Y as input, and returns the matrix constructed and returned by IMCA. The detailed algorithm is described in Figure 3.
3.3
Break Down Algorithm
The Break Down Algorithm is used in the Graphic Test Algorithm (GTA). The input to it in GTA is a binary matrix R, and a column index j of R, which satisfies R[a][j] = 1 for at least three distinct rows ra of R. The algorithm tries to break down the matrix R into a list of matrices LR . Each matrix Ri in LR has fewer rows than the matrix R, and has one common row, which is a row ra of R that satisfies R[a][j] = 1. The rest of the rows of Ri are those rows of R whose indices are in the same row group returned by the Row Grouping Algorithm (RGA) when using as input a matrix R0 , which is the same as matrix R except that ra is replaced by a zero row and for each b ∈ Y = {b|R[a][b] = 1}, the column cb is replaced by a zero column. The algorithm will try at most three distinct rows of R, where each row ra satisfies R[a][j] = 1. When trying a row ra , if the list of row groups that the RGA returns contains only one entry, then the breaking down will not be sucessful since LR will contain only one matrix, which is essentially the same matrix as R. If this is the case for all three rows that are tried, then the algorithm returns NULL. Otherwise, it returns the list of matrices in company with the list of column groups returned by the RGA, and the set Y = {b|R[a][b] = 1}, for the successfully tried row ra of R. The algorithm is shown in detail in Figure 4.
3
RECOGNIZING BINARY GRAPHIC MATROIDS
22
Figure 3: Graphic Test Algorithm (GTA) 1 2
4 5 6
8 9 10 11 12 13
15 16 17 18
20 21 22 23 24 25 26 27 28 29 30 31 32 33
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
Input: a binary matrix R in standard form, representing a binary connected matroid M Output: NULL or an incidence matrix of a graph whose bond matroid is M j ← 1 //column index of R while j is a column index of R and column cj has no more than two 1s Increment j by one //Base case: if j is no longer a column index of R Construct a row r, which is the mod 2 sum of all the rows of R Construct a matrix I, whose rows are the rows of R in addition to row r return I. endif //Divide: divide the problem into smaller subproblems //We enter this part if j is the index of a column of R that has more than two 1s Run the Break Down Algorithm (BDA) using R and j as input Let O be the output of BDA //Conquer: solve the subproblems recursively if O is NULL return NULL else Let Y be the set of column indices in O Let Lκ be the list of column groups in O Let LR be the list of matrices in O Initialize an empty ordered list of matrices, LI for each matrix Ri in LR Run the Graphic Test Algorithm (GTA) recursively using Ri as input Let Ii be the output of GTA if Ii is NULL return NULL else Append(Ii , LI ) endfor endelse //Combine: combine the solutions of the subproblems into a solution for the problem Run the Partition Algorithm (PA) using LR and Y as input Let LP be the output of PA if LP is NULL return NULL else Run the Classification Algorithm (CA) using LP , Y , Lκ and LI as input Let C be the output of CA if C is NULL return NULL else Run the Incidence Matrix Construction Algorithm (IMCA) using C and Y as input Let I be the incidence matrix returned by IMCA return I endelse endelse
3
RECOGNIZING BINARY GRAPHIC MATROIDS
Figure 4: Break Down Algorithm (BDA) 1 2 3 4
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
Input: a binary matrix R, and a column index j of R, which satisfies R[a][j] = 1 for at least three distinct rows ra of R Output: NULL or an ordered list of matrices, a corresponding ordered list of column groups and a set of column indices c ← 1 //a counter t ← false //true if the break down is successful a ← 0 //row index of R Initialize an empty ordered list of row groups, Lρ Initialize an empty ordered list of column groups, Lκ Y ← ø //Y : stores the set {b|R[a][b] = 1} while t is false and c ≤ 3 Increment c by one Increment a by one while R[a][j] = 0 Increment a by one Y ← ø for each column cb of R if R[a][b] = 1 Y ← Y ∪ {b} endfor Construct a matrix R0 by first letting R0 = R Then in R0 , replace ra by a zero row, and for each b ∈ Y , replace column cb by a zero column Run the Row Grouping Algorithm (RGA) using R0 as input Lρ ← the list of row groups that the RGA returns Lκ ← the list of column groups that the RGA returns if Lρ contains more than one entry set t to true endwhile if c > 3 Return NULL else //t is true, i.e., break down was successful Initialize an empty ordered list of matrices LR for each row group ρi in Lρ Initialize an empty matrix Ri for each row index k ∈ ρi append the row rk of R to matrix Ri Append the row ra of R to matrix Ri Append(Ri , LR ) endfor endelse Return LR , Lκ , Y
23
3
RECOGNIZING BINARY GRAPHIC MATROIDS
24
Figure 5: Partition Algorithm (PA) 1 2 3
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Input: an ordered list of matrices, LR , in which each matrix Ri has a common row r, and the set Y of indices of those columns that have a 1 in row r Output: NULL or an ordered list of partitions of Y corresponding to the list LR Initialize an empty ordered list of partitions of Y , LP for each matrix Ri in LR Construct a matrix Ri0 by first letting Ri0 = Ri for each column cj in Ri0 if j 6∈ Y Replace column cj by a zero column endfor Transform Ri0 to standard form through elementary row operations for each column cj in Ri0 c ← the number of 1s in cj if c > 1 return NULL endfor Pi ← ø //a partition of Y obtained from Ri for each non-zero row rk in Ri0 Ek ← ø //a partition element of Pi for each column cj in Ri0 if Ri0 [k][j] = 1 Ek ← Ek ∪ {j} endfor Pi ← Pi ∪ {Ek } endfor Append(Pi , LP ) endfor return LP
3.4
Partition Algorithm
Given as input a list LR of matrices, and a set Y of column indices, the Partition Algorithm returns a list LP of partitions of Y where each partition Pi in LP is obtained from the matrix Ri in LR . Or, it returns NULL if no partition of Y could be obtained from a matrix Ri in LR . The detailed algorithm is shown in Figure 5.
3
RECOGNIZING BINARY GRAPHIC MATROIDS
3.5
25
Classification Algorithm
Given as input a set Y of column indices, an ordered list LP of partitions of Y , a corresponding ordered list LI of incidence matrices, another corresponding ordered list Lκ of column groups, the Classification Algorithm tries to divide the list LP into two lists, LP1 and LP2 according to the following criterion: for any two partitions Pi and Pj in the same list, there must be a partition element pair P = (I, J) such that I ∪ J = Y , I ∈ Pi and J ∈ Pj . If this arrangement can not be made, the algorithm returns NULL. Otherwise, it adds two lists, LL1 and LL2 . In each list LLk , each entry Li is a list of partition element pairs, and has i entries. Each entry Pj in Li is a pair (I, J) where I ∪ J = Y , I ∈ Pi+1 , J ∈ Pj , and Pi+1 is the (i + 1)th entry, Pj is the jth entry of LPk . The algorithm also divides the list, LI into two lists, LI1 and LI2 , and the list Lκ into two lists, Lκ1 and Lκ2 . For each Ii in LI and κi in Lκ , if Pi in LP is the jth entry of LPk , then Ii is the jth entry in LIk and κi is the jth entry of Lκk . The algorithm is described in detail in Figure 6.
3.6
Incidence Matrix Construction Algorithm
The Incidence Matrix Construction Algorithm is used in the Graphic Test Algorithm, after the recursive Graphic Test Algorithm returns an incidence matrix Ii for each Ri used as its input. It constructs an incidence matrix X of a graph whose bond matroid is the matroid M represented by the input matrix R of the Graphic Test Algorithm. The detailed algorithm is shown in Figure 7. The incidence matrix X is constructed through unioning all the matrices Ii . The list of all the incidence matrices Ii was previously divided into two lists, LI1 and LI2 , in the Classification Algorithm (CA). The algorithm first constructs an incidence matrix Xi from each list LIi . Then it constructs X by unioning the two incidence matrices X1 and X2 . For each list LIi , if it has just one entry I1 , then the matrix Xi is I1 . Otherwise, Xi is constructed by unioning the first two matrices in LIi to form a new incidence matrix, then unioning the newly formed incidence matrix
3
RECOGNIZING BINARY GRAPHIC MATROIDS
26
Figure 6: Classification Algorithm (CA) 1 2 3 4 5
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Input: a set Y of column indices, an ordered list LI of incidence matrices, a corresponding ordered list Lκ of column groups, a corresponding ordered list LP of partitions of Y , Output: NULL or two ordered lists for each input list and two ordered lists of partition element pair lists Initialize two empty ordered lists of partitions of Y , LP1 and LP2 Initialize two empty ordered lists of incidence matrices, LI1 and LI2 Initialize two empty ordered lists of column groups, Lκ1 and Lκ2 Initialize two empty ordered lists of partition element pair lists, LL1 and LL2 for each Pi in LP if i = 1 Append(Ii , LI1 ), Append(κi , Lκ1 ), Append(Pi , LP1 ) else if Pi is the last entry in LP and LP2 is empty Append(Ii , LI2 ), Append(κi , Lκ2 ), Append(Pi , LP2 ) else p ← false //true if Pi has been appended j ← 1 k ← 1 Initialize an empty ordered list of partition element pairs LP while j ≤ number of entries in LPk and p is false if there exists a partition element pair P = (I, J) such that I ∪ J = Y , I ∈ Pi and J ∈ Pj Append(P, LP ) if Pj is the last entry in LPk Append(Ii , LIk ), Append(κi , Lκk ) Append(Pi , LPk ), Append(LP , LLk ) set p to true else Increment j by one else //no such pair if k = 1 if LP2 is empty Append(Ii , LIk ), Append(κi , Lκk ), Append(Pi , LPk ) set p to true else //LP2 is not empty k ← 2 j ← 1 Empty LP else //k = 2 return NULL endelse endwhile endelse endfor return LP1 and LP2 , LI1 and LI2 , Lκ1 and Lκ2 , LL1 and LL2
4
CORRECTNESS PROOF OF THE ALGORITHM
27
with the third matrix, if any, and so on. Each incidence matrix in LI1 and LI2 must have a common row r where Y is the set of indices of those columns that have a 1 in row r. For each list LIi , each step of the union of two incidence matrices Ia and Ib (each having a common r) takes place as follows: Construct an incidence matrix I, whose rows are those rows of Ib except the common row r, in addition to those rows of Ia except the common row r. Then transform I into a matrix having the common row r. The transformation of I takes place as follows: The algorithm uses the information obtained in the previously run Classification Algorithm to obtain a target row t. And then it runs the switch algorithm to transform row t into the common row r.
3.7
Switch Algorithm
The Switch Algorithm is used in the Incidence Matrix Construction Algorithm. The input to it is a set Y of column indices, an incidence matrix I, and a row index t. The algorithm transforms the row rt of I into a row r where Y is the set of indices of those columns that have a 1 in row r. The detailed algorithm is shown in Figure 8.
4
Correctness Proof of the Algorithm
The main algorithm and the sub-algorithms used in the main algorithm are described in detail in Figures 1 through 8. We shall prove the correctness of these algorithms according to the descriptions in these figures line by line. Since Row Grouping Algorithm is quite straightforward, the proof of it will be skipped.
4.1
The Main Algorithm
The Main Algorithm is described in Figure 1.
4
CORRECTNESS PROOF OF THE ALGORITHM
28
Figure 7: Incidence Matrix Construction Algorithm (IMCA) 1 2 3 4 5
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
Input: a set Y of column indices, two ordered lists of partitions of Y , LP1 and LP2 , two ordered lists of incidence matrices, LI1 and LI2 , two ordered lists of column groups, Lκ1 and Lκ2 , two ordered lists of partition element pair lists, LL1 and LL2 Output: an incidence matrix of a grpah Initialize two empty matrices, X1 and X2 for i = 1 to 2 for each matrix Ij in LIi Find the row ra in Ij where the set {b | Ij [a][b] = 1} = Y if ra is not the last row Swap ra with the last row if j = 1 Xi ← Ij else Let mi and mj be the number of rows in Xi and Ij , respectively Construct a matrix X of mi + mj − 2 rows, in which the first mi − 1 rows are the first mi − 1 rows of Xi and the last mj − 1 rows are the first mj − 1 rows of Ij (I, J) ← the partition element pair P1 in Lj of LLi for each partition element pair Pk = (S, T ) in Lj , whereLj in LLi if S = I for each b ∈ κk , where κk ∈ Lκi Mark each row ra of X where X[a][b] = 1 endfor Let b be a column index in Y − I Search the first mi − 1 rows of X for the row ra , where X[a][b] = 1 Initialize an empty queue Q t ← a while ra is not marked for each row rc where c < mi and X[a][d] = X[c][d] = 1 for some d if rc is marked t ← c, break the while loop else Enqueue(c, Q) endfor a ← Dequeue(Q) endwhile Run the Switch Algorithm (SA) using X, Y , t as input. Xi ← the matrix returned by SA endelse endfor endfor Let m1 and m2 be the number of rows in X1 and X2 , respectively Construct a matrix X of m1 + m2 − 2 rows, in which the first m1 − 1 rows are the first m1 − 1 rows of X1 and the last m2 − 1 rows are the first m2 − 1 rows of X2 return X
4
CORRECTNESS PROOF OF THE ALGORITHM
29
Figure 8: Switch Algorithm (SA) 1 2
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
Input: a matrix X, a set Y of column indices, and a row index t of X Output: modified matrix X I ← {b | X[t][b] = 1} while Y − I 6= ø Let b be a column index such that b ∈ Y − I Search the the column cb of X for two rows ra , rc such that X[a][b] = X[c][b] = 1 and a > b Construct a matrix X 0 = X. In X 0 , replace row rt and row ra with zero rows, and for each d such that X[a][d] = 1 or X[t][d] = 1, replace column cd with a zero column ρ ← ø if the row rc of X 0 is a zero row ρ ← ρ ∪ {c} else Run the Row Grouping Algorithm (RGA) using X 0 as input Let Lρ be the list of row groups returned by RGA ρ ← the row group that contains c endelse for each e ∈ ρ for each column cd in X if X[e][d] = 1 if X[a][d] = 1 X[a][d] ← 0 X[t][d] ← 1 else if X[t][d] = 1 X[a][d] ← 1 X[t][d] ← 0 endif endfor endfor I ← {b | X[t][b] = 1} endwhile if rt is not the last row of X Swap rt with the last row in X return X
4
CORRECTNESS PROOF OF THE ALGORITHM
30
Lines 4 through 6: If the input matrix R is a zero matrix, then R represents an empty matroid M . R is also an incidence matrix of a graph G that has no link. Clearly the bond matroid of G is M . Lines 7 through 9: If R is not in standard form, then elementary row operations are used to transform R into a standard form. These operations do not alter the property of the matrix being a representative matrix of the same matroid M (see Section 2.7). Within a permutation of columns, the matrix R in standard form is a standard representative matrix. In a standard representative matrix, each row represents an elementary chain (Theorem 2.7.1). In other words, the set Y = {b | R[a][b] = 1} for each row ra in R represents a circuit of M . Lines 10 through 11: With R as its input, the Row Grouping Algorithm (RGA) returns a list Lρ of row groups and a corresponding list Lκ of column groups. Since a row group ρ of R is a set of row indices of R such that if i and j are in ρ then there exists a column index k such that R[i][k] = R[j][k] = 1; and for each row group ρ, the corresponding column group is the set {j | R[i][j] = 1, i ∈ ρ}, it is easy to verify that each column group κ in Lκ represents an elementary separator S of M . Lines 12 through 27: Lines 13 through 26 are a for loop. Inside the for loop, in lines 14 through 17, for each row group ρi in Lρ , a matrix Ri , whose rows are those rows of R whose indices are in ρi , is constructed. As the corresponding column group κi represents an elmentary separator Si of M , Ri is a binary matrix in standard form representing the matroid M ·Si = M ×Si , which is a connected component of M . Hence in line 18, each input Ri to the Graphic Test Algorithm (GTA) is a valid input. For each matrix Ri , GTA outputs Ii . We shall prove in Section 4.2 that GTA returns NULL if it determines that the matroid represented by its input matrix is not graphic, or returns an incidence matrix of a graph whose bon-matroid is the matroid represented by its input matrix. In line 20, if Ii is NULL, then the matroid represented by Ri , M × Si , is not graphic. Since M × Si is a minor of M and and a minor of a graphic matroid is graphic (Theorem 2.8.6), M cannot be graphic, hence the algorithm returns NULL in line 21, indicating that M is
4
CORRECTNESS PROOF OF THE ALGORITHM
31
not graphic. If each Ii is not NULL, then in lines 22 through 25, a matrix I whose rows are all the rows of each Ii altogether is constructed. Since each Ii represents a graph whose bond matroid is a component of M , M × Si , it is clear that I represents a graph G, where the components of G are those graphs represented by each Ii , and the bond matroid of G is M . Hence it is correct to return I in line 27.
4.2
The Graphic Test Algorithm
The Graphic Test Algorithm (GTA) is described in Figure 3. It is basically a divide and conquer algorithm. We shall prove the correctness of GTA by induction. Lines 8 through 13 describe the base case, in which each column of R has no more than two 1s. A row r which is the mod 2 sum of all the rows of R is constructed in line 10, and a matrix I, whose rows are those rows of R in addition to row r, is constructed in line 11. Clearly I is an incidence matrix of a graph whose bond matroid is M . Hence M is graphic, and it is correct to output I in line 12. Lines 15 through 18 describe the divide step. When the base condition is not satisfied, i.e., there exists a column of R that has at least three 1s, the algorithm tries to break down the problem into smaller subproblems by running the Break Down Algorithm (BDA) using as input the matrix R and a column index j, where the column cj of R has at least three 1s (line 17). Lines 20 through 33 describe the conquer step. We shall prove in Section 4.3 that if BDA returns NULL, then the matroid represented by its input matrix is not graphic. Hence if the output of BDA is NULL, it is correct for the algorithm to return NULL in line 21. We shall also prove in Section 4.3 that if the matrix R is successfully broken down into a list LR of matrices, each matrix Ri in LR represents a Y -component of M , M × (Bi ∪ Y ), where Y is a circuit of M represented by the set of column indices (also indicated by Y ) returned by BDA, and Bi is a bridge of Y in M , represented by the column group κi in the list Lκ returned by BDA.
4
CORRECTNESS PROOF OF THE ALGORITHM
32
At line 28, for each matrix Ri in LR , GTA is run recursively with Ri as its input, and outputs Ii . Assume that GTA runs correctly for each of its input Ri (Induction Hypothsis). If any output Ii is NULL, then the matroid M × (Bi ∪ Y ), represented by the matrix Ri is not graphic. Since M × (Bi ∪ Y ) is a minor of M , and a minor of a graphic matroid is graphic (Theorem 2.8.6), the matroid M represented by matrix R cannot by graphic. Hence it is correct for the algorithm to return NULL in line 30. If each Ii is a matrix, then Ii is the incidence matrix of a graph whose bond matroid is the Y -component M × (Bi ∪ Y ) (Induction Hypothesis), and the algorithm continues to the combine step. Lines 35 through 49 describe the combine step. In the combine step, first, with LR and Y as its input, the Partition Algorithm (PA) is run to determine whether each bridge Bi of Y , represented by the column group κi in Lκ , partitions Y . We shall prove in Section 4.4 that if PA returns NULL, then there is a bridge Bi that does not partition Y ; otherwise, in the list LP returned by PA, each entry Pi is the partition of Y determined by the bridge Bi . Since if M is regular, then each bridge of Y in M partitions Y (Theorem 2.10.5). So if PA returns NULL, the matroid M cannot be regular. And since every graphic matroid is regular, M cannot be graphic if it is not regular. Hence it is correct for the algorithm to return NULL in line 38. If each bridge Bi of Y in M partitions Y , the list LP of partitions of Y is obtained and returned by PA. And the algorithm continues to line 40, where the classification algorithm is run to determine whether Y is an even circuit. We shall prove in Section 4.5 that if CA returns NULL, then Y is not even; otherwise, Y is even, and its input list LP of partitions of Y is divided into two lists LP1 and LP2 , according to the following criterion: for any two partitions Pi and Pj in the same list LPk , there exists a partition element pair P = (I, J) such that I ∪ J = Y , I ∈ Pi and J ∈ Pj ; and P will be added as the jth entry of (i − 1)th partition element pair list in the list LLk returned by CA. The other two input lists of CA, LI and Lκ , each of their ith entry corresponds to the ith entry in LP , are divided into two lists accordingly.
4
CORRECTNESS PROOF OF THE ALGORITHM
33
Since in a graphic matroid every circuit is even (Theorem 2.10.6), if CA returns NULL, then Y is not even, and then the matroid M cannot be graphic. Hence it is correct for the algorithm to return NULL in line 42. If the output of CA is not NULL, then the algorithm continues to line 43. Up to this point in the algorithm, Y is even and each Y -component of M is graphic. By Theorem 2.10.7, we can conclude that M is graphic. The Incidence Matrix Construction Algorithm (IMCA) is run in line 44. We shall prove in Section 4.6 that the incidence matrix returned by IMCA is the incidence matrix of a graph whose bond matroid is M .
4.3
The Break Down Algorithm
The Break Down Algorithm is described in Figure 4. Lines 12 through 30 are a while loop. The algorithm can enter the while loop at most three times, by the loop counter condition. Each time it enters the while loop, a distinct row ra where R[a][j] = 1 is selected, and there constructs a matrix R0 , which is the same as matrix R except that the row ra is replaced by a zero row and for each b ∈ Y = {b|R[a][b] = 1}, the column cb is replaced by a zero column. It is easy to see that if R represents the matroid M = (E, Q), then R0 represents the matroid M · (E − Y ), where Y is a circuit of M , represented by the set {b|R[a][b] = 1}. As reasoned in Section 4.1, after the Row Grouping Algorithm (RGA) is run using R0 as its input, in the list of column groups Lκ returned by RGA, each entry κi represents an elementary separator Si of R0 , that is, a bridge Bi of Y . And for each row group ρi in the list Lρ returned by RGA, the matrix Ri0 , whose rows are those rows of R whose indices are in ρi , represents the matroid [M · (E − Y )] × Bi = [M × (Bi ∪ Y )] · Bi (by Theorem 2.8.7 3). Thus each matrix Ri in the list LR returned by the algorithm, whichis constructed in lines 35 through 41, and whose rows are those rows of Ri0 in addition to the row ra of R, represents the matroid M × (Bi ∪ Y ). If there is only one entry in the list of column groups returned by RGA, then there is only one bridge of Y in M for that choice of Y . If this is
4
CORRECTNESS PROOF OF THE ALGORITHM
34
the case each time the algorithm enters the while loop, then the algorithm will terminate after it has entered the while loop for three times, and return NULL. In this case, there are three distinct choices of Y , and for each choice of Y , j ∈ Y and there is only one bridge of Y in M . By Theorem 2.10.3, if M is graphic, then each distinct Y corresponds to the set of edges incident on a distinct vertex v, then the column cj corresponds to an edge that has three ends, which is impossible. Hence M is not graphic if the algorithm returns NULL.
4.4
The Partition Algorithm
The Partition Algorithm is described in Figure 5. It is used in the Graphic Test Algorithm (GTA). The input to it in GTA is the list LR of matrices broken down in the previously run Break Down Algorithm (BDA), and the set Y of column indices also returned by BDA. We know from the proof in Section 4.3 that each matrix Ri in LR represents the matroid M × (Bi ∪ Y ), where M is the matroid represented by the input matrix R of GTA, Y is a circuit of M represented by the set Y , and Bi is a bridge of Y in M represented by the column group κi in the list Lκ returned by BDA. For each matrix Ri in R, the algorithm first constructs a matrix R0 , which is the same as Ri except that each column whose index is not in Y is replaced by a zero column (lines 7 through 11). Clearly, Ri0 represents the matroid [M × (Bi ∪ Y )] · Y . The algorithm then transforms each matrix Ri0 into a standard form through elementary row operations (line 12). We already know that elementary row operations do not alter the property of the matrix being a representative matrix of the same matroid. So each Ri0 still represents the matroid [M × (Bi ∪ Y )] · Y . Now since each Ri0 is in standard form, each row of it represents an elementary chain. In other words, for each row ra in Ri0 , the set {b | Ri0 [a][b]} represents a circuit of the matroid [M × (Bi ∪ Y )] · Y . For each matrix Ri0 , the number of 1s in each column is counted (lines 13 through 14). If in matrix Ri0 , each column has at most one 1, then the circuits
4
CORRECTNESS PROOF OF THE ALGORITHM
35
of the matroid [M × (Bi ∪ Y )] · Y , each represented by the set {b | Ri0 [a][b]} for a row ra in Ri0 , are disjoint subsets of Y . In this case, we say that Bi partitions Y and each partition element in the partition Pi determined by Bi is a circuit of the matroid [M × (Bi ∪ Y )] · Y (See section 2.10). It is quite clear that the set Pi in the list LP returned by the algorithm, which is constructed in lines 19 through 26, is the partition determined by Bi . If there exists a column cj in Ri0 that has more than one 1, i.e., there exist two distinct rows ra and rb of Ri0 such that Ri0 [a][j] = Ri0 [b][j], then the circuit A of [M × (Bi ∪ Y )] · Y , represented by the set {c | Ri0 [a][c]}, and the circuit B of [M × (Bi ∪ Y )] · Y , represented by the set {c | Ri0 [b][c]}, are not disjoint. In this case the algorithm returns NULL (line 16). Hence if the algorithm returns NULL, it indicates that there exists a bridge Bi that does not partition Y .
4.5
The Classification Algorithm
The Classification Algorithm (CA) is described in Figure 6. It is used in the Graphic Test Algorithm (GTA). The input to it in GTA is the set Y of column indices, the list LP of partitions of Y , the list LI of incidence matrices, and the list Lκ of column groups. The algorithm tries to put each entry in LP into two disjoint lists LP1 and LP2 , and each entry in each of the other corresponding lists into two disjoint lists accordingly. For any two partitions Pi and Pj to be put in the same list, the following condition (lines 23 through 24) must be satisfied: I ∪ J = Y , I ∈ Pi and J ∈ Pj . This condition is also the condition for the two bridges Bi and Bj to not overlap, where Bi determines the partition Pi and Bj determines the partition Pj (See Section 2.10). If all the partitions in the list LP can be put into two lists, then all the column groups in the list Lκ can be put into two lists accordingly. Since each column group κi represents the bridge Bi , which determines the partition Pi , all the bridges can be arranged into two disjoint classes such that no two bridges in the same class overlap. Then in this case Y is an even circuit (See
4
CORRECTNESS PROOF OF THE ALGORITHM
36
Section 2.10). If there exists a partition Pi that can be put in neither of the two lists, then the algorithm returns NULL in line 42. In this case, the bridge Bi that determines Pi also cannot be put into either of the two classes accordingly, hence Y is not even.
4.6
Incidence Matrix Construction
The Incidence Matrix Construction Algorithm (IMCA) is described in Figure 7. It is used in the Graphic Test Algorithm (GTA). The input to it in GTA is the output of the previously run Classification Algorithm, the lists LP1 , LP2 , LI1 , LI2 , Lκ1 , Lκ2 , LL1 , and LL2 , and the set Y of column indices, which represents a circuit Y of the matroid M represented by GTA’s input matrix R. Up to the point where the algorithm is run in GTA, M has been determined graphic (See Section 4.2), and the task of IMCA is to construct and return an incidence matrix X of a graph whose bond matroid is M . In addition, up to this point, Y has been determined to be an even circuit, and the list LP has been divided into two lists, LP1 and LP2 according to the following criterion: for any two partitions Pi and Pj in the same list, there exsits a partition element pair (I, J) such that I ∪ J = Y , I ∈ Pi and J ∈ Pj . Each of the other two lists LI and Lκ , is divided into two lists, LI1 and LI2 , Lκ1 and Lκ2 accordingly. Hence any two column groups in the same list represent two bridges that do not overlap. To prove that the matrix X constructed in the algorithm represents a graph whose bond matroid is M , let’s look at the construction process in Figure 7 line by line. Lines 8 through 44 are a for loop, the algorithm enters the for loop twice, each time working on a list LIi to construct a matrix Xi . Lines 9 through 43 is another for loop inside the above for loop. The algorithm enters the for loop each time for a matrix Ij in the list LIi . Inside the second for loop, lines 10 through 12 look for a common row/vertex ra whose incident edges constitute the set Y , and if the row ra is not the last
4
CORRECTNESS PROOF OF THE ALGORITHM
37
row, then swap it to the last row. In the proof below, we show that the common row ra can be found in each incidence matrix Ij in a LIi : Proof: Each incidence matrix Ij in a LIi represents a graph whose bond matroid is a Y -component of M . Since in any Y -component, Y has only one bridge, by Theorem 2.10.3, in any graph whose bond matroid is the Y component, there exists a vertex v where the the set of edges incident on v is Y . Hence each incidence matrix Ij in a list LIi must have a common row r, which represents the vertex v whose incident edge set is Y . If Ij is the first entry in the list LIi , then it becomes Xi in lines 13 through 14. Otherwise, in lines 15 through 42, a new matrix Xi is constructed from the matrix Xi that has been constructed so far and the matrix Ij . In lines 16 through 19, there constructed a new matrix X with mi +mj −2 rows, whose first mi − 1 rows are those rows of Xi except the last row, and last mj − 1 rows are those rows of Ij except the last row. We already know that Ij is an incidence matrix, and the last row in Ij is the common row r. We will show later in this section that Xi is also an incidence matrix, and the last row in Xi is also the common row r. Hence the newly constructed matrix X is the incidence matrix of a graph, in which the first mi − 1 rows represent the vertices in an end graph H1 of Y , and the last mj − 1 rows represent the vertices in the other end graph H2 of Y . Let’s denote G to be the graph represented by X, G1 to be the graph represented by X1 , and G2 to be graph represented by Ij . The bond matroid of G1 is a Y -component of M , M × (Bj ∪ Y ), where Bj is a bridge of Y in M represented by the jth column group in the list Lκi . We can see clearly that G × (Bj ∪ Y ) ∼ = G2 . In line 40 the Switch Algorithm is run to transform X into an incidence matrix of a graph G0 whose bond matroid B(G0 ) is the same as the bond matroid B(G) of G, and the last row in the matrix is the common row r. We will prove this later in this section. In line 41, the matrix transformed from X in the Switch Algorithm becomes Xi . We can prove by induction that the Xi at the end of the for loop that ends at line 43 has the common row r as
4
CORRECTNESS PROOF OF THE ALGORITHM
38
its last row, and is the incidence matrix of a graph whose bond matroid is M × (B1 ∪ B2 . . . ∪ Bj ∪ Y ), where B1 , B2 , . . . Bj are the bridges of Y in M represented by the 1, 2, . . . , jth column groups in the list Lκi : proof: Base case: (where j = 1) Xi is I1 that is assigned to it at line 14, and the last row is the common row by lines 10 through 12. And Xi is the incidence matrix of a graph whose bond matroid is the Y -component of M , M × (B1 ∪ Y ). Inductive step: In the beginning of the for loop that ends at line 43, Xi is the incidence matrix of the graph G1 whose bond matroid is M × (B1 ∪ B2 . . . ∪ Bj−1 ∪ Y ), by the Induction Hypothesis. Clearly the graph G1 ∼ = G × (B1 ∪ B2 . . . ∪ Bj−1 ∪ Y ), and the graph G2 ∼ = G × (Bj ∪ Y ). So the bond matroid B(G) of graph G is B(G1 ) ∪ B(G2 ) = [M × (B1 ∪ B2 . . . ∪ Bj−1 ∪ Y )] ∪ [M × (Bj ∪ Y )] = M × (B1 ∪ B2 . . . ∪ Bj ∪ Y ) We will see later in this section, that the Switch Algorithm transforms X into another incidence matrix X 0 , which has the common row as its last row and represents a graph G0 whose bond matroid B(G0 ) is the same as the bond matroid of G. As X 0 is assigned to Xi at the end of the for loop in line 41, the Xi at the end of the for loop that ends at line 43 is the incidence matrix of a graph whose bond matroid is M × (B1 ∪ B2 . . . ∪ Bj ∪ Y ).
As reasoned above, at the end of the for loop that starts at line 8 and ends at line 44, X1 represents a graph whose bond matroid is M × (A ∪ Y ),
4
CORRECTNESS PROOF OF THE ALGORITHM
39
where A is the union of all the bridges represented by the column groups in Lκ1 ; X2 represents a graph whose bond matroid is M × (B ∪ Y ), where B is the union of all the bridges represented by the column groups in Lκ2 . And the last row in both X1 and X2 is the common row r. Hence the matrix X constructed in lines 45 through 48 represents the graph whose bond matroid is [M × (A ∪ Y )] ∪ [M × (B ∪ Y )] = M × (A ∪ B ∪ Y ) = M. Now we prove that the Switch Algorithm can transform the graph G, represented by the matrix X in the for loop that starts at line 9 and ends at line 43, into a graph G0 whose bond matroid B(G0 ) is the same as the bond matroid B(G) of G, and one end graph of Y is a single vertex. We prove this by the following theorem: Theorem 4.6.1 ([5], 8.4) Let G be a nonseparable graph. Let Y be a bond of G. Let B1 , . . . , Bn be the bridges of Y in B(G). If B1 , . . . , Bn are pairwise nonoverlapping, and neither end-graph of Y is a single vertex, then G can be transformed into a graph G0 such that the bond matroid of G, B(G) = B(G0 ) and one end-graph of Y is a single vertex. Proof: Let H1 , H2 be the two end-graphs of Y in G. It is clear that each G · Bi is a separate of H1 or H2 . Let H2 denote the end-graph that has fewer edges. Let v be a vertex of G · Bi , we denote by C(Bi , v) the component of H1 : [E(H1 )−Bi ] or H2 : [E(H2 )−Bi ] containing vertex v. We denote by Y (Bi , v) the set of edges incident on the vertices of C(Bi , v), which is the same set of edges incident on v in [G×(Bi ∪Y )]·Y . For a bridge Bi , Y (Bi , v) is an element of the partition Pi determined by Bi (see section 2.10). Since B1 , . . . , Bn are pairwise nonoverlapping, for any two briges Bi , Bj , there exist a vertex vi in G · Bi and a vertex vj in G · Bj such that Y (Bi , vi ) ∪ Y (Bj , vj ) = Y . Let G · Bi be a separate of H1 . Let G · B2 be a separate of H2 . Then there exist a vertex vi in G · Bi and a vertex v2 in G · B2 such that Y (Bi , vi ) ∪ Y (B2 , v2 ) = Y . Find all the pairs (Bi , vi ) in H1 that satisfiy the relation
4
CORRECTNESS PROOF OF THE ALGORITHM
40
Y (Bi , vi ) ∪ Y (B2 , v2 ) = Y . Let (B1 , v1 ) be the pair for which C(B1 , v1 ) has the least possible number of edges. Let A1 , . . . , Ak , where A1 = B1 , be the sets of edges of the separates of H1 having v1 as a vertex. For each Ai , let Ei be the subgraph of H1 , which is the union of G · Ai and those subgraphs C(Ai , v) of H1 such that v is a vertex of G · Ai other than v1 . Then the graphs Ei have only one common vertex v1 . And since H1 is connected, it is the union of the graphs Ei . For each Ai , we have the relation: Y (Ai , pi ) ∪ Y (B2 , qi ) = Y . Since G is nonseparable, for each such relation, there must be an edge ai such that ai ∈ Y (B2 , qi ) but ai 6∈ Y (Ai , pi ) and an edge bi such that bi ∈ Y (Ai , pi ) but bi 6∈ Y (B2 , qi ). For A1 = B1 , we have p1 = v1 , q1 = v2 , and an edge a1 with one end being v2 and the other end being a vertex of E1 other than v1 . For each Ai other than A1 , suppose pi 6= v1 , then since a1 cannot be an element of Y (Ai , pi ), a1 must be an element of Y (B2 , qi ), hence qi must be v2 . But then C(Ai , pi ) has fewer edges than C(B1 , v1 ), which contradicts the definition of B1 , v1 . Hence in each relation Y (Ai , pi ) ∪ Y (B2 , qi ) = Y , pi = v1 . Considering the edge ai we see that qi is uniquely determined for each Ai . Let Zi denote the set of all members of Y having one end a vertex of Ei other than v1 . Then Zi is non-null since it includes ai . By the relation Y (Ai , pi ) ∪ Y (B2 , qi ) = Y , Zi must be a subset of Y (B2 , qi ), which means each member of Zi has its other end a vertex of C(B2 , qi ). For each vertex v of G · B2 , we denote by R(v) the subgraph of G which is the union of C(B2 , v), the graph Ei for which qi = v, and the members of the corresponding Zi . For a given vertex v the graph R(v) may have only one vertex. If not the set E(R(v)) is non-null and its vertices of attachment in G are v and v1 . Since G is nonseparable, there are at least two such vertices of attachment, and v and v1 are the only possibilities. Moreover if x and y are distinct vertices of G · B2 then R(x) and R(y) have at most one common vertex v1 and no common edge. We may therefore independently switch R(x) through the vertices v1 , x for each non-null E(R(x)). In the switch process, each edge that is incident on v1 is changed to be incident on x, and each edge
4
CORRECTNESS PROOF OF THE ALGORITHM
41
that is incident on x is changed to be incident on v1 ; the rest of the graph remains unchanged. Since the bonds of the graph are still the same after the switch process, the bond matroid of the graph remains the same. After each R(x), for which E(R(x)) is non-null, has been switched, G is transformed into another graph G0 that has the same bond matroid as B(G), but for the end-graphs H10 and H20 , E(H10 ) = E(H2 ) − B2 , and E(H20 ) = E(H1 ) + B2 . If |E(H10 )| 6= 0, by a transformation similar to the transformation of G to G0 , or a series of these transformations, we eventually will transform G into a new graph which has the same bond matroid but one end-graph of Y in the new graph is a single vertex, that is, has zero edges. Inside the for loop that starts at line 9 and ends at line 42, the graph G represented by X is nonseparable, since M is a connected matroid. It is clear that the bridges of Y in B(G) are B1 , B2 , . . . , Bj , which are represented by the column groups κ1 , κ2 , . . . , κj in the list Lκ . Since these column groups are in the same list, no two of these bridges overlap. And since X does not include the common row r, the graph G does not have the common vertex. As the theorem states, the graph G must be able to be transformed into a graph G0 whose bond matroid is the same as the bond matroid of G, and one end graph of Y in G0 is a single vertex. The end-graph H2 of Y in G is G·Bj , which is nonseparable. From the above proof, we can see that after one round of transformation, G will be turned into graph G0 in which the endgraph H10 of Y has |E(H2 )|−|Bj | = 0 number of edges, which means that the end-graph H10 of Y in G0 is a single vertex. As reasoned in the proof, in the same round of transformation, each subgraph that is switched is attached to the rest of the graph through a common vertex v1 in H1 and another vertex v in H2 . And each switch occurs independently without interfering with others. After one round of switch, v1 becomes the single vertex in the end-graph H10 of Y in G0 . Hence once v1 is identified, it will be the target for the common row, and the switch will be straightforward: for each edge e ∈ Y that is not incident on v1 , identify its two ends, v2 and v3 . Suppose v2 is in H2 , then obtain the subgraph that contains v3 and is attached to the rest of the graph through v1 and v2 , and make a switch of the subgraph. It
5
RUNNING TIME ANALYSIS OF THE ALGORITHM
42
is quite clear that the Switch Algorithm described in Figure 8 accomplishes the switches in terms of the incidence matrix. After the transformation in the Switch Algorithm, the formed common row r is assured to be the last row in lines 34 through 35 (Figure 8). The process of identifying the target row/vertex rt for the common row/vertex r is described in lines 20 through 39. Since each partition element in the partition Pj is the set of edges incident on a vertex in the graph [G × (Bj ∪ Y )] · Y , the partition element I in line 20 uniquely identifies a row/vertex rc in the last mj − 1 rows, where I ⊆ {b | X[c][b] = 1} and I = Y (Bj , rc ). In lines 21 through 25, the bridges Bk that satisfy the relationship Y (Bk , vk )∪ Y (Bj , rc ) = Y are searched and the rows/vertices of G · Bk are marked. Lines 26 through 39 search for the target row/vertex rt . In lines 26 through 28, a row/vertex ra in H1 whose incident edges include an edge b in Y − I is identified. ra must be a vertex in a subgraph C(Bk , vk ), where Y (Bk , vk ) ∪ Y (Bj , rc ) = Y , since the column/edge cb ∈ Y (Bk , vk ). If row/vertex ra is marked, then it must be target vertex rt , since among all the subgraphs C(Bk , vk ) that satisfy Y (Bk , vk ) ∪ Y (Bj , rc ) = Y , the one that has vk = ra must have the least number of edges. Otherwise, since any two separates of H1 have at most one vertex in common, breath-first serach is used to find the marked row/vertex rt that has the shortest path to row/vertex ra , and the subgraph C(Bk , rt ) is a subgraph of all those subgraphs C(Bk , vk ) and hence has the least number of edges. And the row/vertex rt will be the target row/vertex.
5
Running Time Analysis of the Algorithm
In this section the running time for the various sub-algorithms is analyzed first, then the running time analysis of the Graphic Test Algorithm is performed, and finally we analyze the running time for the Main Algorithm. Given as input a binary matrix R with m rows and n columns, it is easy to see that the Row Grouping Algorithm takes O(mn) time and the
5
RUNNING TIME ANALYSIS OF THE ALGORITHM
43
transformtion to standard form takes O(m2 n) time.
5.1
The Break Down Algorithm
Given as input a binary matrix R with m rows and n columns, the running time for the Break Down Algorithm is analyzed as follows. Lines 6 through 11 take O(1) time. Lines 12 through 30 are a while loop, the algorithm iterates this loop at most three times. Inside the while loop, lines 13 through 14 take O(1) time, lines 15 through 16 take O(m) time, lines 18 through 21 take O(n) time, lines 22 through 24 take O(mn) time, line 25 takes O(mn) time, and lines 26 through 29 take O(1) time. Hence the whole while loop takes O(mn) time. Lines 31 through 32 take O(1) time. Lines 33 through 42 take O(mn) time. Hence the running time for the Break Down Algorithm is O(mn).
5.2
The Partition Algorithm
The Partition Algorithm is called in the Graphic Test Algorithm (GTA) one time. Given that the input to GTA is a binary matrix R with m rows and n columns, the running time of the Partition Algorithm is analyzed as follows. Lines 6 through 28 are a for loop. The algorithm iterates the for loop s times, where s is the number of matrices in the input list LR . Inside the for loop, lines 7 through 11 take O(mi n) time, line 12 takes O(m2i n) time, lines 13 through 17 take O(mi n) time, and lines 19 through 26 take O(mi n) time, where mi is the number of rows in Ri0 . So the whole for loop takes time: s X i=1
O(m2i n)
s s X X 2 = O(( mi )n) = O(( mi )2 n) i=1
i=1
= O((m + s − 1)2 n) = O(m2 n), since s = O(m). Thus the running time for the algorithm is O(m2 n).
5
RUNNING TIME ANALYSIS OF THE ALGORITHM
5.3
44
The Classification Algorithm
The Classification Algorithm is called in the Graphic Test Algorithm (GTA) one time. Given that the input to GTA is a binary matrix R with m rows and n columns, the running time of the Classification Algorithm is analyzed as follows. Lines 7 through 11 take O(1) time. Lines 12 through 46 are a for loop. The algorithm iterates the for loop s times, where s is the number of partitions in the input list LP . Inside the for loop, lines 13 through 21 take O(1) time, and lines 22 through 44 are a while loop. The iteration of the while loop is at most s times. Inside the while loop, lines 23 through 31 take O(n2 ) time, and lines 33 through 43 take O(1) time. Hence the while loop takes O(sn2 ) = O(mn2 ) time. Also, the for loop takes O(smn2 ) = O(m2 n2 ) time. So the running time of the algorithm is O(m2 n2 )
5.4
The Switch Algorithm
The Switch Algorithm (SA) is called in the Incidence Matrix Construction Algorithm (IMCA). Given that the input matrix of SA is an m by n matrix, the running time of SA is analyzed as follows. Line 4 takes O(n) time. Lines 5 through 33 are a while loop. The algorithm iterates this while loop O(n) times. Inside the while loop, lines 6 through 8 take O(m) time, lines 9 through 11 take O(mn) time, lines 13 through 19 take O(mn) time, lines 20 through 31 take O(mn) time, and line 32 takes O(n) time. Hence the while loop takes O(mn2 ) time. Line 34 through 35 take O(n) time. So the running time of SA is O(mn2 ).
5.5
The Incidence Matrix Construction Algorithm
The Incidence Matrix Construction Algorithm (IMCA) is called in the Graphic Test Algorithm (GTA) one time. Given that the input to GTA is a binary matrix R with m rows and n columns, the running time of IMCA is analyzed as follows.
5
RUNNING TIME ANALYSIS OF THE ALGORITHM
45
Lines 8 through 44 are a for loop. The algorithm iterates this for loop two times. Lines 9 through 43 are a for loop immediately inside the other for loop. The algorithm iterates this for loop si time, where i = 1 or 2, and s1 + s2 = s. Inside this for loop, lines 10 through 14 take O(mn) time, lines 16 through 19 take O(mn) time, lines 20 through 25 take O(mn) time, lines 26 through 30 take O(m + n) time, and lines 31 through 39 take O(mn) time. Line 40 takes O(mn2 ) time. So the for loop (Lines 8 through 44) takes O(smn2 ) = O(m2 n2 ) time. Lines 45 through 48 take O(mn) time. Thus the running time of IMCA is O(m2 n2 ).
5.6
The Graphic Test Algorithm
The Graphic Test Algorithm (GTA) is called in the Main Algorithm. Given as input a binary matrix with m rows and n columns, the running time TGT A (m, n) of GTA is analyzed as follows. Lines 4 through 6 take O(mn) time. Lines 9 through 12 take O(mn) time. Line 17 takes O(mn) time. P Lines 22 through 33 take si=1 TGT A (mi , n) time, where s is the number of matrices in LR , and mi is the number rows in matrix Ri , since GTA is called recursively with input Ri , i = 1, 2, . . . , s. As reasoned in Section 5.2, line 36 takes O(m2 n) time. As reasoned in Section 5.3, line 40 takes O(m2 n2 ) time. Lines 44 through 46 also take O(m2 n2 ) time, as reasoned in Section 5.5. Thus the total running time of the algorithm is TGT A (m, n) =
s X
TGT A (mi , n) + O(m2 n2 ),
i=1
We can prove by induction that TGT A (m, n) = O(m2 n2 ).
5.7
The Main Algorithm
Given as input a binary matrix with m rows and n columns, the running time T (m, n) of the Main Algorithm is analyzed as follows.
6
46
THE JAVA PROGRAM
Lines 4 through 6 take O(mn) time. Lines 7 through 9 take O(m2 n) time. Line 10 takes O(mn) time. Lines 13 through 26 are a for loop. The algorithm iterates this for loop s times, where s is the number of entries in Lρ . Inside the for loop, lines 14 through 17 take O(mi n) time, where mi is the number of rows in matrix Ri , line 18 takes TGT A (mi , n) = O(m2i n2 ) time, and lines 19 through 25 take O(mi , n) time. Hence the whole for loop takes s X
[TGT A (mi , n) + O(mi n)] =
i=1
s X
[O(m2i n2 ) + O(mi n)]
i=1
=
s X
O(m2i n2 ) = O(m2 n2 )
i=1
time. Thus the running time for the Main Algorithm is O(m2 n2 ).
6
The Java Program
The main program called InputApplet, is an applet. When the program is run, a main window shows up. This window contains two input lines, which take the input of the number of rows and the number of columns of the input binary matrix, and one text area, which takes the input of the binary matrix. It also contains three buttons: the “Compute” button, the “Show reason” button, and the “Show graph” button. The “Show reason” button and the “Show graph” button are disabled before the first click of the “Compute” button. The user can click the “Compute” button to determine whether the matroid represented by the input binary matrix is graphic. If the program determines that the input is graphic, both the “Show reason” and the “Show graph” buttons will be enabled, and at the bottom of the window, there will be a line of text indicating that the matroid is graphic. Otherwise, the “Show graph” button will be disabled, and at the bottom of the window there will be a line of text indicating that the matroid is not graphic. When the “Show reason” button is pressed, another window which contains the reasoning of the graphicness for the matroid will pop up. When
6
THE JAVA PROGRAM
47
the input matroid is graphic, the “Show graph” button is enabled. Clicking on the “Show graph” button will bring up a third window which contains a graph whose bond matroid is the matroid represented by the input matrix. This window contains a Layout menu. The user can select a layout from three choices: Polygon layout, Ring layout, and Random layout. The user can also change the layout of the graph by simply dragging a vertex to another place using the mouse. If the user presses “Enter” on the keyboard while the cursor is blinking in the second input line, a binary matrix in standard form will appear in the text area. This matrix has the number of rows and number of columns as indicated in the two input lines, and has block of 1s in each column that follows unit matrix part, which was randomly generated. We know that matroids represented by the matrices generated this way are graphic. This is used for testing the correctness of the program. If the applet is run as an application, then the “File” menu could be used to open a file containing a binary matrix. The input file must be in the following format: The first line contains the number of rows and number of columns of the matrix separated by a space. The rest of the file consists of the actual binary matrix. To input a binary matrix from a file, click on the “File” menu, select “Open”, this will bring up a dialog box to browse the directory and select the desired file. After the user opens the file successfully, the number of rows, number of columns, and the binary matrix will appear in the indicated place. The rest of the steps is the same.
6.1
Test of The Program
As stated earlier in in this section, the main program contains a “File” menu. If the program is run as an application, one can open a file that contains a binary matrix, and test if that matroid is graphic. We have stored many files that contain known graphic and non-graphic binary matroids in the directory sampleInputs. The program works correctly for all the files in that directory. In addition, one can press “Enter” on the keyboard after entering the number
6
THE JAVA PROGRAM
48
of rows and number of columns, while the cursor is blinking in the second input line. A binary matrix in standard form with the indicated number of rows and number of columns will be generated and appears in the text area. It has block of 1s in each column that follows the unit matrix part, which was randomly generated, which gurantees that the matroid is graphic. Clicking on the “Compute” button will tell whether the matroid generated is indeed graphic. We have tested this more than 50 times, with different number of rows and number of columns. The program works correctly in every test we have run so far. Below are some sample runs of the program. 6.1.1
Example 1 100111000 110010100 011010010 001110001
Given as input the above matrix, the program determines that the matroid represented by the input matrix is not graphic. The step-by-step reasoning, which is contained in the window that shows up when the “Show reason” button is pressed, is shown below: Determine 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1
whether the matroid M represented by the following matrix is graphic: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Group the rows into row groups. For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {1, 2, 3, 4, 5, 6, 7, 8, 9} The row groups are: {1, 2, 3, 4} For each elementary separator Si , adjoin the rows in the corresponding row group together. The formed matrix is a standard representative matrix of the matroid M × Si , which is a connected component of M . These components of M are: 1 0 0 1 1 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 0 0 0 1 1 1 0 0 0 1 Determine whether these components are graphic. The matroid M is graphic if and only if all these components are graphic.
6
THE JAVA PROGRAM
Determine 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1
whether the component 1 is graphic: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
The matrix has at least one column with at least three 1s in it. Select the first column that has at least three 1s. Select the first row that has a 1 in the selected column. selected column = 5, selected row = 1. Y (the set of columns with a 1 in this row) = {1, 4, 5, 6} Replace row 1 and all the columns with a 1 in this row with 0s, the resulted matrix R0 is: 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 Get the bridges of Y, which are the elementary separators of the matroid represented by matrix R0 Group the rows into row groups. For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {2, 3, 7, 8, 9} The row groups are: {2, 3, 4} Since Y Y (the Replace the 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 1
has only one bridge, repeat the procedure for row 2. set of columns with a 1 in this row) = {1, 2, 5, 7} row 2 and all the columns with a 1 in this row with 0s, resulted matrix R0 is: 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
Get the bridges of Y , which are the elementary separators of the matroid represented by matrix R0 Group the rows into row groups. For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {3, 4, 6, 8, 9} The groups of rows are: {1, 3, 4} Since Y has only one bridge, repeat the procedure for row 3. Y (the set of columns with a 1 in this row) = {2, 3, 5, 8} Replace row 3 and all the columns with a 1 in this row with 0s, the resulted matrix R0 is: 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 Get the bridges of Y , which are the elementary separators of the matroid represented by matrix R0 Group the rows into row groups.
49
6
THE JAVA PROGRAM
50
For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {1, 4, 6, 7, 9} The row groups are: {1, 2, 4} Since there is only one bridge for all 3 choices of Y , We conclude that this matroid is not graphic. The component 1 of the matroid M is not graphic. Since every minor of a graphic matroid is graphic, the matroid M is not graphic.
6.1.2
Example 2 10001110 01001100 00101011 00010111
Given as input the above matrix, the program determines that the matroid represented by the input matrix is not graphic. The step-by-step reasoning, which is contained in the window that shows up when the “Show reason” button is pressed, is shown below: Determine 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0
whether the matroid M represented by the following matrix is graphic: 1 1 0 1 0 0 0 1 1 1 1 1
Group the rows into row groups. For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {1, 2, 3, 4, 5, 6, 7, 8} The groups of rows are: {1, 2, 3, 4} For each elementary separator Si , adjoin the rows in the corresponding row group together. The formed matrix is a standard representative matrix of the matroid M × Si , which is a connected component of M . These components of M are: 1 0 0 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 1 Determine whether these components are graphic. The matroid M is graphic if and only if all these components are graphic. Determine 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1
whether the component 1 is graphic: 1 1 0 1 0 0 0 1 1
6
THE JAVA PROGRAM
51
0 0 0 1 0 1 1 1 The matrix has at least one column with at least three 1s in it. Select the first column that has at least three 1s. Select the first row that has a 1 in the selected column. selected column = 5, selected row = 1. Y (the set of columns with a 1 in this row) = {1, 5, 6, 7} Replace row 1 and all the columns with a 1 in this row with 0s, the resulted matrix R0 is: 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 Get the bridges of Y , which are the elementary separators of the matroid represented by matrix R0 Group the rows into row groups. For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {2} {3, 4, 8} The groups of rows are: {2} {3, 4} From the following matrix: 1 0 0 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 1 Adjoin all the rows in the same row group together, and add row 1 as the last row. The formed matrix represents a Y component of the matroid represented by the matrix. The following matrices are formed: 0 1 0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 1 1 0 0 0 1 1 1 0 For each Y component, delete the columns with a 0 in the last row. Reduce the formed matrix to standard form(within a permutation of columns). Check each column. If there is a column with more than one 1 in it, then the corresponding bridge does not partition Y . Then since in a graphic matroid, every bridge partitions Y , the matroid is not graphic. Otherwise, the corresponding bridge determines a partition. And each element of the partition is the set of columns with a 1 in the same row in the matrix. The reduction to Y of Y component 1 is: 0 1 1 0 1 1 1 1 Reduce it to standard form: 0 1 1 0 1 0 0 1 Bridge 1 determines partition {{5, 6} {1, 7}}
6
THE JAVA PROGRAM
The 0 1 0 0 1 1
52
reduction to Y of Y component 2 is: 0 1 1 1 1 1
Reduce it to standard form: 0 1 0 1 0 0 1 1 1 0 0 1 Bridge 2 has more than one 1 in column 4, hence it does not partition Y and the matroid is not graphic. The component 1 of the matroid M is not graphic. Since every minor of a graphic matroid is graphic, the matroid M is not graphic.
6.1.3
Example 3 1000100101 0100111101 0010111011 0001110010
Given as input the above matrix, the program determines that the matroid represented by the input matrix is not graphic. The step-by-step reasoning, which is contained in the window that shows up when the “Show reason” button is pressed, is shown below: Determine whether 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0
the matroid M represented by the following matrix is graphic: 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Group the rows into row groups. For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} The groups of rows are: {1, 2, 3, 4, 5, 6} For each elementary separator Si , adjoin the rows in the corresponding row group together. The formed matrix is a standard representative matrix of the matroid M × Si , which is a connected component of M . These components of M are: 1 1 1 1 1 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 1 Determine whether these components are graphic.
6
53
THE JAVA PROGRAM
The matroid M is graphic if and only if all these components are graphic. Determine whether 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0
the component 1 is graphic: 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
The matrix has at least one column with at least three 1s in it. Select the first column that has at least three 1s. Select the first row that has a 1 in the selected column. selected column = 1, selected row = 1. Y (the set of columns with a 1 in this row) = {1, 2, 3, 4, 5} Replace row 1 and all the columns with a 1 in this row with 0s, the resulted matrix R0 is: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 Get the bridges of Y , which are the elementary separators of the matroid represented by matrix R0 Group the rows into row groups. For two rows a and b in the same row group, there must be a column c such that c has a 1 in both row a and row b. The set of columns with 1s in the rows of the same row group is an elementary separator of the matroid represented by the matrix. The elementary separators of the matroid represented by the matrix are: {6} {7} {8} {9} {10} The groups of rows are: {2} {3} {4} {5} {6} From the following matrix: 1 1 1 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 1
Adjoin all the rows in the same row group together, and add row 1 as the last row. The formed matrix represents a Y component of the matroid represented by the matrix. The following matrices are formed: 0 1 1 1 0 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1
1 1
1 1
0 1
0 1
0 0
1 0
0 0
0 0
0 0
1 1
1 1
0 1
0 1
0 1
0 0
0 0
1 0
0 0
0 0
0 1
0 1
1 1
1 1
0 1
0 0
0 0
0 0
1 0
0 0
1 1
1 1
1 1
0 1
0 1
0 0
0 0
0 0
0 0
1 0
6
THE JAVA PROGRAM
For each Y component, delete the columns with a 0 in the last row. Reduce the formed matrix to standard form(within a permutation of columns). Check each column. If there is a column with more than one 1 in it, then the corresponding bridge does not partition Y . Then since in a graphic matroid, every bridge partitions Y , the matroid is not graphic. Otherwise, the corresponding bridge determines a partition. And each element of the partition is the set of columns with a 1 in the same row in the matrix. The reduction to Y of Y component 1 is: 0 1 1 1 0 1 1 1 1 1 Reduce it to standard form: 0 1 1 1 0 1 0 0 0 1 Bridge 1 determines partition {{2, 3, 4} {1, 5}} The reduction to Y of Y component 2 is: 0 1 1 0 0 1 1 1 1 1 Reduce it to standard form: 0 1 1 0 0 1 0 0 1 1 Bridge 2 determines partition {{2, 3} {1, 4, 5}} The reduction to Y of Y component 3 is: 1 1 0 0 0 1 1 1 1 1 Reduce it to standard form: 1 1 0 0 0 0 0 1 1 1 Bridge 3 determines partition {{1, 2} {3, 4, 5}} The reduction to Y of Y component 4 is: 0 0 1 1 0 1 1 1 1 1 Reduce it to standard form: 0 0 1 1 0 1 1 0 0 1 Bridge 4 determines partition {{3, 4} {1, 2, 5}} The reduction to Y of Y component 5 is: 1 1 1 0 0 1 1 1 1 1 Reduce it to standard form: 1 1 1 0 0 0 0 0 1 1 Bridge 5 determines partition {{1, 2, 3} {4, 5}} For two partitions P1 and P2, determined by bridges B1 and B2, respectively, If the union of one element in P1 and one element in P2 is Y , then B1 and B2 do not overlap. Otherwise, B1 and B2 overlap.
54
6
THE JAVA PROGRAM
55
Try to group the bridges of Y and hence the corresponding Y components into at most two disjoint classes, such that any two bridges in the same class do not overlap. If this arrangement could be made, then Y is an even circuit. Otherwise, Y is not even; and since in a graphic matroid every circuit is even, the matroid is not graphic. Brige/Y component 1 is added into class 1. The union of the partition element 2 in partition 2 with the partition element 1 in partition 1 is Y . Brige/Y component 2 is added into class 1. There is no element in partition 3 whose uion with an element in partition 1 is Y . Hence bridge 3 overlaps with bridge 1, and cannot be added into class 1. Brige/Y component 3 is added into class 2. The union of the partition element 2 in partition 4 with the partition element 1 in partition 1 is Y . There is no element in partition 4 whose uion with an element in partition 2 is Y . Hence bridge 4 overlaps with bridge 2, and cannot be added into class 1. The union of the partition element 2 in partition 4 with the partition element 2 in partition 3 is Y . Brige/Y component 4 is added into class 2. There is no element in partition 5 whose uion with an element in partition 1 is Y . Hence bridge 5 overlaps with bridge 1, and cannot be added into class 1. The union of the partition element 1 in partition 5 with the partition element 2 in partition 3 is Y . There is no element in partition 5 whose uion with an element in partition 4 is Y . Hence bridge 5 overlaps with bridge 4, and cannot be added into class 2. Since bridge 5 cannot be added into either of these two classes, Y is not even and the matroid is not graphic. The component 1 of the matroid M is not graphic. Since every minor of a graphic matroid is graphic, the matroid M is not graphic.
6.1.4
Example 4
Given as input the following binary matrix, which represents the bond matroid of a Petersen graph, the program constructs a Petersen graph shown in Figure 9, which can be changed into the graph shown in Figure 10 by rearranging the vertices of the graph in the program. 100000000110000 010000000111000 001000000111100 000100000111110 000010000011110 000001000011111 000000100010111 000000010010101 000000001000101
6.1.5
Example 5
Given as input the following binary matrix, the program constructs a graph shown in Figure 11. By rearranging the vertices of the graph in the program,
6
THE JAVA PROGRAM
Figure 9: The Petersen graph constructed by the program
56
6
THE JAVA PROGRAM
57
Figure 10: The Petersen graph after rearrangement of the vertices of Figure 9
7
CONCLUSION
58
we can obtain a graph shown in Figure 12, so that it can be easily verified that each set of columns (edges) with a 1 in the same row of the input matrix is a bond of the graph. 1000000000111000 0100000000111100 0010000000100100 0001000000011000 0000100000010010 0000010000001010 0000001000011000 0000000100111001 0000000010011001 0000000001001001
7
Conclusion
In this paper, we provided a formal description of Tutte’s algorithm for recognizing binary graphic matroids, so that the algorithm can be readily implemented. The correctness of the algorithm was shown in Section 4, and the running time was analyzed in Section 5. A Java implementation of the algorithm is provided. Some sample runs of the Java program were included in this paper. The program works correctly in all the tests we’ve run so far. As the Java program provides an explanation for why a given binary matroid represented by a binary matrix is graphic or non-graphic, it can also serve as an educational tool. The Java program only tests whether a binary matroid is graphic. It would be nicer if we had a program to test whether a more general matroid were graphic, not just binary. Seymour published a paper in 1981 entitled “Recognizing Graphic Matroids”, which describes an algorithm for testing whether a matroid represented by means of an independent oracle is graphic, in which Tutte’s algorithm is used as a basis [1]. It would be nice to extend our program to implement this algorithm and have a way of determining whether a general matroid is graphic and if so, present a drawing of the graph that corresponds to the matroid.
7
CONCLUSION
Figure 11: The graph constructed by the program
59
7
CONCLUSION
Figure 12: The graph after rearragement of the vertices of Figure 11
60
REFERENCES
61
References [1] P. D. Seymour, “Recognizing Graphic Matroids,” Combinatorica, Vol. 1, 1981, pp. 75–78. [2] W. T. Tutte, “An Algorithm for Determining Whether a Given Binary Matroid is Graphic,” Proceedings of the American Mathematical Society, Vol. 11, 1960, pp. 905–917. [3] W. T. Tutte, “A Homotopy Theorem for Matroids, I,” Transactions of the American Mathematical Society, Vol. 88(1), 1958, pp. 144–160. [4] W. T. Tutte, “A Homotopy Theorem for Matroids, II,” Transactions of the American Mathematical Society, Vol. 88(1), 1958, pp. 161–174. [5] W. T. Tutte, “Matroids and Graphs,” Transactions of the American Mathematical Society, Vol. 90(3), 1959, pp. 527–552. [6] W. T. Tutte, “Introduction to the Theory of Matroids,” Elervier, 1971. [7] H. Whitney, “On the Abstract Properties of Linear Dependence,” Amer. J. Math., Vol.57, 1935, pp. 509–533. [8] R. J. Wilson, “An Introduction to Matroid Theory,” American Mathematical Monthly, Vol. 80(5), 1973, pp. 500–525.