4
1 JOURNAL OF NORTHERN JIAOTONG UNIVERSITY Ap r. 1999 Vol. 23 No.2 An Efficient Algorithm for Finding an Adjacency Matching of a Graph Li Deming Liu Yanpei (College of Sciences , Northem Jiaotong University , Beijing 100044) Abstract An adjacency matching in a graph is a matching that each edge in the graph is matched with an adjacent edge if the edges are not in the adjacency matching inducing a connected spanning subgraph. In this paper , an efficient algorithm on finding a maxi- mum adjacency matching of a graph is provided. Key words adjacency matching augmenting walk algorithm 1 Introduction Let G ( V , E) be a graph with vertex set V and edge set E , respectively. G [ 5] is the in- duced graph by set S. Let M be a set of paìrs of mathched edges such that each pair of the edges share a common vertex. Let E ( M) be the edges in M . If we delete the matched edges in E(M) , the resulting graph is connected , then M is an adjacency matching of graph G. The problem on the adjacency matching of a graph is to find an adjacency matching M such that it has as many pairs of matched edges as possible. If more than two loopls are with a ver- two of them will form edges of the adjacency mathching. so we need only con- sider that each vertex of (; has at mostone loop. Possibly , the loop is in the adjacency mathcing , or prossible not. We subdivede the loop with one vertex , the loop becomes two adjacent edges , at

Finding Adjacency Matching

  • Upload
    sibi

  • View
    7

  • Download
    0

Embed Size (px)

DESCRIPTION

Useful technique to find adjacency matching

Citation preview

Page 1: Finding Adjacency Matching

1 999 年 4 月第 23 卷第 2 期

北方交通大学学报

JOURNAL OF NORTHERN JIAOTONG UNIVERSITY

Apr. 1999

Vol. 23 No.2

An Efficient Algorithm for Finding an Adjacency Matching of a Graph

Li Deming Liu Yanpei (College of Sciences, Northem Jiaotong University , Beijing 100044)

Abstract An adjacency matching in a graph is a matching that each edge in the graph

is matched with an adjacent edge if the edges are not in the adjacency matching inducing

a connected spanning subgraph. In this paper, an efficient algorithm on finding a maxi­

mum adjacency matching of a graph is provided.

Key words adjacency matching augmenting walk algorithm

求邻接对集的一个有效算法

李德明 刘彦佩(北方交通大学理学院,北京 100044)

摘要 固的-个邻接对集是指由其互不相交的相邻边对构成的边的子集,且去掉这些相邻边对

后,所得之图是连通的.本文提供了求最大邻接对集的-小有效算法,并指出此算法可以求图的最

大亏格-

关键词邻接对集可增广路算法

分类号 。157.5

1 Introduction

Let G ( V , E) be a graph with vertex set V and edge set E , respectively. G [ 5] is the in­

duced graph by set S. Let M be a set of paìrs of mathched edges such that each pair of the

ma飞ched edges share a common vertex. Let E ( M) be the edges in M . If we delete the matched

edges in E(M) , the resulting graph is connected , then M is an adjacency matching of graph G.

The problem on the adjacency matching of a graph is to find an adjacency matching M such that it

has as many pairs of matched edges as possible. If more than two loopls are incid巳nt with a ver­

tex,医ach two of them will form on巳 paìr edges of the adjacency mathching. so we need only con­

sider that each vertex of (; has at mostone loop. Possibly , the loop is in the adjacency mathcing ,

or prossible not. We subdivede the loop with one vertex, the loop becomes two adjacent edges, at

本文收到日期 1998-06-20 李德明 1968 年生博士生 现在首都师范大学数学系任教

Page 2: Finding Adjacency Matching

72 北方交通大学学报 第 23 卷

most one of the two is in the set of matched edges. Hence, it is sufficient to consider graphs

without loops , but the graphs may have multiple edges.

A maximum adjacency matching 岛{ is an adjacency matching that there is no other adjacency

matching in the graph having greater number of matched edges than M . When the card(nality of

旦豆ian adjacency matêhing is L t' ~2'"' I J , where 卢( G) is the cycle rank!. the largest possibly in a graph ,

we say the adjacency matching is perfect.

Let us consider a graph G together with a fixed adjacency matching M . Edges in M are

called ma tched edges. The other edges are free. If j ( U , Z ), (Z , v) I is one pair of ma thched

edges of M , Vertices U and v may be the same one. (u , z) is called the mathch of ( Z , v). Z is

called a saturated vertex. u and v are called exposed vertices. A saturated vertex may be e?CPosed

at the same time. Whether a vertex is saturated or exposed is determined by the matched pãir.

Let P ( U , z) be the path in G - M connecting u and z . If there is a vertex u' in P (u , %) which is on

a cycle C in G - M , we call u' a pc-vertex u a pcm-vertex and u is attached to the cycle C . Start

from u , walk along path P (u , z) to z , we call the first vertex on cycle C a pct-vertex. A pcm-ver­

tex is a particular exposed vertex. The definitions of exposed , saturated and pcm-vertices are de­

termined by the adjacency mathching M. It is likely that a '{ertex. may be saturated and exposed at

the same time. It can be regardedas a folded path in G [ E ( M) J. We label these vertices by Ui

and Zj to the ends of E (M) such that Ui are exposed while Zj are saturated. A walk of graph G is

a sequence of distinct adjacent edges. A walk P = (Ul' el' 町,町 , U2' 句 , Z2' …,句 , e/ , Uk+l) is

called an adjoining walk if the edges are all edges of M. P is called an augmenting walk if both ul

and uk+ 1 are distinct pcm-vertices and attached to distimct cycles in G - M.

2 Theorems on adjacency matching

The significane of a augmenting walk for the adjacency matching problem is the same as that

of an augmenting path for the matching problem

Lemma 1 Let P (Ul' 町, z1 , E1' , uh ez , Z2,…,句 , ek , 的+1) be an augmenting walk in

a graph G with respect to the adjacency mathching M . Then there exists another adjacency

matching M' such that I M' I = I M I + 1.

Proof To prove this lemma, we only need construct such an adjacency matching 岛{' that

its cardinality is greater than that of M by one.

Let walk P (U1' el' ZI' e1" U2' e2' Z2' …,句,句的+1) be an augmenting walk of M. Ul

and U k+ l are distinct pcm-vetices, which are attacthed to distinct cycles C1 and Ck+ l in G - M ,

respectively-Assume that uf is the pet-vertex of cycle C1and path P(U1' 引), two adjacent edges

el and el' incident with U.l,' are on cycle C1 and pathP(u1, %1)' respectively. Uk+l' is the pct-vertex

of cycle Ck+ 1 and P (气 , U k + 1 ) 正 tVfo adjacent edges ek+ 1 and e是 +1' incident with U k+l' are on Ck+ l and

P(Zk' Uk+

1) , respectively. Let M 1 11 (叫 , ZI) , (ZI , u2)1 , I( 句 , Z2 ), (Z2' 的) 1 ,…, 1 (肉, Zk) ,

(zk , uk+1) 11 , M 2 = II(Zlo Ui) , (U2 , Z2 )1, !(Z2 , U3) , (U3 , Z3)1 , …, j (Zk-l , Uk) , (Uk' Zk) 11 ,

and let M' = (M - M 1) U 1 e 1 , e l' 1 U 1 e川,如l' I U M 2' Edges ( u l' Z 1) and (句 , uk + 1)

Page 3: Finding Adjacency Matching

第 2 期 李德明等:求邻接对集的一个有效算法 73

become free edges' in G - M' . It is easy to see that G - M' is a connected spanning subgraph of

G and I M' I = I M I + 1 holds.

There are no augmenting walks with respect to a maximum adjacenty matching , since such a

walk could be used to augment the adjacency matching. Theorem 1 states that the converse is true

as well.

Theorem 1 An adjacency matching M is a: graph G is maximum if and only if there is no

augmenting walk in G with respect to M .

Pn∞1 One direction follows from Lemma 1. For the other.direction, suppose that there is

no augmenting walk in G with respect to M , and yet :l\在 is not maximum.τhat .is, there is an

adjacency matching M' of G such that I M' I > 1M I . consider the edges in E( M丁 EB E(M).

These edges form a subgraph of G . -Let ( e , e') be an element of M' EB M. If neither of them is

the edge Qf 岛,[, there. is a spanning tree such that e an.d e' are cotree edges since G - E ( M) is con­

nected , we can find two distinct cyc\es on which e and e' lie. Then (e , e') is an augmenting walk

with respect to M. Then each pair of M' in M' EB M has one edge in M' , the other in M . Since

I M' I > I M 1, there must be the form of adjoining walks (町,句,句,… , ek' e') , where el and

e' are edges ofM' but are not edges of M in M' EB M. We can find spanning tree of G such that

e and e' are cotree edges and lie on distinct cyc\es in G - E ( M) . And hence this is an augmenting

walk. However , this contradicts the assumption that there are no augmenting walk in G with re­

spect to M and the theorem is proved

Theorem 2 is a characterization of maximum adjacency matchings. We can devise an algo­

rit~m for a maximum adjacency matching of G Start with any adjacency matching , and repeélt­

edly discover augmenting walks. This idea is the same as findinga maximum mathching.

The following theorem is one property of a maximum adjacency matching of G

Theorem 2 Let M be a maximum adjacency matching of G . Let G - M be the spanning

connected subgraph of G after deleted the edges of M from G. Then there is no common vertex a­

mong distinct cyc\es in G 一具f

Proòf suppose not then there are distinct cyc\es C 1 and C2 having a common vertex z in G

- M. C 1 EBC2 is either a union of cyc\es or a cyc\e. Let el and e2 be the two edges incident with

x and on distinct cyc\es C 1 and C2 . Then ( el' e2) is an augmenting walk of G with respect to

M. A contradiction.

Note It is a necessary condition for the maximality of M that there is no common vertex a­

mong distinct cyc\es in G - M . It is not sufficient.

3 The algorithm

The algorthm for a maximum adjacency matching of a graph is the same as the idea of finding

the maximum matching. Shrinking a blossom technique is used in coping with non-bipartite

matching problem , but here , we need not use it. This is the difference between the twoprob­

lems. Hence , the complexity of the algorithm is nearly the same as that of bipartite matching al­

gorithm.

Page 4: Finding Adjacency Matching

74 北方交通大学学报 第 23 卷

To [acilitate the algorithm and inìtìalize the adjacency matchìng M , we can fìnd a spanning

tree of the graph G , and match the cotree edges in a depth-fìrst vvay such -that there will be no

unmatched edges if the graph is even size or only one unmatched edge ìf ìt is odd size , since G -

M is a connected spanning subgraph of G. Let G be a connected loopless graph wìth n vertices e

edges. The followìng steps consìst of th巳 algorìthm for a maxìmum adjacency matchìng ìn G .

(1) Construct one adja_cency matchìng as the ìnitìal adjacency matching òf G.

( Fìnd a spannìng tree T in G

( Label the vertices of the' cotree edges using Ui and Zj such that u; are exposed ver.tices .and

Zj are saturated vertices. .A vertex in G may have more than one label.

(2) Let M denote the current adjacency matching of G. Search for augmentìng walk with re­

spect to M.

( Let u be an exposed vertex of an adjoìning walkP . Determine whether u ìs a pçm-vettex'.

( Take two dìstinct pcm-vertices u and u' of the adjoining walk P. Decìde whether they are

attached to distinct cycles in G - M . lf yes , then an augm巳nting walk is found , goto step(3). If no , change one or two of u and u' by other pcm-vertìces , and repeat this step. If there are no two

distìnct pcm-vertices attacbing to two distinct cycles ìn any adjoining walk P with respect to , the

current adjacency matching M , stop the algorithm.

(3) Augmenting the .adjacency matching M.

Let P = (u] , 町, zhEl ,, u2 ,句 , zz , 勺, eIF , u晶 +1) be an augmenting walk where UI and

Uk+1 are the two distinct pcm-vetìces attaching to two distinct cycles C 1 and C晶 +1 is G - M . As­

sume that u/ is the pct-vertex of cycle C1 and path P( 飞,引) , two adjacent edges el and e/ inci­

dent with u l' ae on cycle C 1 and path P (飞, zl) , respectively.zth+1'ls thepct·vertex of CA+land

P( 勺 , U, 叫), two adjacent edges ek+ 1 and ek+ 1' .incident with Uk+ 1' are on Ck+ 1 and P (勺 'UH1 )' respec-

tively. LetM1 = II(U1 , Zl)'( 町 , uz) l. l( 的, zz ), (句, U3) 1, ..., I (肉, Zk) , (Zk' 的+1) 11 , and

M z = Il(z1' uz) , (肉 , zz)! , l(zz , 的), (町, Z3)! , …, I ( Zk -1' Uk)' (肉, Zk) I 1 . Let M' ==

(M - M 1) U le1' 町 '1 U I ek+ l' ek+ 1' 1 U M z . L巳t M' be the curent adjacency matching. Goto

step (2).

The following theorem proves the algorithm is efficient

Theorem 3 The algorithm solves the adjacency matching problem in 0 (卢( G) . I E I ) time

Proof The algorithm stops if there is no augmenting walk in G with respect to the maxi-

mum adjacency matching. An adjacency matching M can have no more that ß( G) edges. Since

each augmentation increases the cardinality of the adjacency matching at least by one , we have at

β( G) mo叫tγ J stages. It 盯ufficient to show t阳hat剖叫t t巾he c∞O创叫r

ter口rn口m丑11m让ing whe创ther an exposed vert巳x is a pcm-vertex needs 0 (们I E Iο) tim丑1巳. Checking whether

two distinct pcm-vertices are attached to two distinct cycles takes 0 ( I E 1) time , Each augment­

ing stage need spend 0 (1 E 1) time. Then the theorem foIiows.

{下转 78 页)