Frontiers in Algorithmics: Third International Workshop, FAW 2009, Hefei, China, June 20-23, 2009. Proceedings [1 ed.] 9783642022692, 3642022693

This book constitutes the refereed proceedings of the Third International Frontiers of Algorithmics Workshop, FAW 2009,

373 113 6MB

English Pages 372 [382] Year 2009

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Front Matter....Pages -
CFI Construction and Balanced Graphs....Pages 97-107
Minimizing the Weighted Directed Hausdorff Distance between Colored Point Sets under Translations and Rigid Motions....Pages 108-119
Space–Query-Time Tradeoff for Computing the Visibility Polygon....Pages 120-131
Square and Rectangle Covering with Outliers....Pages 132-140
Processing an Offline Insertion-Query Sequence with Applications....Pages 141-152
Bounds on the Geometric Mean of Arc Lengths for Bounded-Degree Planar Graphs....Pages 153-162
On Minimizing One Dimension of Some Two-Dimensional Geometric Representations of Plane Graphs....Pages 163-172
On Modulo Linked Graphs....Pages 173-180
Pathwidth is NP-Hard for Weighted Trees....Pages 181-195
Study on Parallel Computing....Pages 1-1
Communication Complexity and Its Applications....Pages 2-2
Algorithmic Problems in Computer and Network Power Management....Pages 3-3
Shortest Path and Maximum Flow Problems in Networks with Additive Losses and Gains....Pages 4-15
Edge Search Number of Cographs in Linear Time....Pages 16-26
Formal Derivation of a High-Trustworthy Generic Algorithmic Program for Solving a Class of Path Problems....Pages 27-39
Improved Algorithms for Detecting Negative Cost Cycles in Undirected Graphs....Pages 40-50
Covering-Based Routing Algorithms for Cyclic Content-Based P/S System....Pages 51-62
On the α -Sensitivity of Nash Equilibria in PageRank-Based Network Reputation Games....Pages 63-73
Cop-Robber Guarding Game with Cycle Robber Region....Pages 74-84
Covered Interest Arbitrage in Exchange Rate Forecasting Markets....Pages 85-96
A Max-Margin Learning Algorithm with Additional Features....Pages 196-206
DDoS Attack Detection Algorithm Using IP Address Features....Pages 207-215
Learning with Sequential Minimal Transductive Support Vector Machine....Pages 216-227
Junction Tree Factored Particle Inference Algorithm for Multi-Agent Dynamic Influence Diagrams....Pages 228-236
An Efficient Fixed-Parameter Enumeration Algorithm for Weighted Edge Dominating Set....Pages 237-250
Heuristics for Mobile Object Tracking Problem in Wireless Sensor Networks....Pages 251-260
Efficient Algorithms for the Closest String and Distinguishing String Selection Problems....Pages 261-270
The BDD-Based Dynamic A* Algorithm for Real-Time Replanning....Pages 271-282
Approximating Scheduling Machines with Capacity Constraints....Pages 283-292
Approximating the Spanning k -Tree Forest Problem....Pages 293-301
Toward an Automatic Approach to Greedy Algorithms....Pages 302-313
A Novel Approximate Algorithm for Admission Control....Pages 314-325
On the Structure of Consistent Partitions of Substring Set of a Word....Pages 326-335
A Bit-Parallel Exact String Matching Algorithm for Small Alphabet....Pages 336-345
An Improved Database Classification Algorithm for Multi-database Mining....Pages 346-357
Six-Card Secure AND and Four-Card Secure XOR....Pages 358-369
Back Matter....Pages -
Recommend Papers

Frontiers in Algorithmics: Third International Workshop, FAW 2009, Hefei, China, June 20-23, 2009. Proceedings [1 ed.]
 9783642022692, 3642022693

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Lecture Notes in Computer Science Commenced Publication in 1973 Founding and Former Series Editors: Gerhard Goos, Juris Hartmanis, and Jan van Leeuwen

Editorial Board David Hutchison Lancaster University, UK Takeo Kanade Carnegie Mellon University, Pittsburgh, PA, USA Josef Kittler University of Surrey, Guildford, UK Jon M. Kleinberg Cornell University, Ithaca, NY, USA Alfred Kobsa University of California, Irvine, CA, USA Friedemann Mattern ETH Zurich, Switzerland John C. Mitchell Stanford University, CA, USA Moni Naor Weizmann Institute of Science, Rehovot, Israel Oscar Nierstrasz University of Bern, Switzerland C. Pandu Rangan Indian Institute of Technology, Madras, India Bernhard Steffen University of Dortmund, Germany Madhu Sudan Massachusetts Institute of Technology, MA, USA Demetri Terzopoulos University of California, Los Angeles, CA, USA Doug Tygar University of California, Berkeley, CA, USA Gerhard Weikum Max-Planck Institute of Computer Science, Saarbruecken, Germany

5598

Xiaotie Deng John E. Hopcroft Jinyun Xue (Eds.)

Frontiers in Algorithmics Third International Workshop, FAW 2009 Hefei, China, June 20-23, 2009 Proceedings

13

Volume Editors Xiaotie Deng City University of Hong Kong, Department of Computer Science No. 83 Tat Chee Avenue, Kowloon Tong, Hong Kong, China E-mail: [email protected] John E. Hopcroft Cornell University, Computer Science Department 5144 Upson Hall, Ithaca, NY 14853, USA E-mail: [email protected] Jinyun Xue Jiangxi Normal University Provincial Key Laboratory of High-Performance Computing Nanchang, 330027, China E-mail: [email protected]

Library of Congress Control Number: Applied for CR Subject Classification (1998): C.2, G.2.1, C.2.2, F.2, G.2.2, I.1.2 LNCS Sublibrary: SL 1 – Theoretical Computer Science and General Issues ISSN ISBN-10 ISBN-13

0302-9743 3-642-02269-3 Springer Berlin Heidelberg New York 978-3-642-02269-2 Springer Berlin Heidelberg New York

This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, re-use of illustrations, recitation, broadcasting, reproduction on microfilms or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. springer.com © Springer-Verlag Berlin Heidelberg 2009 Printed in Germany Typesetting: Camera-ready by author, data conversion by Scientific Publishing Services, Chennai, India Printed on acid-free paper SPIN: 12693412 06/3180 543210

Preface

The Third International Frontiers of Algorithmics Workshop (FAW 2009), held during June 20–23, 2009 at Hefei University of Technology, Hefei, Anhui, China, continued to provide a focused forum on current trends in research on algorithmics, including discrete structures, and their applications. We aim at stimulating the various fields for which algorithmics can become a crucial enabler, and to strengthen the ties between the Eastern and Western algorithmics research communities as well as theory and practice of algorithmics. We had three distinguished invited speakers: Guoliang Chen, Andrew ChiChih Yao and Frances Foong Yao, speaking on parallel computing, communication complexity and applications, and computer and network power management. The final program also included 33 peer-reviewed papers selected out of 87 contributed submissions, covering topics including approximation and online algorithms; computational geometry; graph theory and graph algorithms; games and applications; heuristics; large-scale data mining; machine learning; pattern recognition algorithms; and parameterized algorithms. April 2009

Xiaotie Deng John Hopcroft Jinyun Xue

Organization

FAW 2009 was organized by Hefei University of Technology, China.

Program Committee General Chairs Franco P. Preparata Lian Li

Brown University, USA Hefei University of Technology, China

Organizing Committee Chairs Hao Li Xiaoping Liu

Laboratoire de Recherche en Informatique, France Hefei University of Technology, China

Steering Committee Chairs Denny Chen Jianping Yin

University of Notre Dame, USA National University of Defense Technology, China

Program Committee Chair John Hopcroft

Cornell University, USA

Program Committee Co-chairs Xiaotie Deng Jinyun Xue

City University of Hong Kong Jiangxi Normal University, China

Plenary Speakers Guoliang Chen Andrew Chi-Chih Yao Frances Foong Yao Committee Members Hee-Kap Ahn Helmut Alt

University of Science and Technology of China Tsinghua University, China City University of Hong Kong

Pohang University of Science and Technology, South Korea Freie University Berlin, Germany

VIII

Organization

Tetsuo Asano Cristina Bazgan Stephan Brandt Hajo Broersma Kyung-Yong Chwa Mao-cheng Cai Jianer Chen Ning Chen Wei Chen Xi Chen Bhaskar DasGupta Zhenhua Duan Genghua Fan Michael Fellows Haodi Feng Rudolf Fleischer Yunjun Gao Gregory Gutin Pinar Heggernes Seokhee Hong Xiaodong Hu Kazuo Iwama Mihyun Kang Irwin King Michael A. Langston Lap Chi Lau D.T. Lee Zongpeng Li Zhiyong Liu Shuang Luan Andy McLennan Hiroshi Nagamochi Thomas Ottmann Yuval Rabani Rajeev Raman Stefan Ruzika

Japan Advanced Institute of Science and Technology, Japan Universite Paris Dauphine, France Technische University Ilmenau, Germany University of Durham, UK Korea Advanced Institute of Science and Technology, South Korea Academy of Mathematics and Systems Science, Chinese Academy of Sciences, China Texas A&M University, USA Nanyang Technological University, Singapore Microsoft Research Asia, China Princeton University, USA University of Illinois at Chicago, USA Xidian University, China Fuzhou University , China University of Newcastle, UK Shandong University, China Fudan University, China Singapore Management University, Singapore University of London, UK University of Bergen, Norway University of Sydney, Australia Academy of Mathematics and Systems Science, Chinese Academy of Sciences, China Kyoto University, Japan Humboldt University of Berlin, Germany The Chinese University of Hong Kong University of Tennessee, USA The Chinese University of Hong Kong Institute of Information Science Academia Sinica, Taiwan University of Calgary, Canada Institute of Computing Technology, Chinese Academy of Sciences, China University of New Mexico, USA University of Queensland, Australia Kyoto University, Japan Albert Ludwigs University Freiburg, Germany Technion - Israel Institute of Technology, Israel University of Leicester, UK University of Kaiserslautern, Germany

Organization

Detlef Seese Takashi Ui Kasturi Varadarajan Guoqing Wu Meihua Xiao Bin Xu Boting Yang Shi Ying Roger Yu Xingxing Yu Dong Zhang Guochuan Zhang Li Zhang Hong Zhu

University of Karlsruhe, Germany Yokohama National University, Japan The University of Iowa, USA Wuhan University, China Nanchang University, China Tsinghua University, China University of Regina, Canada Wuhan University, China Thompson Rivers University, Canada Georgia Institute of Technology, USA Google, China Zhejiang University, China Microsoft, USA Fudan University, China

External Reviewers Sang Won Bae Hui Chen Chin-Wan Chung Tobias Dietrich Michael Dom John Eblen Berndt Farwer Petr Golovach Frank Hoffmann Chunfeng Hu Jianqiang Hu Falk Hueffner Ioannis Ivrissimtzis Jeremy Jay Gary Rogers Jr. M. J. Kao

Klaus Kriegel Thierry Lecroq Cheng-Chung Li Kuan Li Yong Li Qiang Liu Yun Liu Daniel Meister Pablo Moscato Boris Motik Sudhir Naswa Charles Phillips Iris Reinbacher Saket Saurabh Feng Shi Jie Tang

Helen Tu Bo Wang Lusheng Wang Yajun Wang Yongan Wu Hong Qing Yu Hung-I Yu Ran Yu Guomin Zhang Junping Zhang Min Zhang Xiao Zhang Qian Zhong

IX

Table of Contents

FAW 2009 Invited Talks Study on Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Guoliang Chen

1

Communication Complexity and Its Applications . . . . . . . . . . . . . . . . . . . . Andrew Chi-Chih Yao

2

Algorithmic Problems in Computer and Network Power Management . . . Frances F. Yao

3

Graph Algorithms Shortest Path and Maximum Flow Problems in Networks with Additive Losses and Gains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Franz J. Brandenburg and Mao-cheng Cai Edge Search Number of Cographs in Linear Time . . . . . . . . . . . . . . . . . . . . Pinar Heggernes and Rodica Mihai

4 16

Formal Derivation of a High-Trustworthy Generic Algorithmic Program for Solving a Class of Path Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Changjing Wang and Jinyun Xue

27

Improved Algorithms for Detecting Negative Cost Cycles in Undirected Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Xiaofeng Gu, Kamesh Madduri, K. Subramani, and Hong-Jian Lai

40

Covering-Based Routing Algorithms for Cyclic Content-Based P/S System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chen Mingwen, Hu Songlin, and Liu Zhiyong

51

Game Theory with Applications On the α-Sensitivity of Nash Equilibria in PageRank-Based Network Reputation Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wei Chen, Shang-Hua Teng, Yajun Wang, and Yuan Zhou Cop-Robber Guarding Game with Cycle Robber Region . . . . . . . . . . . . . . Hiroshi Nagamochi

63 74

XII

Table of Contents

Covered Interest Arbitrage in Exchange Rate Forecasting Markets . . . . . . Feng Wang, Yuanxiang Li, and Cheng Yang

85

Graph Theory, Computational Geometry I CFI Construction and Balanced Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . Xiang Zhou Minimizing the Weighted Directed Hausdorff Distance between Colored Point Sets under Translations and Rigid Motions . . . . . . . . . . . . . . . . . . . . Christian Knauer, Klaus Kriegel, and Fabian Stehn

97

108

Space–Query-Time Tradeoff for Computing the Visibility Polygon . . . . . . Mostafa Nouri and Mohammad Ghodsi

120

Square and Rectangle Covering with Outliers . . . . . . . . . . . . . . . . . . . . . . . Hee-Kap Ahn, Sang Won Bae, Sang-Sub Kim, Matias Korman, Iris Reinbacher, and Wanbin Son

132

Graph Theory, Computational Geometry II Processing an Offline Insertion-Query Sequence with Applications . . . . . Danny Z. Chen and Haitao Wang

141

Bounds on the Geometric Mean of Arc Lengths for Bounded-Degree Planar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mohammad Khairul Hasan, Sung-Eui Yoon, and Kyung-Yong Chwa

153

On Minimizing One Dimension of Some Two-Dimensional Geometric Representations of Plane Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Huaming Zhang

163

On Modulo Linked Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Yuan Chen, Yao Mao, and Qunjiao Zhang

173

Pathwidth is NP-Hard for Weighted Trees . . . . . . . . . . . . . . . . . . . . . . . . . Rodica Mihai and Ioan Todinca

181

Machine Learning A Max-Margin Learning Algorithm with Additional Features . . . . . . . . . . Xinwang Liu, Jianping Yin, En Zhu, Yubin Zhan, Miaomiao Li, and Changwang Zhang

196

DDoS Attack Detection Algorithm Using IP Address Features . . . . . . . . . Jieren Cheng, Jianping Yin, Yun Liu, Zhiping Cai, and Min Li

207

Table of Contents

XIII

Learning with Sequential Minimal Transductive Support Vector Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Xinjun Peng and Yifei Wang

216

Junction Tree Factored Particle Inference Algorithm for Multi-Agent Dynamic Influence Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Hongliang Yao, Jian Chang, Caizi Jiang, and Hao Wang

228

Parameterized Algorithms, Heuristics and Analysis An Efficient Fixed-Parameter Enumeration Algorithm for Weighted Edge Dominating Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jianxin Wang, Beiwei Chen, Qilong Feng, and Jianer Chen

237

Heuristics for Mobile Object Tracking Problem in Wireless Sensor Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Li Liu, Hao Li, Junling Wang, Lian Li, and Caihong Li

251

Efficient Algorithms for the Closest String and Distinguishing String Selection Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lusheng Wang and Binhai Zhu

261

The BDD-Based Dynamic A* Algorithm for Real-Time Replanning . . . . Yanyan Xu, Weiya Yue, and Kaile Su

271

Approximation Algorithms Approximating Scheduling Machines with Capacity Constraints . . . . . . . . Chi Zhang, Gang Wang, Xiaoguang Liu, and Jing Liu

283

Approximating the Spanning k-Tree Forest Problem . . . . . . . . . . . . . . . . . . Chung-Shou Liao and Louxin Zhang

293

Toward an Automatic Approach to Greedy Algorithms . . . . . . . . . . . . . . . Yujun Zheng, Jinyun Xue, and Zhengkang Zuo

302

A Novel Approximate Algorithm for Admission Control . . . . . . . . . . . . . . . Jinghui Zhang, Junzhou Luo, and Zhiang Wu

314

Pattern Recognition Algorithms, Large Scale Data Mining On the Structure of Consistent Partitions of Substring Set of a Word . . . Meng Zhang, Yi Zhang, Liang Hu, and Peichen Xin

326

A Bit-Parallel Exact String Matching Algorithm for Small Alphabet . . . . Guomin Zhang, En Zhu, Ling Mao, and Ming Yin

336

XIV

Table of Contents

An Improved Database Classification Algorithm for Multi-database Mining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Hong Li, XueGang Hu, and YanMing Zhang

346

Six-Card Secure AND and Four-Card Secure XOR . . . . . . . . . . . . . . . . . . . Takaaki Mizuki and Hideaki Sone

358

Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

371

Study on Parallel Computing Guoliang Chen University of Science and Technology of China

Abstract. In this talk, we present a general survey on parallel computing. The main contents include parallel computer system which is the hardware platform of parallel computing, parallel algorithm which is the theoretical base of parallel computing, parallel programming which is the software support of parallel programming, parallel application which is the development impetus of parallel computing. Specially, we also introduce some enabling technologies of parallel application. We argue that the parallel computing research should form an integrated methodology of “architecture-algorithm-programming-application”. Only in this way, parallel computing research becomes continuous development and more realistic.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, p. 1, 2009. © Springer-Verlag Berlin Heidelberg 2009

Communication Complexity and Its Applications* Andrew Chi-Chih Yao Tsinghua University, Beijing

Abstract. For any function f(x, y), its communication complexity is the minimum number of bits needed to be exchanged between two parties holding integers x and y respectively. Invented thirty years ago, communication complexity has been a central research area in theoretical computer science with rich applications to algorithmic problems. In this talk, we give an overview of computational complexity, high-lighting several notable recent results and the diverse mathematical techniques needed for deriving such results.

*

This work was supported in part by the National Basic Research Program of China (973 Project) Grant 2007CB807900, 2007CB807901, and the National Natural Science Foundation of China Grant 60553001.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, p. 2, 2009. © Springer-Verlag Berlin Heidelberg 2009

Algorithmic Problems in Computer and Network Power Management* Frances F. Yao City University of Hong Kong

Abstract. Power management has become an important issue in the design of information systems. Computer industry struggles to cope with the energy and cooling costs for servers. The wireless ad hoc network community has to invent clever schemes to conserve the limited power available to individual small radio devices. The algorithmic challenges in studying these problems involve both proper mathematical modeling and finding solutions to the resulted optimization problems. In this talk, we will look at some sample problems of power management in computers and wireless networks, discussing their mathematical modeling and efficient algorithms. It will be seen that graph theory and computational geometry can often play a role in providing effective solutions.

*

The work reported here is supported in part by grants from the Research Grants Council of the Hong Kong SAR, China, under Project No. 122105, 122807, and the National Basic Research Program of China Grant 2007CB807900, 2007CB807901.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, p. 3, 2009. © Springer-Verlag Berlin Heidelberg 2009

Shortest Path and Maximum Flow Problems in Networks with Additive Losses and Gains⋆ Franz J. Brandenburg1 and Mao-cheng Cai2,⋆⋆ 1

University of Passau, 94030 Passau, Germany [email protected] 2 Academy of Mathematics and Systems Science, Chinese Academy of Sciences, Beijing 100080, China [email protected]

Abstract. We introduce networks with additive losses and gains on the arcs. If a positive flow of x units enter an arc a, then x + g(a) units exit. Arcs may increase or consume flow, i.e., they are gainy or lossy. Such networks have various applications, e.g., in financial analysis, transportation, and data communication. Problems in such networks are generally intractable. In particular, the shortest path problem is NP-hard. However, there is a pseudo-polynomial time algorithm for the problem with nonnegative costs and gains. The maximum flow problem is strongly NP-hard, even in unit-gain networks and in networks with integral capacities and loss at most three, and is hard to approximate. However, it is solvable in polynomial time in unit-loss networks using the Edmonds-Karp algorithm. Our NP-hardness results contrast efficient polynomial time solutions of path and flow problems in standard and in so-called generalized networks with multiplicative losses and gains. Keywords: extended networks; lossy and gainy arcs; max-flow; shortest path; NP-hard; unit-loss networks.

1

Introduction

How much does it cost transporting commodities in a network with losses and gains on the arcs? What is an optimal investment policy when charges and fees, interest and changes of stock quotations are taken into account? How much data can be sent through a communication network if the amount of data is changed by the used links and routers, e.g., by appending routing information? In such networks all nodes except the source and the sink are flow conserving, whereas the arcs are not. A gain function on the arcs augments or decreases the flow. If ⋆

⋆⋆

This research was done in part while the authors were visiting the City University of Hong Kong. Research partially supported by the National Natural Science Foundation of China (Grant No. 10671108).

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 4–15, 2009. c Springer-Verlag Berlin Heidelberg 2009 

Shortest Path and Maximum Flow Problems in Networks

5

x > 0 units enter an arc a, then x + g(a) units exit where g(a) is the gain of the arc a in a so-called additive network. In the general setting there is a gain function ga for each arc a such that ga (x) units exit if x units enter a. The amount of flow must be nonnegative at either end, and ga (0) = 0 expresses “no flow, no gain”. An arc a is gainy and increases the flow if ga (x) − x > 0, and is lossy if ga (x) − x < 0, where some flow is consumed. Each arc has a capacity and a cost per unit which are taken at the entrance. Networks with losses and gains have many applications reaching from historical events in trading to nowadays problems in financial analysis and data communication. Losses and gains express the variation of the commodity by the evaporation of gas and liquids, by interest and quotations on stock, or by breeding. With multiplicative losses and gains, i.e., with linear gain functions the amount of flow on an arc is changed by a certain percentage. The loss or gain is proportional to the size of the transported commodity. Such networks are known as generalized networks. They have been studied intensively in the literature from the early days of production planning and combinatorial optimization [7,9,15,17] to recent research [1,3,8,11,23,25]. Here many network flow problems have a canonical linear programming (LP) formulation, which implies that there is a polynomial time solution by general-purpose LP-methods [18,19]. Recently, efficient combinatorial algorithms have been developed, see [23] for the shortest path problem, [11,12,13] for the maximum flow problem, and [25] for the min-cost flow problem. Oldham [23] provides a summary for the solution of various path and flow problems in generalized networks. Accordingly, there are many applications with non-linear and, in particular, with additive gain functions. In communication networks the data is expanded by appending a fixed amount of routing information, which means an additive gain, as described in the debugging mode of routers [5]. In the transport of goods or liquids a fixed amount of a commodity may go lost due to consumption, leakage, theft, or toll. For example, at irrigation systems or rivers that run dry seasonally an initial amount of water seeps away before the waterways are saturated by fresh water. The historic “Raffelstetter Zollordnung” (Raffelstett customs regulations) from 903/05 stated that “three bushels of salt per ship” had to be delivered at the toll gates in Passau, Linz or Mautern when crossing the Danube river, and “one bushel of salt per wagon” on the alternative overland routes [14]. Similar regulations were reported for the caravanes from China to Europe transporting tea on the Silk Road and paying toll in terms of tea (http://www.tee-import.de/china/chronolog.htm). The withhold toll was a fixed or a linear amount of the transported commodities, and this loss accumulated with the number of tollgates on the route. The major application of gain functions comes from financial transactions in business. Here linear, additive, and even more complex functions are used to describe the transaction costs of financial transactions, money exchange and stock dealing. Such costs are investigated in financial analysis [22]. There are fees, such as a service charge for currency exchange, a commission for trading investments, and fees for the exchange of

6

F.J. Brandenburg and M.-c. Cai

stock [26]. These are fixed costs and are a loss for the investor. In addition the investor’s capital changes by interest, quotations and exchange rates, which can be expressed by linear gain functions. When all price alterations and fees are taken into account, the optimal investment policy can be modelled as a shortest (cheapest) path problem or as a maximum flow problem in networks with losses and gains. Unfortunately, this works only backwards for the past and not for future investments. In this paper we introduce and investigate additive networks, which extend standard networks by additive gain functions of the form x + g(a) for the arcs. These gain functions are associated with the network and the flow. An arc is used if the flow is positive and does not exceed the capacity and is nonnegative at the exit. Then the flow is increased or decreased by a fixed amount. In detail, a flow x on an arc a with capacity u(a) and gain g(a) becomes x + g(a) if x > 0, x ≤ u(a) and x + g(x) ≥ 0. A loss g(a) < 0 serves as an entrance fee. Then the requirement x ≥ g(a) serves as a lower bound. However, this is pre-conditioned by a positive flow x > 0. Many flow problems in standard and in generalize networks can be formulated by linear programs, where a real valued variable for each arc expresses the amount of flow on the arc. Additive losses and gains need additional 0-1 variables to express the use of an arc. By the losses and gains of the arcs the amount of flow changes from the source towards the sink, and the change depends on the used arcs. Thus the maximum flow can be measured at the source or at the sink reflecting the producer’s or the consumer’s view. This makes an essential difference for the amount of flow and also for the maximum flow problem. We define the out-flow and in-flow problems, which are reversible if losses and gains are interchanged and do not consume all flow. This paper is organized as follows. In Section 2 we introduce networks with losses and gains, in Section 3 we investigate the shortest path problem. In networks with losses and gains there are two versions: a flow model and a path model. We study some basic properties of shortest paths in the path model and show that the shortest path problem is NP-hard in both models, and is solvable in pseudo-polynomial time for nonnegative costs and gains by a dynamic programming approach. In Section 4 we address the maximum flow problem in additive networks and show that it is NP-hard in the strong sense by a reduction from the Exact Cover by 3-Sets [10]. These NP-hardness results hold for networks with integral capacities and with unit gains or with losses of at least three units. Moreover, the maximum flow problem is MAX-SNP-hard, and is hard to approximate. To the contrary, the maximum flow problem in unit-loss networks can be solved efficiently by the Edmonds-Karp algorithm in O(nm2 ). In summary, our results reveal an essential difference between networks with additive and with multiplicative (or without) losses and gains. From the algorithmic point additive networks are much harder. Here the common flow problems

Shortest Path and Maximum Flow Problems in Networks

7

are intractable whereas they are tractable in generalized networks with multiplicative losses and gains and in standard networks.

2

Networks with Losses and Gains

In this section we introduce the main concepts on networks with additive losses and gains and establish basic properties of flows and paths. A network with losses and gains is a tuple N = (V, A, s, t, c, u, g), where (V, A) a directed graph with n nodes and m arcs and two distinguished nodes, a source s and a sink t without incoming and outgoing arcs, respectively. Each arc a has parameters for the cost, the capacity, and the gain, respectively, which are defined by weighting functions. c(a) is the cost per unit flow, and the capacity u(a) is an upper bound on the amount of flow with u(a) ≥ 0. Both are taken at the entrance of the arcs. g assigns a gain function ga to each arc a, where ga is a function over the nonnegative reals with ga (x) ≥ 0 for x ≥ 0 and ga (0) = 0. The gain ga may vary the amount of flow if there is a flow. If x > 0 units of flow enter a, then ga (x) units exit provided that x ≤ u(a). An arc is gainy if ga (x) > x, conserving if ga (x) = x, and lossy if ga (x) < x. These terms extend to paths and cycles. For convenience, conserving arcs are lossy or gainy. The gain of an arc a is additive if ga (x) = x + g(a), and multiplicative if ga (x) = g(a) · x for some real (or integer) g(a). More general gain functions are not discussed here. For convenience we speak of additive and multiplicative arcs and networks, and we shall restrict ourselves to these cases. A unit-loss network is an additive network with integral capacities for the arcs and no or unit losses. Accordingly, a unit-gain network has integral capacities and gains g(a) ∈ {0, 1}. A flow in a network N is a nonnegative real-valued function f : A → R+ on the arcs satisfying the capacity constraints 0 ≤ f (a) ≤ u(a) and flow conservation at each node except at the source and the sink, and which respects the gains of the arcs. If f (a) = 0  the arc a is unused. Flow conservation at a node v is expressed  by the equation a=(v′ ,v) ga (f (a)) = a′ =(v,v′′ ) f (a′ ), where all terms ga (f (a)) and f (a′ ) are nonnegative.  The out-flow is the amount of flow from the source fout = a=(s,v) f (a),  and the in-flow is the flow into the sink fin = a=(w,t) g(f (a)). These values may differ in networks with losses and gains. The cost of a flow is the sum of the cost of the arcs, where the cost of each arc is charged per unit of flow, c(f ) = a c(a)f (a). If flow x with x > 0 arrives at an unused arc a, then the flow must satisfy the capacity constraint x ≤ u(a) at the entrance. If in addition the arc is lossy with g(a) < 0 the flow must compensate the loss, i.e., x ≥ −g(a). If x = −g(a), all flow is consumed by the arc. If an arc is unused the loss has no effect. This distinguishes losses from lower bounds. The maximum out-flow problem maximizes fout and the maximum in-flow problem maximizes fin . In standard networks these values coincide and in generalized networks with multiplicative losses and gains there are polynomial transformations between these problems [11,20]. However, in additive networks (even

8

F.J. Brandenburg and M.-c. Cai

with unit losses and gains) these problems are essentially different, as shall be shown in Section 4. The shortest path problem is another major problem. Shortest paths have many applications on their own and are often used as a subproblem, e.g. for the maximum flow and the min-cost flow problems. In networks with losses and gains shortest paths must be taken with care. There are two models: a path model and a flow model. In the path model, an s-t path consists of finite sequence of arcs (vi−1 , vi ) for i = 1, . . . , k with s = v0 and t = vk . It is simple, if all nodes are distinct. The cost of a path τ is the cost of a unit flow from the first node and is the sum of the accumulated cost of the arcs of τ , provided that the path is feasible, i.e., the flow on each arc is nonnegative. If all incoming flow is consumed by an arc, then the subsequent arcs are free of charge. The feasibility condition may lead to complex shortest paths consisting of simple paths between gainy and lossy cycles. In particular, if a path includes a cycle then the losses and gains of the arcs in the cycle are accumulated repeatedly and once for each use of each arc. Alternatively, in the flow model the cost of a path is the cost of a unit out-flow in an uncapacitated network. Here the gain function of each arc is used at most once, even in a cycle. Such paths play an important role in generalized networks with multiplicative losses and gains, and consist of a simple s-t path or of a simple path and followed by a lossy cycle where all flow is consumed [3,11,23]. We focus on the complexity and show that the shortest path problem is NPhard in either model of additive networks, even in directed acyclic networks, where both models coincide. Moreover, we provide a pseudo-polynomial time solution with nonnegative costs and gains. 3 2 3 u=4

4 g=1

g=2 1 u=1 2 1 s 1 1 u=1 g=1 u=1 g=1

3

3 7 u=9 g=0

g=1

u=2 2 2 4 u=8

7

t

g= -3

Fig. 1. Paths and flows in an additive network

Flows and paths in additive networks are illustrated by an example. The capacity and the gains are annotated below the arcs. The numbers above the arcs are the flow values at the entrance and at the exit. All arcs have unit cost c(a) = 1. The unit flow from s gains one unit and due to the capacities splits into an upper flow through the nodes 1, 2, 3, t and a median flow through 1, 4, 3, t. A lower path through the nodes 1, 4, t is infeasible, since the arc (4, t) has a loss of three units and needs at least three units of flow at its entrance. The upper path from 1 to t delivers 4 units of flow at t and has cost 8. If the median path comes next it adds 3 units at the cost of 6.

Shortest Path and Maximum Flow Problems in Networks

3

9

Shortest Paths

Here we investigate some basic properties of shortest (or cheapest) paths in additive networks and establish the NP-hardness of the shortest path problem, both in the path and in the flow model. The path model is considered first. Definition 1. Let N be an additive network with cost c(a) and gain g(a) for each arc a. Let τ = (a1 , . . . , ar ) be a path with the arcs a1 , . . . , ar . For an initial  j seed g0 ≥ 0 and 0 ≤ j ≤ r, let γ(τ, j, g0 ) = i=1 g(ai ) + g0 be the prefix sum of the gains with seed g0 . A path τ is full if γ(τ, j, 1) > 0 for j = 1, . . . , r. τ is a dead end if there is some q ≤ r with γ(τ, j, 1) > 0 for j = 1, . . . , q − 1 and γ(τ, q, 1) = 0. τ is infeasible if there is some q ≤ r with γ(τ, q, 1) < 0 and γ(τ, j, 1) > 0 for j = 1, . . . , q − 1. A full path has a positive flow at each arc with a unit as the initial seed. In a dead end there is an arc which absorbs all flow arriving at its entrance. Such paths are feasible. A path is infeasible if the flow were negative. Definition 2. The additive gain of a full path τ = (a1 , . . . , ar ) is g + (τ ) = γ(τ, r, 1) and is zero for a dead end. It is undefined for infeasible paths.  The additive cost of a full path τ is c+ (τ ) = ri=1 c(a i )γ(τ, i − 1, 1). If τ is a q dead end with q = min{j | γ(τ, j, 1) = 0}, then c+ (τ ) = i=1 c(ai )γ(τ, i − 1, 1). A path between two nodes with minimum cost is called a shortest path. The usual  length of a path is the cost without additive gains l(τ ) = ri=1 c(ai ). Thus, the additive gain of a feasible path is the sum of gains of the arcs and is set to zero if the path is a dead end. The cost is the accumulated cost of the arcs, which are charged per unit at the entrance. The feasibility of a path may depend on the initial seed, which increases the cost linearly with the length of the path. There is a threshold as an initial seed such that above the path is full, at the threshold it is a dead end and is infeasible below. A new seed g0 can be obtained by attaching a new arc from a new source with gain g0 − 1. Some basic properties of paths in additive networks can be retrieved from paths with a common prefix or a common suffix, which follow directly from the given definitions. Lemma 1. If a full path τ = τ1 ◦ τ2 is the composition of two full subpaths the gain is g + (τ ) = g + (τ1 ) + g + (τ2 ) and the cost accumulates to c+ (τ ) = c+ (τ1 ) + c+ (τ2 ) + g + (τ1 )l(τ2 ). If τ = τ1 ◦ τ2 is a full path, then the prefix τ1 is a full path. However, τ2 may be full, a dead end, or infeasible. If τ is a dead end, then τ1 may be full or a dead end, and τ2 may be full, a dead end or infeasible. For a comparison of the cost of paths with a common prefix or a common suffix we use two parameters, the cost and the gain, or the cost and the length. This is used in our pseudo-polynomial time algorithm.

10

F.J. Brandenburg and M.-c. Cai

Lemma 2. Let τ1 = ρ ◦ σ1 and τ2 = ρ ◦ σ2 be full paths with the same prefix and full suffixes. Then g + (τ1 ) − g + (τ2 ) = g + (σ1 ) − g + (σ2 ), and c+ (τ1 ) − c+ (τ2 ) = c+ (σ1 ) − c+ (σ2 ) + g + (ρ)(l(σ1 ) − l(σ2 )). Lemma 3. Let τ1 = σ1 ◦ ρ and τ2 = σ2 ◦ ρ be full paths with the same suffix. g + (τ1 ) − g + (τ2 ) = g + (σ1 ) − g + (σ2 ), and c+ (τ1 ) − c+ (τ2 ) = c+ (σ1 ) − c+ (σ2 ) + l(ρ)(g + (σ1 ) − g + (σ2 )). In standard networks each subpath of a shortest path is itself a shortest path. Thus the shortest is hereditary. This property is important for the efficient computation of shortest paths by dynamic programming techniques. It does not hold with losses and gains. Since the multiplicative gain of a finite path is positive, we can conclude that each suffix of a shortest path is a shortest path. A similar property does not hold for prefixes. The algebraic structure is a distributive closed semi-ring, as discovered by Oldham [23] and independently by Batagelj [2]. In additive networks the situation is even worse. The suffix of a path is not necessarily feasible, since the gains may run into the negative, and the prefixes or the suffixes of a shortest path are not necessarily shortest paths. This can be shown by simple examples. Now we turn to shortest paths in additive networks. For the reachability of a node v it must be checked that v is reachable by a full path from the source. This can be done by a Bellman-Ford-type algorithm using the distance function d(a) = −g(a) and the initial distance d(s) = −1 at the source such that the intermediate distances of the nodes are negative. If this algorithm uses a direct negative cycle detection strategy [4,21,24] and detects a cycle of negative cost at some node v, then all graph theoretic successors of v are reachable. The reachability can be computed in O(nm), whereas the shortest path problem is practically unfeasible. Theorem 1. The shortest path problem in additive networks with losses and gains is NP-hard. Proof. We reduce from the partition problem [10]. Given a finite ordered set such that A′ of positive integers A = {a1 , a2 , . . . , a2n }, is there a  subset A′ ⊆ A  contains exactly one of a2i−1 , a2i for 1 ≤ i ≤ n and ai ∈A′ ai = ai ∈A′ ai ?  Let 2B = ai ∈A ai and assume B to be an integer. We construct an instance of the shortest path problem in additive networks as follows: Let N = (V, E, s, t, c, u, g) be an additive network, where V = {s, t} ∪ {u1 , . . . , un+1 } ∪ {v1 , . . . , v2n },  n E = {(s, u1 ), (un+1 , t)} i=1 {(ui , v2i−1 ), (ui , v2i ), (v2i−1 , ui+1 ), (v2i , ui+1 )}. Define the gain of the arcs by g((s, u1 )) = 2B(n + 1), g((ui , vj )) = −2(B + aj ) for j = 2i − 1, 2i and i = 1, . . . , n, and g(a) = 0 otherwise, u ≡ 1 + 2B(n + 1), and let the cost be c((s, u1 )) = c((un+1 , t)) = 1 and c(a) = 0 otherwise. Then it can be shown that N has a shortest s-t path with cost 2 if and only if the instance of partition has a solution.

Shortest Path and Maximum Flow Problems in Networks

11

The construction works equally well in the path and in the flow model, since the network is acyclic. The used partition problem is not NP-hard in the strong sense [10]. The restriction to simple paths is harder by the reduction from the direct Hamilton path problem. Theorem 2. The simple shortest path problem in additive networks is NP-hard in the strong sense. It remains NP-hard if all numbers are integers with absolute values bounded by O(n2 ) and either the costs or the gains are nonnegative. Proof. We reduce from the directed Hamilton path problem [10]. Let G be an instance of the Hamilton path problem with source s and sink t. Construct a network N from G by node splitting. For each node v of G there are two nodes v1 and v2 with the internal arc (v1 , v2 ). v1 inherits all incoming arcs and v2 all outgoing arcs, such that (u, v) is an arc in G if and only if (u2 , v1 ) is an arc in N . These arcs have zero cost and zero gain. Finally, add an arc (t2 , t∗ ) towards a new sink t∗ . First, with nonnegative gains the internal arcs (v1 , v2 ) have unit cost and gain one, and the arc (t2 , t∗ ) has cost −n, where n is the size of G. This is the only negative cost arc. A simple path from s to t through k nodes in G has an associated path in N with gain k and cost k(k − 1)/2 from s1 to t2 . The total cost is k(k − 1)/2 − kn, which is minimum for k = n, which holds if and only if the simple path is a Hamilton path. With nonnegative cost add a new source s∗ and the arc (s∗ , s1 ) with zero cost and gain n + 1. Each inner arc (v1 , v2 ) has unit cost and gain −1, and the arc (t2 , t∗ ) has cost (n + 2)(n + 1). This arc contributes (n + 2)(n + 1) to the cost of the path if and only if the gain has decreased to one, which holds, if and only if there is a Hamilton path in G. Clearly, by guess-and-check it can be determined whether or not there is a path or a simple path with cost at most K from the source to some node v. These NP-hardness results add to the NP-hardness of the cheapest simple path problem in multiplicative networks [3]. Both are NP-hard in the strong sense. There is a pseudo-polynomial time solution by a dynamic programming approach, which leads to a polynomial time solution of the shortest path problem if the gains or the costs are polynomially bounded in the size of the network. Theorem 3. With nonnegative costs and gains the shortest path problem in additive networks can be solved in pseudo-polynomial time. Theorem 4. The shortest (cheapest) path problem in additive networks can be solved in polynomial time, if the costs and the gains are nonnegative and either the costs or the gains are nonnegative integers and bounded from above by some polynomial p(n) in the size of the graph.

4

Maximum Flow Problems in Additive Networks

In networks with losses and gains the maximum flow problem can be stated in various ways. There are networks with a distinguished source without

12

F.J. Brandenburg and M.-c. Cai

incoming arcs and a distinguished sink without out-going arcs, and circulations with flow conservation at all nodes except the source (or the sink). Due to the gains the out-flow from the source and the in-flow into the sink are generally different. The maximum flow can be measured at the source or at the sink (or at any intermediate minimum cut). Both quantities can be combined into the profit problem, which aims at maximizing the difference of the q-fold in-flow and the out-flow. In standard and in multiplicative networks there are linear-time reductions between these versions [11,20]. In additive networks the situation is different. Although all versions of maximum flow problems are shown to be NPhard, there are no linear time reductions, unless P = NP. This is due to the fact that the maximum out-flow problem with unit gain arcs is NP-hard and the in-flow problem is solvable in polynomial time. By symmetry, in unit-loss networks the maximum in-flow problem is NP-hard and the maximum out-flow problem is solvable in polynomial time. Thus maximizing fout with unit gains and fin with unit losses is hard and maximizing fout with unit losses and fin with unit gains is easy. In additive networks there is no symmetry between the generation and the consumption of flow and the in-flow and out-flow problems. All flow is generated in the single source, whereas flow is consumed in the sink and in lossy arcs, if the loss equals the incoming flow. These roles are interchanged in the reverse network. Definition 3. For an additive network N construct the reverse network N ′ by reversing all arcs and exchanging the source and the sink. The capacity and the gains of the arcs are adjusted. If a = (v, w) is an arc of N with capacity u and gain g, then the reverse arc a′ = (w, v) has capacity u + g and gain −g. Thus N ′ is lossy (gainy) if N is gainy (lossy). Cost functions are discarded here. Lemma 4. Let f be a flow in an additive network N such that for each arc a, f (a) + g(a) > 0 if f (a) > 0. Then there is a flow f ′ in the reverse network N ′ ′ ′ with fout = fin (and fin = fout ). Proof. By the assumption the flow f is either positive or zero at both ends of the arcs. Thus all flow is consumed in the sink and the flow can be reversed in N ′ . If f (a) is the flow on the arc a, then 0 < f (a) ≤ u(a) and f (a) + g(a) > 0 by the assumption. In the reverse network N ′ a flow of size f (a) + g(a) enters ′ ′ the reverse arc and f (a) units exit. Hence fout = fin and fin = fout . We now can establish our NP-hardness results for the maximum flow problems by reductions of the Exact Cover by 3-Sets. Theorem 5. In additive networks the maximum out-flow problem is NP-hard in the strong sense, even in unit-gain networks with integral capacities of size O(n). Accordingly, the maximum in-flow problem in unit-loss networks with integral capacities of size O(n) is NP-hard in the strong sense. Theorem 6. In additive networks the maximum out-flow problem is NP-hard in the strong sense, even with integral capacities and losses of size O(n).

Shortest Path and Maximum Flow Problems in Networks

13

Accordingly, the maximum in-flow problem in gainy networks is NP-hard in the strong sense. Remark 1. We can modify the construction for the maximum out-flow problem such that the flow is completely consumed by lossy arcs. Hence such a network is not reversible. The maximum flow problems are NP-hard, and they are MAX-SNP-hard. This is a direct consequence of the above reductions. As a consequence, maximum flow is hard to approximate to within (1 − ǫ) and there is no polynomial time approximation scheme. Theorem 7. In additive networks (with losses) the maximum flow problem from the source is MAX-SNP hard. Proof. The optimization version of the Exact Cover by 3-Sets is MAX-SNP hard [16] and the Exact Cover by 3-Sets is L-reducible to the maximum flow problem from the source in additive networks (with losses). Moreover, we have a further non-approximability result. Theorem 8. There exists a fixed ǫ > 0 such that approximating the maximum out-flow problem within a factor of nǫ in additive networks is NP-hard, where n is an upper bound on the maximum out-flow. Proof. As approximating the max-set-packing problem within a factor of nǫ is NP-hard for some fixed ǫ > 0, where n is the cardinality of the basic set [27], to prove the theorem, it suffices to describe an L-reduction τ from the max-setpacking problem to the maximum out-flow problem in additive networks. Consider an instance I of max-set-packing : Given a collection C = {C1 , · · · , Cm } of subsets of S = {e1 , e2 , · · · , en }, find a subcollection of disjoint subsets C ′ ⊆ C such that |C ′ | is maximized. First we construct an instance τ (I) of the maximum out-flow problem in an additive network N = (V, E, u, g) as follows. V = {s, t, u1 , . . . , um , v1 , . . . , vn }, E = {(s, u1 ), . . . , (s, um )} ∪ {(v1 , t), . . . , (vn , t)} ∪m i=1 {(ui , vj )|ej ∈ Ci }, u ≡ 1,  |Ci | − 1 if a = (s, ui ) and 1 ≤ i ≤ m, g(a) = 0 otherwise. This completes the construction of τ (I). For a feasible solution f of τ (I), let µ(τ (I), f ) denote the objective function value of f , and let µ(I) and µ(τ (I)) denote the optimal values of problems I and τ (I), respectively. Then it can be shown that µ(I) = µ(τ (I)) and τ is a desirable L-reduction. Therefore the approximation within a factor of nǫ is NP-hard for some fixed ǫ > 0. The NP-hardness results indicate that the common network flow techniques with flow augmenting path will not work (efficiently) for computing a maximum flow.

14

F.J. Brandenburg and M.-c. Cai

Unit-loss networks are an exception, where the maximum out-flow problem is solvable in polynomial time. Recall that in unit-loss networks the capacities are integral and so are the flows. Hence, a unit loss can be seen as a shortcut towards the sink and does not serve as a constraint. Theorem 9. Let N be a unit-loss (unit-gain) network with n nodes and m arcs. The maximum in-flow problem can be solved in O(nm2 ) time. Proof. Let N be a unit-loss network with source s and sink t. Since the capacities and the losses are integral, so are the flow and flow augmentations of each arc. Construct a standard network N ′ by adding a new sink t′ and an arc (t, t′ ) with unbounded capacity. For each lossy arc (u, v) in N reduce the capacity by one in N ′ and add an arc (u, t′ ) with unit capacity. Parallel arcs (u, t′ ) can be merged summing the capacity. Then use the Edmonds-Karp algorithm [6] for the computation of the maximal flow in N ′ from s to t′ . The Edmonds-Karp algorithm computes flow augmenting paths according to their lengths, where the length is the number of arcs. Hence, at a node u it prefers the “loss-arcs” (u, t′ ) and uses it first. In the residual network it will not use the backward of a loss-arc. If there were a flow augmenting path from s to t′ using a backward arc (t′ , u), then the path has a cycle at t′ , and the path is not a shortest path as taken by the Edmonds-Karp algorithm. The Edmonds-Karp algorithm computes a maximal flow. If f ′ is the maximal flow computed by the Edmonds-Karp algorithm in N ′ , then the flow f with f (a) = f ′ (a) if a is a flow conserving arc and f (a) = f ′ (a)+1 ′ . Let a = (u, v) be if a is a lossy arc is a maximum flow of N . Clearly, fout ≤ fout ′ ′ a lossy arc. If f (a) > 0, then f (a) ≥ 1 by the integrality and there is a unit flow on the loss-arc (u, t′ ) by the Edmonds-Karp algorithm. Then f (a) = f ′ (a) + 1, and the flow into a in N equals the flow on a in N ′ plus the unit flow on the arc ′ . towards t′ . Hence, fout ≥ fout Notice, that the Edmonds-Karp algorithm may fail when the capacities are nonintegral or the losses are greater than one. In fact, the problem becomes NP-hard with losses of size 3, as Remark 1 establishes. Thus only losses of size two remain unsolved.

References 1. Ahuja, R.K., Magnanti, T.L., Orlin, J.B.: Network Flows. Prentice Hall, Englewood Cliffs (1993) 2. Batagelj, V.: Personal communication (1999) 3. Brandenburg, F.J.: Cycles in generalized networks. In: Kuˇcera, L. (ed.) WG 2002. LNCS, vol. 2573, pp. 47–56. Springer, Heidelberg (2002); Corrigendum In: Bodlaender, H.L. (ed.) WG 2003. LNCS, vol. 2880, pp. 47–57. Springer, Heidelberg 4. Cherkassky, B.V., Goldberg, A.V.: Negative-cycle detection algorithms. Math. Program. 85, 277–311 (1999) 5. Cisco, IP Multicasting, Module 4 Basic Multicast Debugging Cisco Systems Inc. (1998)

Shortest Path and Maximum Flow Problems in Networks

15

6. Cormen, T.H., Leiserson, C.E., Rivest, R.L.: Introduction to Algorithms. MIT Press, Cambridge (1990) 7. Dantzig, G.B.: Linear Programming and Extensions. Princeton Univ. Press, Princeton (1963) 8. Fleischer, L.K., Wayne, K.D.: Fast and simple approximation schemes for generalized flow. Math. Program. 91, 215–238 (2002) 9. Ford Jr., L.R., Fulkerson, D.R.: Flows in Networks. Princeton Univ. Press, Princeton (1962) 10. Garey, M.R., Johnson, D.S.: Computers and Intractability: A Guide to the Theory of NP-Completeness. W.H. Freeman, San Francisco (1979) 11. Goldberg, A.V., Plotkin, S.A., Tardos, E.: Combinatorial algorithms for the generalized circulation problem. Math. Oper. Res. 16, 351–381 (1991) 12. Goldfarb, D., Jin, Z., Orlin, J.: Polynomial-time highest-gain augmenting path algorithms for the generalized circulation problem. Math. Oper. Res. 22, 793–802 (1997) 13. Goldfarb, D., Jin, Z., Lin, Y.: A polynomial dual simplex algorithm for the generalized circulation problem. Math. Progam., Ser. A 91, 271–288 (2002) ¨ 14. Haider, S.: Passau und der Salzhandel nach Osterreich. In: Wurster, H.W., Brunner, M., Loibl, R., Brunner, A. (eds.) Weisses Gold: Passau Vom Reichtum einer europ¨ aischen Stadt, Katalog zur Ausstellung von Stadt und Dioz¨ ose Passau im Oberhausmuseum Passau, pp. 221–236 (1995) 15. Jewell, W.S.: Optimal flow through networks with gains. Oper. Res. 10, 476–499 (1962) 16. Kann, V.: Maximum bounded 3-dimensional matching is MAX-SNP-complete. Inform. Proc. Letters 37, 27–35 (1991) 17. Kantorovich, L.V.: Mathematical methods of organizing and planning production, Publication House of the Leningrad State University, 68 (1939); Translated in Management Science 6, 366–422 (1960) 18. Karmarkar, N.: A new polynomial-time algorithm for linear programming. Combinatorica 4, 373–395 (1984) 19. Khachian, L.G.: Polynomial algorithms in linear programming. Zhurnal Vychislitelnoi Matematiki i Matematicheskoi Fiziki 20, 53–72 (1980) 20. Lawler, E.L.: Combinatorial Optimization: Networks and Matroids, Holt, Rinehard, and Winston, New York (1976) 21. Mehlhorn, K., N¨ aher, S.: LEDA: A Platform for Combinatorial and Geometric Computing. Cambridge University Press, Cambridge (1999) 22. Milgrom, P., Roberts, J.: Economics, Organization, and Management. PrenticeHall, Englewood Cliffs (1992) 23. Oldham, J.D.: Combinatorial approximation algorithms for generalized flow problems. J. Algorithms 38, 135–168 (2001) 24. Tarjan, R.E.: Data Structures and Network Algorithms. Society for Industrial and Applied Mathematics, Philadelphia (1983) 25. Wayne, K.D.: A polynomial combinatorial algorithm for generalized cost flow. Mathematics of Operations Research 27, 445–459 (2002) 26. http://wienerboerse.at/glossary/1/19/446 27. Zuckerman, D.: On unapproximable versions of NP-complete problems. SIAM J. Comput. 26, 1293–1304 (1996)

Edge Search Number of Cographs in Linear Time Pinar Heggernes and Rodica Mihai Department of Informatics, University of Bergen, Norway [email protected], [email protected]

Abstract. We give a linear-time algorithm for computing the edge search number of cographs, thereby proving that this problem can be solved in polynomial time on this graph class. With our result, the knowledge on graph searching of cographs is now complete: node, mixed, and edge search numbers of cographs can all be computed efficiently. Furthermore, we are one step closer to computing the edge search number of permutation graphs.

1

Introduction

Graph searching has been subject to extensive study [4,3,26,28,23,31,38,16,14,27] and it fits into the broader class of pursuit-evasion/search/rendezvous problems on which hundreds of papers have been written (see e.g., the book [1]). The problem was introduced by Parsons [30] and by Petrov [34] independently, and the original definition corresponds exactly to what we today call edge searching. In this setting, a team of searchers is trying to catch a fugitive moving along the edges of a graph. The fugitive is very fast and knows the moves of the searchers, whereas the searchers cannot see the fugitive until they capture him (when the fugitive is trapped and has nowhere to run). An edge is cleared by sliding a searcher from one endpoint to the other endpoint, and a vertex is cleared when a searcher is placed on it; we will give the formal definition of clearing a part of the graph in the next section. The problem is to find the minimum number of searchers that can guarantee the capture of the fugitive, which is called the edge search number of the graph. There are two modifications of the classical Parsons-Petrov model, namely node searching and mixed searching, introduced by Kirousis and Papadimitriou [24] and Bienstock and Seymour in [4], respectively. The main difference between the three variants is in the way an edge is cleared. In the node searching version an edge is cleared if both its endpoints contain searchers. The mixed searching version combines the features of node and edge searching, namely an edge is cleared if either both its two endpoints contain searchers or a searcher is slided along it. The minimum number of searchers sufficient to perform searching and ensure the capture of the fugitive for each of the three variants are respectively the edge, node, and mixed search numbers, and computations of these are all NP-hard [4,28,23]. X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 16–26, 2009. c Springer-Verlag Berlin Heidelberg 2009 

Edge Search Number of Cographs in Linear Time

17

Computing the node search number of a graph is equivalent to computing its pathwidth, and polynomial-time algorithms are known for computing the node search number of trees [32,35], interval graphs [8], k-starlike graphs for fixed k [31], d-trapezoid graphs [6], block graphs [10], split graphs [20], circulararc graphs [36], permutation graphs [5,29], biconvex bipartite graphs [33], and unicyclic graphs [13]. However, only for a few of these graph classes polynomialtime algorithms are known for computing mixed search and edge search numbers. Mixed search number of interval graphs, split graphs [15] and permutation graphs [22] can be computed in polynomial time. Edge search number of trees [28,32], interval graphs, split graphs [31,18], unicyclic graphs [38], and complete multipartite graphs [2] can be computed in polynomial time. In this paper, we give a linear-time algorithm for computing the edge search number of cographs, and thereby we prove that the edge search number of cographs can be computed in polynomial time, which has been an open problem until now. Cographs are an important and well studied subclass of permutation graphs [19,9]. Hence, by the mentioned results on permutation graphs above, their node search and mixed search numbers were already known to be computable in polynomial time. An especially designed algorithm for the node search number of cographs also exists [7]. Our new results complete the knowledge on the graph searching on cographs, showing that node, mixed, and edge search numbers of cographs can all be computed efficiently. Apart from cographs, we see from the above list that interval and split graphs are the only graph classes for which polynomial-time algorithms are known for computing their node, mixed and edge search numbers. For permutation graphs, we still do not know how to compute their edge search number in polynomial time. With our results, we extend the knowledge on permutation graphs in the sense that we know at least how to compute the edge search number of some permutation graphs, namely cographs.

2

Preliminaries

We work with simple and undirected graphs G = (V, E), with vertex set V (G) = V and edge set E(G) = E. The set of neighbors of a vertex x is denoted by N (x) = {y | xy ∈ E}. The degree of a vertex v is d(v) = |N (v)|. A vertex is universal if N (v) = V \ {v} and isolated if N (v) = ∅. A vertex set is a clique if all of its vertices are pairwise are adjacent, and an independent set if all of its vertices are pairwise non-adjacent. The subgraph of G induced by a vertex set A ⊆ V is denoted by G[A]. For a given vertex u ∈ V , we denote G[V \ {u}] simply by G−u. Kn denotes the complete graph on n vertices. In denotes the graph on n isolated vertices (hence no edge), and by Kn,m we denote the complete bipartite graph (X, Y, E) such that |X| = n and |Y | = m. Let G = (V, E) and H = (W, F ) be two undirected graphs with V ∩ W = ∅. The (disjoint) union of G and H is G ⊕ H = (V ∪ W, E ∪ F ), and the join of G and H is G ⊗ H = (V ∪ W, E ∪ F ∪ {vw | v ∈ V, w ∈ W }). Cographs are defined recursively through the following operations:

18

P. Heggernes and R. Mihai

– A single vertex is a cograph. – If G and H are vertex disjoint cographs then G ⊕ H is a cograph. – If G and H are vertex disjoint cographs then G ⊗ H is a cograph. Consequently, complements of cographs are also cographs. If G is a cograph then either G is disconnected, or its complement G is disconnected, or G consists of a single vertex. Using the corresponding decomposition rules one obtains the modular decomposition tree of a cograph which is called a cotree. A cotree T of a cograph G is a rooted tree with two types of interior nodes: 0-nodes and 1-nodes. The vertices of G are assigned to the leaves of T in a one-to-one manner. Two vertices u and v are adjacent in G if and only if the lowest common ancestor of the leaves u and v in T is a 1-node. A graph is a cograph if and only if it has a cotree [11]. Cographs can be recognized and their corresponding cotrees can be generated in linear time [21,12]. A path-decomposition of a graph G = (V, E) is a linearly ordered sequence of subsets of V , called bags, such that the following three conditions are satisfied: 1. Every vertex x ∈ V appears in some bag. 2. For every edge xy ∈ E there is a bag containing both x and y. 3. For every vertex x ∈ V , the bags containing x appear consecutively. The width of a decomposition is the size of the largest bag minus one, and the pathwidth of a graph G, pw(G), is the minimum width over all possible path decompositions. The edge search game can be formally defined as follows. Let G = (V, E) be a graph to be searched. A search strategy consists of a sequence of discrete steps which involves searchers. Initially there is no searcher on the graph. Every step is one of the following three types: – Some searchers are placed on some vertices of G (there can be several searchers located in one vertex); – Some searchers are removed from G; – A searcher slides from a vertex u to a vertex v along edge uv. At every step of the search strategy the edge set of G is partitioned into two sets: cleared and contaminated edges. Intuitively, the agile and omniscient fugitive with unbounded speed who is invisible for the searchers, is located somewhere on a contaminated territory, and cannot be on cleared edges. Initially all edges of G are contaminated, i.e., the fugitive can be anywhere. A contaminated edge uv becomes cleared at some step of the search strategy if at this step a searcher located in u slides to v along uv. A cleared edge e is (re)contaminated at some step if at this step there exists a path P containing e and a contaminated edge and no internal vertex of P contains a searcher. For example, if a vertex u is incident to a contaminated edge e, there is only one searcher at u and this searcher slides from u to v along edge uv = e, then after this step the edge uv, which is cleared by sliding, is immediately recontaminated. A search strategy is winning if after its termination all edges are cleared. The edge search number of a graph G, denoted by es(G), is the minimum number of searchers required for a winning strategy of edge searching on G. The differences

Edge Search Number of Cographs in Linear Time

19

between mixed, edge, and node searching are in the way the edges can be cleared. In node searching an edge is cleared only if both its endpoints are occupied (no clearing by sliding). In mixed searching an edge can be cleared both by sliding and if both its endpoints are occupied by searchers. The mixed and node search numbers of a graph G are defined similarly to the edge search number, and are denoted by ms(G) and ns(G), respectively. The following result is central; it gives the relation between the three graph searching parameters and relates them to pathwidth. Lemma 1 ([37]). Let G be an arbitrary graph. – ns(G) = pw(G) + 1. – pw(G) ≤ ms(G) ≤ pw(G) + 1. – pw(G) ≤ es(G) ≤ pw(G) + 2. Hence computing the pathwidth and the node search number are equivalent tasks. However, note that, although pw(G) of a graph G can be computed easily, it might be difficult to decide whether es(G) = pw(G) or es(G) = pw(G) + 1 or es(G) = pw(G) + 2. A winning edge search strategy using es(G) steps is called optimal. A search strategy is called monotone if at any step of this strategy no recontamination occurs. For all three versions of graph searching, recontamination does not help to search the graph with fewer searchers [4,26], i.e., on any graph with edge search number k there exists a winning monotone edge search strategy using k searchers. Thus in this paper we consider only monotone edge search strategies.

3

Edge Search Number of Cographs

In this section we show how to compute the edge search number of a cograph. We start by giving general results on the disjoint union and join of two arbitrary graphs. Given an arbitrary graph G and an integer c, following Golovach [17], we define Gc to be a supergraph of G, obtained from G by attaching c new vertices of degree 1 to each vertex of G. Hence Gc has c · |V (G)| vertices in addition to the |V (G)| vertices of G. Lemma 2 ([17]). Let G and H be two arbitrary graphs with |V (G)| = n and |V (H)| = m, such that the pair {G, H} is not one of the following pairs {I1 , I1 }, {I1 , I2 }, {I2 , I2 }, {I2 , Kk }. Then es(G ⊗ H) = min{es(Gm )+m, es(Hn )+n}. We will relate the above lemma to edge search strategies. To have an easy notion of the number of searchers that are used at each step of the search, assume for the rest of this section that every searcher which is not necessary is removed from the graph as soon as it becomes unnecessary. We define extra(G) = 1 if there is an optimal edge strategy on G such that every time the maximum number of searchers is used the following operation is executed: sliding a searcher through an edge whose both endpoints are occupied by two other searchers. Hence extra(G) = 0 if every optimal edge search strategy avoids this operation at least once when using the maximum number of searchers.

20

P. Heggernes and R. Mihai

Lemma 3. Let G be an arbitrary graph and c > 2 be an integer. Then es(Gc ) = es(G)+1−extra(G). Proof. Clearly, es(Gc ) ≥ es(G). Let us study the two cases extra(G) = 1 and extra(G) = 0 separately. Let extra(G) = 1. Then it follows directly that es(Gc ) ≥ es(G) + 1 − extra(G) = es(G). Let us show that es(Gc ) ≤ es(G)+ 1 − extra(G) = es(G). We will do this by turning any optimal edge strategy for G into an edge strategy for Gc using at most the same number of searchers. We run the each search strategy of G on Gc . Since at each step of the search at least one searcher is available to be slided between two already occupied vertices, whenever the strategy of G clears a vertex v, we keep the searcher on v, and we use the extra available searcher to clear all the vertices of degree 1 adjacent to v, one by one. Thus we conclude that es(Gc ) = es(G) = es(G) + 1 − extra(G) when extra(G) = 1. Let extra(G) = 0 and es(G) = k. First we show that es(Gc ) ≥ es(G) + 1 − extra(G) = k + 1. We know that at least k searchers are necessary to clear Gc , by the first sentence of the proof. So assume for a contradiction that es(Gc ) = k. Consider any optimal edge search strategy for Gc ; let us study the last step before the k’th searcher is used for the first time. To get rid of some simple cases, without loss of generality we can use the k’th searcher to clear all edges whose both endpoints are occupied by searchers. In addition, if a degree one vertex contains a searcher, we can slide it to the single neighbor v of this vertex, and then use the k’th searcher to clear all edges between v and its neighbors of degree 1. Hence, for each vertex u of degree at least 2 containing a searcher, we can use the k’th searcher to clear all edges between u and its neighbors of degree 1. Furthermore, if a vertex containing a searcher is incident to only one contaminated edge, then we can slide its searcher to the other endpoint of the contaminated edge, clearing the edge. After repeating this for as long as possible, if some vertices are incident to only cleared edges, we can remove their searcher and place it on an uncleared vertex. Hence we can assume that there is a step in this search strategy where k − 1 searchers are placed on the vertices of G, all edges between vertices of degree one and their neighbors containing searchers are cleared, all edges containing searchers on both endpoints are cleared, and Gc is not yet cleared since extra(G) = 0 and we have so far only slided the k’th searcher between vertices of G occupied with searchers. At this point, every vertex containing a searcher is incident to at least two contaminated edges of G. After this point, we can clear at most one contaminated edge incident to some vertex occupied by a searcher, by sliding the k’th searcher from the occupied endpoint towards the endpoint w not occupied by a searcher. Note that w is not a degree one vertex, and all edges between w and its neighbors of degree one are contaminated. Consequently, from now on no searcher can be removed or slided without allowing recontamination, and the search cannot continue successfully without increasing the number of searchers. Thus es(Gc ) ≥ k + 1 = es(G) + 1 − extra(G). Let us now show that es(Gc ) ≤ es(G) + 1, that k + 1 searchers are enough to clear Gc . We construct an optimal edge search strategy for Gc by following the steps of an optimal edge search

Edge Search Number of Cographs in Linear Time

21

strategy for G. At each step where we place a searcher on a vertex v of G we use the extra searcher to clear all the edges between v and vertices of degree 1. Thus es(Gc ) = es(G) + 1 − extra(G) if extra(G) = 0. ⊓ ⊔ By Lemmas 2 and 3, the next lemma follows immediately. For the cases that are not covered by this lemma, it is easy to check that es(I1 ⊗ I1 ) = es(I1 ⊗ I2 ) = es(I2 ⊗ I2 ) = 1 and es(I2 ⊗ Kk ) = k + 1 for k ≥ 2. Lemma 4. Let G and H be two arbitrary graphs with |V (G)| = n and |V (H)| = m, such that the pair {G, H} is not one of the following pairs {I1 , I1 }, {I1 , I2 }, {I2 , I2 }, {I2 , Kk }. Then es(G ⊗ H) = min{n+es(H)+1−extra(H), m+es(G)+1−extra(G)}. Consequently, if we know how to compute extra(G) for a graph G then we can compute the edge search number of the join of two graphs using the above lemma. This might be a difficult task for general graphs, but here we will show that we can compute extra(G) efficiently if G is a cograph. Before we continue with this, we briefly mention that the disjoint union operation on two arbitrary graphs is easy to handle with respect to edge search number and the parameter extra. If G and H are two arbitrary disjoint graphs, then clearly es(G⊕H) = max{es(G), es(H)}. Furthermore we have the following observation on extra(G ⊕ H). Lemma 5. Let G1 and G2 be two arbitrary graphs. Then extra(G1 ⊕ G2 ) = mini∈{1,2} {extra(Gi ) | es(Gi ) = es(G1 ⊕ G2 )}. Proof. Without loss of generality let es(G1 ⊕ G2 ) = es(G1 ). We have two possibilities: either es(G2 ) < es(G1 ) or es(G2 ) = es(G1 ). For the first case, extra(G1 ⊕ G2 ) = extra(G1 ), regardless of extra(G2 ), since we can search G2 first and then move all the searchers to G2 . For the second case, the lemma claims that if extra(G1 ) = 0 or extra(G2 ) = 0 then extra extra(G1 ⊕ G2 ) = 0. This is easy to see, since regardless of where we start the search, there will be a point of the search where all searchers are used without the use of the sliding operation between two vertices occupied by searchers. ⊓ ⊔ We continue by listing some simple graphs G with extra(G) = 0. For the graphs covered by the next lemma, it is known that es(In ) = 1, es(K2 ) = 1, es(K3 ) = 2, and es(Kn ) = n for n ≥ 4. Furthermore, es(Kn,m ) = min{n, m} + 1 when min{n, m} ≤ 2 and since (I2 ⊗ Kn ) is an interval graph, es(I2 ⊗ Kn ) = n + 1 for n ≥ 1, by the results of [31,18]. Lemma 6. If G is one of the following graphs then extra(G) = 0: In , Kn with n ≤ 3, Kn,m with min{n, m} ≤ 2, or (I2 ⊗ Kn ). Proof. The optimal edge search strategies for these graphs are known, as listed before the lemma, from previous results [2,15]. Using these results and by the definition of the parameter extra it follows immediately that extra(G) = 0 if G is one of the following graphs: In , Kn , or Kn,m with min{n, m} < 3. If G = I2 ⊗Kn

22

P. Heggernes and R. Mihai

then since G an interval graph, it follows from [31,18] that es(G) = n + 1. It follows also that extra(G) = 0 since in every optimal edge search strategy for G, when the maximum number of searchers are required, at least one edge uv is cleared by sliding the searcher from u towards v when all adjacent edges to u are cleared except uv. ⊓ ⊔ Lemma 7. If G has a universal vertex u, and the size of the largest connected component of G−u is at most 2, then extra(G) = 0. Proof. If all connected components of G−u are of size 1, then G = K1,n and covered by the previous lemma. Otherwise, a graph G that satisfies the premises of the lemma consists of edges and triangles all sharing a common vertex u, and sharing no other vertices. Such a graph is an interval graph, and it is known that it can be cleared with 2 searchers: place one searcher on u, and clear every edge or triangle attached at u by sliding the second searcher from u to the other vertices of the edge or the triangle. Clearly extra(G) = 0. ⊓ ⊔ Notice that the above two lemmas, together with Lemma 5, handle the extra parameter of all (and more) graphs that are not covered by Lemma 4. We are now ready to show how to compute extra(G) when G is a cograph. This will be explained algorithmically in the proof of the next lemma. For this we will use the cotree as a data structure to store G. Note that due to the decomposition rules on cographs explained in Section 2, we may assume that each interior node of a cotree has exactly two children. As an initialization, note that a single vertex is a special case of In , and hence for a single vertex u we define extra(u) = 0. Consequently, in our algorithm every leaf l of the cotree of a cograph will have extra(l) = 0 before we start the computations. Lemma 8. Let G be a cograph. Then extra(G) can be computed in linear time. Proof. Let G be a cograph and let T be its cotree. If G is one of the special cographs covered by Lemmas 6 and 7 then extra(G) = 0. We assume now we initialized all the subtrees corresponding to the special cases covered by these lemmas. Let us consider now the first node in the cotree which corresponds to a graph which is not one of those cases. If we are dealing with a 0-node then we can compute the value for the parameter extra by Lemma 5. We will show now how to compute extra for a 1-node. Let Tl and Tr be the the left subtree and the right subtree of the 1-node considered and let Gl and Gr be the corresponding cographs that have Tl and Tr as their cotrees, respectively. We first consider the case when extra(Gl ) = extra(Gr ) = 0. Since we already initialized all the special cases covered by Lemmas 6 and 7, and we are at a join-node, we know that we not dealing with one of the cases not covered by Lemma 4. Thus by Lemma 4 we have that es(Gl ⊗Gr ) = min{|V (Gl )|+es(Gr )+ 1 − extra(Gr ), |V (Gr )| + es(Gl ) + 1 − extra(Gl )} = min{|V (Gl )| + es(Gr ) + 1, |V (Gr )| + es(Gl ) + 1}. Let us assume without loss of generality that es(Gl ⊗ Gr ) = |V (Gl )| + es(Gr ) + 1. We will show now that there is an optimal edge search strategy for Gl ⊗ Gr using at every step that requires the maximum

Edge Search Number of Cographs in Linear Time

23

number of searchers in the strategy the following operation: an edge is cleared by sliding a searcher from one endpoint towards the other endpoint when both endpoints are occupied by searchers. We place |V (Gl )| searchers on the vertices of Gl , and we use one more searcher to clear all the edges inside Gl . At this point the only edges not cleared are the edges of Gr and the edges between the vertices of Gr and the vertices of Gl . The following step in the edge search strategy for Gl ⊗ Gr is the same as the first step in the edge search strategy for Gr . At each point when we place a new searcher on a vertex v of Gr we use one searcher to clear the edges between v and Gl . This is possible to do also when using the maximum number of searchers in Gr which is es(Gr ). At this point |V (Gl )| searchers are placed on the vertices of Gl and we have es(Gr ) searchers on some vertices of Gr . Since es(Gl ⊗ Gr ) = |V (Gl )| + es(Gr ) + 1 we have one more searcher available to clear the edges between Gl and Gr by sliding. This is true for each step when using the largest number of searchers in Gr . Thus, by the definition of extra we have extra(Gl ⊗ Gr ) = 1. We consider now the case when extra(Gl ) = 0 and extra(Gr ) = 1. First we consider the case when es(Gl ⊗ Gr ) = min{|V (Gl )| + es(Gr ), |V (Gr )| + es(Gl ) + 1} = |V (Gl )| + es(Gr ). We give a corresponding edge search strategy such that extra(Gl ⊗ Gr ) = 1. We place as before |V (Gl )| searchers on the vertices of Gl and use one more searcher to clear the edges inside Gl . Next steps are to imitate the optimal edge search strategy of Gr . We know that extra(Gr ) = 1 which means that at every step when using es(Gr ) searchers on Gr , one searcher is used only to slide trough an edge uv whose both endpoints are occupied by two other searchers. Thus we can use the same sliding searcher to clear the edges between u and the vertices of Gl and the edges between v and the vertices of Gl . Thus extra(Gl ⊗ Gr ) = 1. Let assume now that es(Gl ⊗ Gr ) = min{|Gl | + es(Gr ), |Gr | + es(Gl ) + 1} = |Gr | + es(Gl ) + 1. We construct the desired edge search strategy in the following manner. We place |Gr | searchers on the vertices of Gr . After that we construct the edge search strategy similar to the first case consider when extra(Gl ) = extra(Gr ) = 0. Thus extra(Gl ⊗ Gr ) = 1. The last case we need to consider is extra(Gl ) = extra(Gr ) = 1. Then es(Gl ⊗ Gr ) = min{|Gl | + es(Gr ), |Gr | + es(Gl )}. This is similar to the case when extra(Gl ) = 0 and extra(Gr ) = 1 and es(Gl ⊗ Gr ) = |Gl | + es(Gr ). Thus we have extra(Gl ⊗ Gr ) = 1 also in this situation. All the previous cases can be checked in constant-time. For each node of the cotree we compute the value of extra in constant-time using a bottom-up strategy. Therefore, we can conclude that extra(G) can be computed in lineartime for a cograph. ⊓ ⊔ In fact, a stronger result follows immediately by the proof of Lemma 8: Corollary 1. If G is a connected cograph, and G is not one of the graphs covered by Lemmas 6 and 7, then extra(G) = 1. Theorem 1. Let G be a cograph. Then the edge search number of G can be computed in linear time.

24

P. Heggernes and R. Mihai

Proof. In order to compute the edge search number of a cograph G we do the following. First we compute the cotree T of G in linear time. The next step is to initialize all starting subtrees according to Lemmas 6 and 7. After that we use a bottom-up strategy to compute the edge search number of G. For each 1-node we compute the edge search number according to Lemma 4 and the parameter extra according to Lemma 8. For each 0-node we compute the edge search number and the parameter extra according to Lemma 5. Thus we have that the edge search number of a cograph can be computed in linear time. ⊓ ⊔

4

Conclusions

We have shown how to compute the edge search number of cographs in linear time. It remains an open problem whether the edge search number of permutation graphs can be computed in polynomial time. Both answers to this questions would be interesting. If it turns out that the edge search number for permutation graphs is NP-hard, this would give the first graph class where node and mixed search number are computable in polynomial time and the edge search number computation is NP-hard.

Acknowledgment The authors would like to thank Petr Golovach for useful discussions.

References 1. Alpern, S., Gal, S.: The theory of search games and rendezvous. International Series in Operations Research & Management Science, vol. 55. Kluwer Academic Publishers, Boston (2003) 2. Alspach, B., Dyer, D., Hanson, D., Yang, B.: Lower Bounds on Edge Searching. In: Chen, B., Paterson, M., Zhang, G. (eds.) ESCAPE 2007. LNCS, vol. 4614, pp. 516–527. Springer, Heidelberg (2007) 3. Bienstock, D.: Graph searching, path-width, tree-width and related problems (a survey), DIMACS Ser. Discrete Mathematics and Theoretical Computer Science 5, 33–49 (1991) 4. Bienstock, D., Seymour, P.: Monotonicity in graph searching. J. Algorithms 12, 239–245 (1991) 5. Bodlaender, H.L., Kloks, T., Kratsch, D.: Treewidth and pathwidth of permutation graphs. SIAM J. Disc. Math. 8, 606–616 (1995) 6. Bodlaender, H.L., Kloks, T., Kratsch, D., M¨ ohring, R.H.: Treewidth and Minimum Fill-in on d-Trapezoid Graphs. J. Graph Algorithms Appl. 2 (1998) 7. Bodlaender, H.L., M¨ ohring, R.H.: The pathwidth and treewidth of cographs. In: Gilbert, J.R., Karlsson, R. (eds.) SWAT 1990. LNCS, vol. 447, pp. 301–310. Springer, Heidelberg (1990) 8. Booth, K.S., Lueker, G.S.: Testing for the consecutive ones property, interval graphs, and graph planarity using pq-tree algorithms. J. Comp. Syst. Sc. 13, 335– 379 (1976)

Edge Search Number of Cographs in Linear Time

25

9. Brandst¨ adt, A., Le, V.B., Spinrad, J.P.: Graph classes: a survey, Philadelphia, PA, USA. Society for Industrial and Applied Mathematics (1999) 10. Chou, H., Ko, M., Ho, C., Chen, G.: Node-searching problem on block graphs. Disc. Appl. Math. 156, 55–75 (2008) 11. Corneil, D.G., Lerchs, H., Stewart Burlingham, L.: Complement reducible graphs. Annals Discrete Math. 1, 145–162 (1981) 12. Corneil, D.G., Perl, Y., Stewart, L.K.: A linear recognition algorithm for cographs. SIAM Journal on Computing 14, 926–934 (1985) 13. Ellis, J., Markov, M.: Computing the vertex separation of unicyclic graphs, Inf. Comput. 192, pp. 123–161 (2004) 14. Fomin, F.V., Fraigniaud, P., Nisse, N.: Nondeterministic Graph Searching: From Pathwidth to Treewidth. Algorithmica (2008) 15. Fomin, F., Heggernes, P., Mihai, R.: Mixed search number and linear-width of interval and split graphs. In: Brandst¨ adt, A., Kratsch, D., M¨ uller, H. (eds.) WG 2007. LNCS, vol. 4769, pp. 304–315. Springer, Heidelberg (2007) 16. Fomin, F., Thilikos, D.: An annotated bibliography on guaranteed graph searching. Theor. Comput. Sci. 399, 236–245 (2008) 17. Golovach, P.A.: Extremal search problems on graphs, Ph.D Thesis, Leningrad (1990) 18. Golovach, P.A., Petrov, N.N.: Some generalizations of the problem on the search number of a graph. Vestn. St. Petersbg. Univ., Math. 28(3), 18–22 (1995); translation from Vestn. St-Peterbg. Univ., Ser. I, Mat. Mekh. Astron., 3, pp. 21–27 (1995) 19. Golumbic, M.C.: Algorithmic Graph Theory and Perfect Graphs (Annals of Discrete Mathematics, vol. 57. North-Holland, Amsterdam (2004) 20. Gustedt, J.: On the pathwidth of chordal graphs. Disc. Appl. Math. 45, 233–248 (1993) 21. Habib, M., Paul, C.: A simple linear time algorithm for cograph recognition. Discrete Applied Mathematics 145, 183–197 (2005) 22. Heggernes, P., Mihai, R.: Mixed search number of permutation graphs. In: Preparata, F.P., Wu, X., Yin, J. (eds.) FAW 2008. LNCS, vol. 5059, pp. 196–207. Springer, Heidelberg (2008) 23. Kirousis, L.M., Papadimitriou, C.H.: Interval graphs and searching. Disc. Math. 55, 181–184 (1985) 24. Kirousis, M., Papadimitriou, C.H.: Searching and pebbling. Theor. Comput. Sci. 47, 205–218 (1986) 25. Kloks, T., Kratsch, D., Spinrad, J.: On treewidth and minimum fill-in of asteroidal triple-free graphs. Theor. Comp. Sc. 175, 309–335 (1997) 26. LaPaugh, A.S.: Recontamination does not help to search a graph. J. ACM 40, 224–245 (1993) 27. Mazoit, F., Nisse, N.: Monotonicity of non-deterministic graph searching. Theor. Comput. Sci. 3, 399, 169–178 (2008) 28. Megiddo, N., Hakimi, S.L., Garey, M.R., Johnson, D.S., Papadimitriou, C.H.: The complexity of searching a graph. J. ACM 35, 18–44 (1988) 29. Meister, D.: Computing treewidth and minimum fill-in for permutation graphs in linear time. In: Kratsch, D. (ed.) WG 2005. LNCS, vol. 3787, pp. 91–102. Springer, Heidelberg (2005) 30. Parsons, T.: Pursuit-evasion in a graph. In: Theory and Applications of Graphs. Springer, Heidelberg (1976) 31. Peng, S.-L., Ko, M.-T., Ho, C.-W., Hsu, T.-s., Tang, C.Y.: Graph searching on some subclasses of chordal graphs. Algorithmica 27, 395–426 (2000)

26

P. Heggernes and R. Mihai

32. Peng, S.-L., Ho, C.-W., Hsu, T.-s., Ko, M.-T., Tang, C.Y.: Edge and node searching problems on trees. Theor. Comput. Sci. 240, 429–446 (2000) 33. Peng, S.-L., Yang, Y.-C.: On the treewidth and pathwidth of biconvex bipartite graphs. In: Cai, J.-Y., Cooper, S.B., Zhu, H. (eds.) TAMC 2007. LNCS, vol. 4484, pp. 244–255. Springer, Heidelberg (2007) 34. Petrov, N.N.: A problem of pursuit in the absence of information on the pursued. Differentsialnye Uravneniya 18, 1345–1352, 1468 (1982) 35. Skodinis, K.: Construction of linear tree-layouts which are optimal with respect to vertex separation in linear time. J. Algorithms 47, 40–59 (2003) 36. Suchan, K., Todinca, I.: Pathwidth of circular-arc graphs. In: Brandst¨ adt, A., Kratsch, D., M¨ uller, H. (eds.) WG 2007. LNCS, vol. 4769, pp. 258–269. Springer, Heidelberg (2007) 37. Takahashi, A., Ueno, S., Kajitani, Y.: Mixed searching and proper-path-width. Theor. Comput. Sci. 137, 253–268 (1995) 38. Yang, B., Zhang, R., Cao, Y.: Searching cycle-disjoint graphs. In: Dress, A.W.M., Xu, Y., Zhu, B. (eds.) COCOA. LNCS, vol. 4616, pp. 32–43. Springer, Heidelberg (2007)

Formal Derivation of a High-Trustworthy Generic Algorithmic Program for Solving a Class of Path Problems Changjing Wang 1,2,3 and Jinyun Xue 1,2,* 1

Key Laboratory for High-Performance Computing Technology, Jiangxi Normal University, Nanchang 330022 2 Institute of Software, Chinese Academy of Sciences Beijing 100190 3 Graduate University of Chinese Academy of Sciences Beijing 100190

, ,

Abstract. Recently high-trustworthy software has been proposed and advocated by many academic and engineering communities. High-trustworthy algorithm is core to high-trustworthy software. In this paper, using PAR method we derive formally a high-trustworthy generic algorithmic program for solving general single-source path problems. Common characteristics of these path problems can be abstracted into an algebra structure-dioid. Some typical graph algorithms, such as Bellman-Ford single-source shortest path algorithm, Reachability problem algorithm, and Bottleneck problem algorithm, etc. are all instances of the generic algorithmic program. Our approach mainly employs formal derivation technology and generic technology. Main contribution is combining the two techniques into a systemic approach, which aims to develop high-trustworthy generic algorithmic program for solving general problems. According to our approach, the correctness, reliability, safety and development efficiency of algorithmic programs are greatly improved. It is expected to be a promising approach to develop high-trustworthy generic algorithmic program. Keywords: High-trustworthy; Formal derivation; Generic algorithm; Path problem; Dioid.

1 Introduction Recently high-trustworthy software has been proposed and advocated by academic and engineering community. Hoare [1] has proposed a grand challenge project, formerly called the “verifying compiler” grand challenge, and now the “verified software” grand challenge [2]. The national software strategy of USA (2006-2015)-next generation software engineering also puts the improvement of software trustworthiness in the first place. DARPA, NASA, NSA, NSF, NCO/ITRD, etc., of USA are actively participating in this research subject. A series of related international conferences had been held [3-4] and many official *

Corresponding author: [email protected]

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 27–39, 2009. © Springer-Verlag Berlin Heidelberg 2009

28

C. Wang and J. Xue

related reports had been made [5-6]. High-trustworthy algorithm is core to high-trustworthy software. But until now it is still not easy to ensure the high-trustworthy of ingenious algorithmic programs, although many researchers have made various attempts in this direction. In this paper, using PAR method (see Part 2.1) we derive formally a high-trustworthy generic algorithmic program for solving a class of path problems. At first, we derive a generic algorithmic program for solving general single-source path problems. Common characteristics of these path problems can be abstracted into an algebra structure-dioid. Then some typical graph problems, such as Bellman-Ford single-source shortest path algorithm, Reachability problem algorithm, and Bottleneck problem algorithm, etc. are generated by simply substituting concrete dioid for abstract dioid, i.e., generic type and operation parameters, in the generic algorithmic program. Our approach mainly employs formal derivation technology and generic technology. Main contribution is combining the two techniques into a systemic approach, which aims to develop high-trustworthy generic algorithmic program for solving general problems. As for as formal derivation technology, there have two points to illustrate. Firstly, the common characteristics of general single-source path problems can be abstracted into a dioid (see Part 2.2). The properties of the dioid satisfy the conditions of transformation rules of quantifiers. This makes formal derivation of the generic algorithmic program possible. Secondly, we use Radl(Recurrence-based Algorithm Design Language) represent specification, transformation rules and algorithm that has two peculiar characteristics: mathematical transparency and suitable notation, which make it easy and simpler to directly get algorithm from problem specification by formal derivation. In the process of algorithm derivation, not only embody the designer insight, but reveal the main ideas and ingenuity of algorithm. As for as generic technology, we define Radl and Apla(Abstract Programming Language). They provide two important generic mechanisms (type parameterization and operation parameterization) to support conveniently developing of generic algorithmic program, which few modern languages fully possess, say Java, C#, etc. The remainder of the paper is organized as follows: Part 2 gives a necessary preliminary knowledge. Part 3 illustrates how to apply our approach to derive a generic algorithm program for solving general single-source path problems. Part 4 instantiates the generic algorithm program to get some typical algorithms. Part 5 compares with related works. Part 6 concludes and discusses about future work directions.

2 Preliminary 2.1 PAR Method and Its Derivation Rules PAR method [7-8] is a unified and systematic approach for designing efficient algorithmic programs. It consists of Radl, Apla, systematic algorithm design method and software development method, and a set of automatic tools for program generation. Radl main function is to describe the algorithm specification,

Formal Derivation of a High-Trustworthy Generic Algorithmic Program

29

transformation rules and algorithm. Apla main function is to embody data abstraction and operation abstraction. PAR method covers several existing algorithm design methods such as divide-and-conquer, dynamic programming, greedy, and enumeration. The designer of algorithms using PAR can partly avoid the difficulty in making choice among various existing design methods. According to PAR, the process of developing an algorithmic program can be divided into six steps: Step 1: Describe the formal functional specification of an algorithmic problem using Radl. Step 2: Partition the problem into a couple of sub-problems, each of which has the same structure with the original problem but smaller in size; then partition the sub-problems into smaller sub-problems until each sub-problem can be solved directly. Step 3: Formally derive the algorithm from the formal functional specification. The algorithm is described using Radl and represented by recurrences and initialization. Step 4: Develop the loop invariant for the algorithm based on our strategy [9] straightforward; Step 5: Based on the loop invariant, transform the Radl algorithm and algorithm specification to the Apla program and program specification mechanically; Step 6: Automatically transform the Apla program to one or more executable language programs, say, Java, C++, C#, etc. In step3 in order to formally derive the algorithm to get problem recurrences, we should apply below derivation rules, which be used in the next part. Let q be an associative and commutative binary operator. Q be the quantifier of operator q, then Q(i: r(i):f(i)) Means ‘the quantity of f(i) where i ranges over r(i)’. We write the quantifier of binary operator +, *, , , min, max, ∩,

∧ ∨



as Σ, Π , ∀ , ∃, MIN, MAX,∩,∪ L1. Cartesian : Q( i, j: r(i) s(i,j): f(i,j))= Q(i: r(i): Q(j: s(i,j): f(i,j))) L2. Range Splitting: Q(i : r(i): f(i))= Q(i: r(i) b(i): f(i))q Q(i: r(i) ┐b(i): f(i)) L3. Singleton Splitting: Q(i : i=k: f(i))=f(k) L4.Range Disjunction: Q(i: r(i) s(i): f(i))=Q(i: r(i):f(i)) q Q(i: s(i): f(i)) L5.Generalized Associativity and Commutativity: Q(i: r(i): s(i)q f(i))= Q(i: r(i): s(i))q Q(i: r(i): f(i))









2.2 Dioid and General Single-Source Path Problems

⊕⊙

Dioid< S, , , θ, I > is a commutative and idempotence closed simiring, which originally rooted in the work of Kleene [10]. In this part, we firstly give the

30

C. Wang and J. Xue

definition of dioid, and then discuss the relationship between the dioid and general single-source path problems; furthermore we give some examples of dioid. Definition 1. A semiring is a set S equipped with two binary operations ⊕ and ⊙, called addition and multiplication, and two constant elements θ and I , such that: 1 is a commutative monoid with identity element θ, that is for all a, b, c ∈ S (a⊕b) ⊕c =a⊕(b ⊕ c) a⊕b =b⊕ a a⊕θ =θ ⊕a =a 2 is a monoid identity element I, that is for all a, b, c∈ S (a⊙b) ⊙c =a ⊙(b ⊙ c) a⊙I=I⊙a =a 3 Multiplication distributes over addition that is for all a, b, c∈ S (a⊕b) ⊙c=(a⊙ c)⊕ (b ⊙c) c⊙(a ⊕b) =(c⊙a)⊕(c ⊙b) 4 θ annihilates S, that is for all a ∈ S a⊙θ =θ ⊙a =θ











Definition 2. A closed semiring is a semiring with two additional properties: 1.

2.

If a 1,a2,a 3,…,an is sequence of elements of S, then a 1⊕a 2⊕a3 ⊕…an exists and is unique; combinableness, commutativity and idempotence are established to countable infinite sums; The operation ⊙ distributes over countable infinite sums as well as finite sums, that is

⊕(i:0≤i≤+∞:a ) ⊙⊕(j:0≤j≤+∞:b )=⊕(i,j:0≤i, j≤+∞:a ⊙b ) i

i

i

i

Definition 3. A Dioid or path algebra is a closed semiring with two additional properties: Operation ⊙ is commutative ,that is for all a, b∈ S, a⊙ b =b ⊙ a Operation ⊕ is idempotent, that is for all a ∈ S,a⊕ a =a Although the properties of dioid are very abstract but it can relate to general single-source path problems. In order to illustrate their relationship, we firstly give general single-source path problems. Given a directed connected graph G=(V, E, C), in which V is the set of vertex, E is the set of edges, C is the set of the “length” of each edge, s in V is specified as the source. Suppose #V =n, and each vertex is numbered by j, 1≤j≤n. Let set C be stored in adjacent matrix C(1:n, 1:n) and C(i, j) denotes the “length” of edge(i, j). If there is no edge between s and t, the value of C(s, t) is θ. Let PATH(s, t) denotes the set of all single-source paths between vertex s and t, length(p) denotes the “length” of path p, cost(s, t) denotes the cost between vertex s and t, that is:

Formal Derivation of a High-Trustworthy Generic Algorithmic Program

cost(s, t)=

31

⊕(p: p∈PATH(s, t): length(p))

length(p)=

⊙(: ∈p: C(i, j))

The general single-source path problem is to determine cost of paths from the source s to each vertex t, t V. As for as the above problem, since the order of path addition is no matter, the operation should satisfy associativity and commutativity. And if a path p exists, its cost is length(p), or else its cost is θ. In a similar way, the order of path multiplication is no matter, so the operation also should satisfy associativity and commutativity. And if an edge exists, its cost is C, or else its cost is I. Obviously, length(p) length(p)=length(p), so the operation also should satisfy idempotence. Considering a path may not be simple path (ie. exists cycle). Then a graph may have numerous paths, so the operation ⊕ should apply to the situation of numerous paths. That is to say, if a 1, a 2, a 3,…,a n is sequence of elements of S, then a 1 ⊕a 2 ⊕a 3 ⊕ …a n exists and is unique. Since the order in which the various elements added is irrelevant, associativity and commutativity are established to countable infinite sums. Obviously, length(p) ⊕ length(p) ⊕ … ⊕ length(p)=length(p), so idempotence are established to countable infinite sums. To computing divergence paths, we require that operation ⊙ distributes over ⊕. As a graph may have numerous paths, operation ⊙ should distribute over countable infinite sums as well as finite sums. Based on the definition, it is easy to verify following algebra structures are dioid: 1) S1 = (R +∞, min, +, +∞, 0) 2) S2 = ({0, 1}, , , 0, 1) 3) S3 = (R -∞ +∞, max, min,-∞, +∞)











⊕⊙ ∪ ∨∧ ∪ ∪

3 Derivation a Generic Algorithm Program Base on the properties of dioid, we can derive a generic algorithmic program for solving general single-source path problem, which is to determine the cost of paths from the source s to each vertex t, t V. The problem specification can be AQ: Given directed graph G=(V, E, C) with edges having negative length, but having no cycles of negative length, s V is a source, is a dioid.



AR: ∀(t: t



⊕⊙

∈V: cost(s, t)=⊕(p: p∈PATH(s, t): length(p))) length(p)= ⊙(: ∈p : C(i,j))

32

C. Wang and J. Xue

Let PATH_E(s, t, j) denote the set of all path from the source s to t each of which has j edges. Since each path has at most n-1 edges, then the range of j is 1≤j≤n-1. We have: (1) PATH_E(s, t) =∪(j: 1≤j≤n-1: PATH_E(s, t, j)) And (2) cost(s, t)

⊕(p: p∈PATH(s, t): length(p)) =⊕(p: p ∈∪(j: 1≤j≤n-1: PATH_E(s, t, j)): length(p)) =⊕(j: 1≤j≤n-1:⊕(p: p ∈PATH_E(s, t, j): length(p)))

=

{(1)} { L4.Range Disjunc-

tion}

⊕(j: 1≤j≤n-2:⊕(p: p∈PATH_E(s, t, j): length(p))) ⊕ ⊕ (p: p ∈ PATH_E(s,t,n-1): length(p)) { L2. Range Splitting and L3. Sin-

=

gleton Splitting} let

(3) incost k(s, t)= then (4) cost(s,t) =

⊕(j: 1≤j≤k:⊕(p: p∈PATH_E(s, t, j): length(p)))

⊕(j: 1≤j≤n-1: ⊕(p: p∈PATH_E(s, t, j): length(p)))

{2}

=incostn-1 (s, t) {3}

⊕(p: p∈PATH_E(s,t,n-1): length(p))) (s, t),⊕(x: x ∈into(t): incost (s, x)⊙ C(x, t)))

=⊕(incost n-2(s, t), =⊕(incost n-2

n-2

{Suppose set into(t) contains tails of edges into vertex t} Let k, 1≤k≤n-1, replace n-1 in (4), we have the following lemma: Lemma 1. incost k(s, t)= ⊕(incost k-1(s, t),

⊕(x: x∈into(t): incost

k-1 (s,

x)⊙ C(x, t)))

Let function edges(p) compute the number of edges in path p and let Maxedges(s, t) = MAX(p: p p ∈PATH(s, t): edges(p)) Considering definition (3), since incost k(s, t) contains the cost of paths that have at most k edges, therefore, if each path in set PATH(s,t) has at most k edges, then incost k(s, t) contain the cost from s to t. So we have

Formal Derivation of a High-Trustworthy Generic Algorithmic Program

33

Lemma 2. If each path in set PATH(s, t) has at most k edges, then cost(s,t)=incost k(s, t) So, if incost k(s, t) reaches its low bound cost(s,t), the algorithm should keep it never be changed. Lemma 1 and Lemma 2 show us a strategy for solving the problem that is to compute the cost in increasing order of at most number of edges of each path in PATH (s, t). That is to maintain the following algorithm invariant:

∀(t: t∈V: incostk(s, t) has been computed) ∧1≤k≤n-1 AI2: ∀(t: t∈ V: maxedges(s, t)≤k =>cost(s, t) has been computed) AI1:

For computing incost k(s, t), the initial value of incost k-1 (s, t) is needed. So we have Initialization: C(j, j))

∀(t: t∈V∧s≠t: incost0(s, t)=C(s, t))∧∀(j: 1≤j≤n: incost0(j, j)=I⊕

Based on algorithm invariant I1, I2 and Lemma 1, Lemma2 and Initialization, we describe the generic algorithm with Radl as follows: ALGORITHM: General single-source path problem |[ k: 1:n; s, t, x: vertex; V: set(vertex, n); d: array(1:n, S) C: array([1:n,1:n], S);]| {AQ; AR}

; BEGIN: k=1 ∧ ∀(t: t ∈ V ∧ s≠t: incost 0(s, t)=C(s, t)) ∧ ∀(j: 1≤j≤n: incost (j, j)=I⊕C(j, j)) TERMINATE: k= |V| {AI1 ∧AI2} RECUR: LET ∀(t: t ∈ V: incost k-1(s, t)= ⊕ (incostk-1(s, t), ⊕(x: x∈into(t): incost k-1(s, x)⊙C(x, t))) 0

END Then, let incost k (s, t) store in array element d(t), we can transform the Radl algorithm with specification and invariant into corresponding Apla program straightforward as follows: PQ: Given directed graph G=(V, E, C) with edges having negative length, but having no cycles of negative length, s V is a source, is a dioid.



∀(t: t∈V: d(t)= incostk (s, t)) LI1: ∀(t: t ∈ V: d(t)=incost k (s, t)) ∧1≤k≤n-1 LI2: ∀(t: t ∈ V: maxedges(s, t)≤k =>d(t)=cost(s, t))

⊕⊙

PR:

PROGRAM: General single-source path problem {PQ; PR} var k: 1:n; t, x, y: vertex; V: set(vertex, n); d: array(1:n, S) C: array([1:n,1:n], S); k:=1;



34

C. Wang and J. Xue



Foreach y: y V: do d(y):=C(s, y) od; Foreach j: 1≤j≤n: do d(j):=I C(j, j) od; {LI1 LI2}





do k≠n -> Foreach t: t



∈ V:

do d(t)=

⊕ (d(t), ⊕ (x: x ∈

into(t): d(x) C(x, t))) od; k:=k+1 od Obviously, the above algorithm computational complexity is O (|V|*|E|).

4 Instantiation of Three Typical Algorithms Based on above generic algorithmic program, several famous path algorithmic programs can be generated easily if their preconditions satisfy the conditions of dioid. Following are 3 typical examples: 4.1 Example 1. Bellman-Ford Single-Source Shortest Path Algorithm Program Single-source shortest path problem: Given a directed connected graph G=(V, E, C), in which V is the set of vertex, E is the set of edges, C is the set of the length of each edge, s in V is specified as the source. The single-source shortest path problem is to determine the distance of the shortest path from the source s to each vertex t, t V, denoted by mindis(s,t). Suppose #V =n, and each vertex is numbered by j, 1≤j≤n. Let set C be stored in adjacent matrix C(1:n, 1:n) and C(i, j) denotes the length of edge(i, j). If there is no edge between s and t, the value of C(s, t) is +∞. Let PATH(s, t) denotes the set of all single-source paths between vertex s and t, length(p) denotes the length of path p. The algorithm specification can be AQ1: Given directed graph G=(V, E, C) with edges having negative length, but having no cycles of negative length, s V is a source. AR1: ∀(t: t V: mindis(s, t) = MIN (p: p PATH(s, t): length(p)))











length(p)= Σ (: p : C(i, j)) According to the analysis to the problem and its specification, we regard MIN Σ as , then Single-source shortest path problem is corresponded to dioid S1 = ( R +∞, min, +, +∞,0). We replace dioid of above generic program by S 1= (R +∞, min, +, +∞, 0). Therefore, we get Bellman-Ford single-source shortest path algorithm program.

、 ⊕、⊙ ∪



⊕⊙

PROGRAM: Bellman-Ford {PQ;PR} var k: 1:n; t, x, y: vertex; V: set(vertex, n); d: array(1:n, R +∞) C: array([1:n,1:n], R +∞); k:=1;

∪ ;



Formal Derivation of a High-Trustworthy Generic Algorithmic Program



Foreach y: y V: do d(y):=C(s, y) od; Foreach j: 1≤j≤n: do d(j):=0 od; {LI1 LI2} do k≠n -> Foreach t: t V: do d(t)= min(d(t),MIN(x: x into(t): d(x)+C(x, t))) od; k:=k+1 od





35



4.2 Example 2. Reachability Problem Algorithmic Program Reachability problem: Given a directed connected graph G=(V, E, C), in which V is the set of vertex, E is the set of edges, C is the set of the length of each edge, s in V is specified as the source. The graph reachability problem is to judge whether there has a connected path from the source s to each vertex t, t V, denoted by isconnectpath(s,t). Let PATH(s, t) denotes the set of all single-source paths between vertex s and t, isconnect(p) denotes whether p is connect path. The algorithm specification can be AQ2: Given directed graph G=(V, E, C) with edges having negative length, but having no cycles of negative length, s V is a source.









AR2: ∀(t: t V: isconnectpath(s, t) = ∃ (p: p PATH(s, t): isconnet(p))) isconnect(p)= ∀ (: p : C(i, j)) According to the analysis to the problem and its specification, we regard



、∀ as⊕、⊙, then Reachability problem is corresponded to dioid S =( {0,1}, ∨, ∧, 0, 1). We replace dioid of above generic program by S = ( {0,1},∨ , ∧,0,1). Therefore, we get Reachability problem algorithmic program. ∃

2

2

PROGRAM: Reachability {PQ;PR} var k: 1:n; t, x, y: vertex; V: set(vertex, n); d: array(1:n, {0,1}) C: array([1:n,1:n], {0,1}); k:=1; Foreach y: y V: do d(y):=C(s, y) od; Foreach j: 1≤j≤n: do d(j):=1 od; {LI1 LI2} do k≠n -> Foreach t: t V: do d(t)= d(t) ∃ (x: x into(t): d(x) C(x, t)) od; k:=k+1 od















4.3 Example 3. Bottleneck Problem Algorithmic Program Bottleneck problem: A high load has to be driven from x to y and on each possible route several low bridges have to be negotiated. The problem is to compute a route

36

C. Wang and J. Xue

that maximizes the height of the lowest bridge on the route. This problem can be modeled as a graph-searching problem as follows: Given a directed connected graph G=(V, E, C), in which V is the set of vertex, E is the set of edges, C is the set of the length of each edge, s in V is specified as the source. The bottleneck problem is to compute the minimum bridge height on a route from the source s to each vertex t that maximizes the minimum bridge height, which denoted by minbridge(s,t). Let PATH(s, t) denotes the set of all single-source paths between vertex s and t, leastbridge(p) denotes the least bridge height on a path p. The algorithm specification can be AQ3: Given directed graph G = (V, E, C) with edges having negative length, but having no cycles of negative length, s V is a source. AR3: ∀(t: t V: minbridge(s, t) = MAX (p: p PATH(s, t): leastbridge(p))) leastbridge(p)= MIN (: p : C(i,j)) According to the analysis to the problem and its specification, we regard MAX

∈ ∈ ∈





⊕、⊙, then Bottleneck problem is corresponded to dioid S =(R∪-∞∪+∞,

MIN as

⊕⊙

3

max, min,-∞, +∞). We replace dioid of above generic program by S3= (R -∞ +∞, max, min,-∞, +∞). Therefore, we get bottleneck problem algorithmic program.

∪ ∪

PROGRAM: Bottleneck {PQ;PR} var k: 1:n; t, x, y: vertex; V: set(vertex, n); d: array(1:n, R -∞ +∞) C: array([1:n,1:n], R -∞ +∞); k:=1; Foreach y: y V: do d(y):=C(s, y) od; Foreach j: 1≤j≤n: do d(j):= +∞ od; {LI1 LI2} do k≠n -> Foreach t: t V: do d(t)= max(d(t),MAX(x: x into(t): min(d(x),C(x, t)))) od; k:=k+1 od





∪ ∪ ; ∈

∪ ∪



5 Comparison with Related Works Aho, Hopcroft and Ullman[11] described a generic algorithm using closed semiring for solving general all-pairs path problems. Tarjan[12] solved general path problem based Gauss elimination method, using linear equations. Roland C.Backhouse[13] derived a generic algorithm of general single-source path problem based on algebra of regular languages, using array. A.Boulmakout[14] used a generic algorithm to solve general single-source path problem base on fuzzy graph. We attempt to derive a generic algorithm for solving general single-source path problems according formal transformation, and using a set of suitable notations of graph.

Formal Derivation of a High-Trustworthy Generic Algorithmic Program

37

It is a common case that most of literatures of algorithm design and analysis do not give a restrict derivation or convincing proof to show how the ingenious algorithm comes out. Only a few textbooks start to pay attention to this issue and give proofs of some algorithms by introducing loop invariants [15] or least fixed point [16]. Many formal methods can verify algorithms afterwards, such as Hoare axiom method [17]; or design and verify algorithms hand in hand, such as Dijkstra’s weakest precondition [18], VDM[19], Z[20], B[21], Smith’s Designware [22], etc. These formal methods cannot derive logically intricate and ingenious algorithms (especially named with people name), but only can verify algorithms. Our approach pays special attention to algorithm derivation from problem specification. In paper [23], we derive formally a generic algorithmic program for solving general all-pairs path problems. Some typical graph algorithms, such as Floyd’s shortest path algorithm, Warshall’s graph transitive closure algorithm, Longest path algorithm, etc. are all instances of the generic algorithmic program. This paper dedicates to formal derivation of a generic algorithmic program for solving general single-source path problems.

6 Conclusion and Prospect We derived a high-trustworthy generic algorithmic program for solving general single-source path problems in a short article. The main ideas and ingenuity of the algorithm, which are represented by lemma, are revealed by formula deduction. These are very useful in understanding how these ingenious algorithms are designed. According to our approach, the correctness, reliability, safety and development efficiency of algorithmic programs are improved greatly. It is expected to be a promising approach to develop high-trustworthy generic algorithmic program. Three points are deserved to summarize as follows: 1) We use Radl represent specification, transformation rules and algorithm has two peculiar characteristics: mathematical transparency and suitable notation. In the case of this paper, algorithm represented by recurrences and initialization which has mathematical transparency, it is easy for formal derivation [24-25]. And it is a very important technique to develop adequate suitable notations. We present some notations to represent graph, algorithm specification and algorithm invariant, which made the formal derivation of graph algorithm possible and simple. It can greatly improve the correctness and reliability of algorithmic program. 2) The properties of dioid satisfy the condition of the transformation rules of quantifier. This makes formal derivation of the generic algorithmic program possible. In the instantiation phase, the properties of dioid restrict which concrete dioid can replace the abstract dioid, ie. , which concrete type and operation parameters can replace abstract type and operation parameters. That is more semantic restriction than syntax restriction to type and operation parameters. It can significantly guarantee the safety of final algorithmic program.

38

C. Wang and J. Xue

3) Abstracting common characteristics of a class of problems into certain algebra structure and make it generic. Then through formal derivation, generic algorithmic program is more commonality and can be reused in many domains. The prospect emerges that algorithm development paradigm will shift a single one every time into a batch every time. It greatly improved the development efficiency of algorithmic programs. Ongoing effects include finding common characteristics of analogy algorithms that isolate in many literatures, and abstracting them into suitable algebra structure. In fact, besides dioid in this paper, we also have found other such algebra structures, such as semigroup, permutation group, cycle permutation group, generated group, semiring, closed semiring, etc. Then we can formally derive more high-trustworthy generic algorithmic program for general problems. Acknowledgments. The work was partially supported by the National Natural Science Foundation of China under Grant (No.60573080, No.60773054), National Grand Foundation Research 973 Program under Grant No. 2003CCA02800, International Science & Technology Cooperative Program under Grant No. 2008DFA11940 of China, Project of the Education Department of Jiangxi Province under Grant No.GJJ09461.

References 1. Hoare, T.: The Verifying Compiler: A Grand Challenge for Computing Research. J. of the ACM 50(1), 63–69 (2003) 2. Hoare, T., Misra, J., Shankar, N.: The IFIP Working Conference on Verified Software: Theories, Tools (2005) 3. The IFIP Working Conference on Verified Software: Theories, Tools, Experiments. Zurich (2005) 4. 1st Asian Working Conference on Verified Software, Macao (2006) 5. High Confidence Software and System Coordinating Group. High Confidence Software and Systems Research Needs, USA (2001) 6. High confidence Medical Device Software and Systems (HCMDSS) Workshop, Philadelphia, June 2-3 (2005) 7. Xue, J.: A Unified Approach for Developing Efficient Algorithmic Programs. Journal of Science and Technology 12, 103–118 (1997) 8. Xue J.: A Practicable Approach for Formal Development of Algorithmic Programs. In: Proceedings of ISFST 1999. Published in Software Association in Japan, 158–160 (1999) 9. Xue, J.: Two New Strategies for Developing Loop Invariants and its Applications. Journal of Computer Science and Technology 8, 95–102 (1993) 10. Kleene, S.: Representation of events in nerve nets and finite automata. In: Shannon, McCarthy (eds.) Automata Studies, pp. 3–40. Princeton Univ. Press, Princeton (1956) 11. aho, A.V., Hopcroft, J.E. (eds.): The Design and Analysis of Computer Algorithms. Addison-Wesley Longman Publishing Co, Inc., Boston (1974) 12. Tarjan, R.E.: A unified approach to path problems. Journal of the Association for Computing Machinery 28, 577–593 (1981)

Formal Derivation of a High-Trustworthy Generic Algorithmic Program

39

13. Backhouse, R.C., Eijnde, van Gasteren, A.J.M.: Calculating path algorithms. Science of Computer Programming 22, 3–19 (1994) 14. Boulmakoul, A.: Generalized path-finding algorithms on semirings and the fuzzy shortest path problem. J. of Computational and Applied Mathematics 162(1), 263–272 (2004) 15. Corman, T.H., Lieserson, C.E., Rivest, R.L.: Introduction to Algorithms. Prentice Hall India (1990) 16. Baase, S., Van Gelder, A.: Computer Algorithms: Introduction to Design and Analysis, 3rd edn. Addison-Wesley, Reading (1999) 17. Hoare, C.A.R.: An Axiomatic Basis for Computer Programming. Commun. ACM 12(10), 576–580 (1969) 18. Dijkstra, E.W.: A discipline of programming. Prentice Hall, Englewood Cliffs (1976) 19. Jones, C.B.: Systematic software development using VDM. Prentice Hall International Ltd., Hertfordshire (1986) 20. Davies, J., Woodcock, J.: Using Z: Specification, Refinement and Proof. Prentice Hall International Series in Computer Science. ISBN 0-13-948472-8 (1996) 21. Schneider, S., Palgrave: The B-Method: An Introduction. Cornerstones of Computing series (2001) 22. Smith, D.R.: Designware: software development by refinement. In: Proc. of the 8th Int’l Conference on Category Theory and Computer Science (CTCS 1998), Edinburgh, pp. 3–21 (1999) 23. Jinyun, X.: Developing the Generic Path Algorithmic Program and Its instantiations Using PAR Method. In: Proceedings of The Second Asian Workshop on Programming Languages, KAIST, Korea (2001) 24. yun, X.J., Davis, R.: A Derivation and Proof of Knuth’ Binary to Decimal Program. Software—Concepts and Tools, 149–156 (1997) 25. yun, X.J.: Formal Development of Graph Algorithmic Programs Using Partition-and-Recur. Journal of Computer Sciences and Technology 13(6), 143–151 (1998)

Improved Algorithms for Detecting Negative Cost Cycles in Undirected Graphs Xiaofeng Gu1 , Kamesh Madduri2,⋆ , K. Subramani3,⋆⋆ , and Hong-Jian Lai1 1

Department of Mathematics, West Virginia University, Morgantown, WV [email protected], [email protected] 2 Computational Research Division, Lawrence Berkeley National Laboratory, Berkeley, CA [email protected] 3 LDCSEE, West Virginia University, Morgantown, WV [email protected]

Abstract. In this paper, we explore the design of algorithms for the problem of checking whether an undirected graph contains a negative cost cycle (UNCCD). It is known that this problem is significantly harder than the corresponding problem in directed graphs. Current approaches for solving this problem involve reducing it to either the b-matching problem or the T -join problem. The latter approach is more efficient in that it runs in O(n3 ) time on a graph with n vertices and m edges, while the former runs in O(n6 ) time. This paper shows that instances of the UNCCD problem, in which edge weights are restricted to be in the range {−K · ·K} can be solved in O(n2.75 · log n) time. Our algorithm is basically a variation of the T -join approach, which exploits the existence of extremely efficient shortest path algorithms in graphs with integral positive weights. We also provide an implementation profile of the algorithms discussed.

1

Introduction

In this paper, we design and analyze algorithms for the problem of detecting a negative cost cycle in weighted, undirected graphs (UNCCD). Although UNCCD is in P, it is much harder than the corresponding problem in directed, weighted graphs. Indeed, approaches for this problem in the paper use variants of weighted matching in non-bipartite graphs. On an undirected, arbitrarily weighted graph ⋆

⋆⋆

This work was supported in part by the U.S. Department of Energy under Contract No. DE-AC02-05CH11231. This research was supported by the Air-Force Office of Scientific Research under contract FA9550-06-1-0050.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 40–50, 2009. c Springer-Verlag Berlin Heidelberg 2009 

Improved Algorithms for Detecting Negative Cost Cycles

41

G = V, E, c, with n vertices and m edges, the b-matching approach runs in time O((m + n)3 = n6 ), and the T -join approach runs in time O(n3 ). This paper focuses on the case in which edge weights are integers in the range {−K · ·K}, where K is a fixed constant. We show that in this special case, the running time can be improved to O(n2.75 · log n), which is an improvement over the previous bound for sparse graphs. We also provide a detailed implementation profile of the algorithms discussed in this paper. The rest of this paper is organized as follows: Section 2 describes the preliminaries and notations that will be used in the paper. Section 3 reviews the b-matching technique and applies it to the UNCCD problem. Section 4 describes the T -join approach; this technique is then specialized to the case in which the edge weights are integers in the range {−K · ·K}. We discuss implementation performance results in Section 5. We conclude in Section 6 by summarizing our contributions and discussing avenues for future research.

2

Preliminaries

Definition 1. For an undirected graph G = V, E, |V | = n, and a mapping b : V (G) → N, we say that a subgraph H of G is a perfect b-matching if each node i has exactly b(i) incident arcs in H.

Fig. 1. Examples of perfect b-matchings

Fig. 2. Examples of perfect matchings

For example, an undirected graph G is shown in Figure 1(A). Figure 1(B) shows a perfect b-matching in G when b : (v1 , v2 , v3 , v4 ) → (1, 3, 2, 2). If b(v) = 2 ∀ v ∈ V (G), then we call it a perfect 2-matching. Figure 1(C) shows a perfect 2-matching in G. Notice that a perfect 2-matching in G is just a Hamiltonian cycle or a set of disjoint cycles that cover all the vertices in V (G).

42

X. Gu et al.

When b(v) = 1 ∀ v ∈ V (G), it is a perfect matching in G. In Figure 2, both examples (A) and (B) are perfect matchings in G. If graph G is weighted, we may consider the problem of finding a minimum perfect b-matching in G, which is closely related to the UNCCD problem. We will show this in Section 3. Definition 2. Given an undirected graph G = V, E and a set T ⊆ V (G) of even cardinality. A set J ⊆ E(G) is a T -join if, |J ∩ δ(x)| is odd if and only if x ∈ T , where δ(x) is the set of edges incident with x.

Fig. 3. Examples of T -joins

In Figure 3, we have an undirected graph G. Given T = {v2 , v4 }, J1 = {e4 } is a T -join in G. J2 = {e3 , e5 } is also a T -join. When T = ∅, J3 = {e1 , e2 , e4 , e5 } and J4 = {e3 , e4 , e5 } are two possible ∅-joins. Notice that J = ∅ is always a ∅-join. An ∅-join is an edge set of some cycles in G or just ∅. If graph G is weighted, we may consider the problem of finding a minimum cost T -join in G, which is also related to the UNCCD problem when T = ∅. We will show this in Section 4. Definition 3. Given a graph G with weights c : E(G) → R and no negative ¯ with weights c¯, where G ¯ is the cycles. The metric closure of G is a graph G simple graph on V (G) that, for x, y ∈ V (G) with x = y, contains an edge e = (x, y) with weight c¯(e) equal to the shortest distance from x to y in G if and only if y is reachable from x in G.

3

UNCCD Algorithm Based on b-matching

Algorithm 1 describes a b-matching method to solve the UNCCD problem. Before proving the correctness of Algorithm 1, some useful lemmas and theorems are introduced. Lemma 1. There is a perfect b-matching Mb in G′ with negative cost, if and only if G contains a negative cycle C, and c(C) = c(Mb ). Proof: Notice that b(i) = 2, for i = 1, 2, . . . , n, and there is a loop (i, i) with zero cost for each node i. So, there always exists a perfect b-matching with zero

Improved Algorithms for Detecting Negative Cost Cycles

43

UNCCD Algorithm based on b-matching Input: An undirected graph G with edge costs c : E(G) → R. Objective: Find a negative cycle. 1. Construct a graph G′ by adding a loop (i, i) of zero cost for each node i ∈ V (G). Construct the perfect b-matching with b(i) = 2 for i = 1, 2, . . . , n in the resulting graph G′ . 2. Insert two additional nodes, say nodes k and l, in the middle of each arc (i, j), i = j. We set b(k) = b(l) = 1 and edge cost cik = clj = cij /2 and ckl = 0. Let G′′ denote the resulting graph. 3. Construct a third graph G′′′ from G′′ by splitting each node i with b(i) = 2 into two nodes i′ and i′′ . For each arc (i, j) in G′′ , we introduce two arcs (i′ , j) and (i′′ , j) with the same cost as (i, j). loop (i, i) convert to (i′ , i′′ ). 4. Find a minimum perfect matching M in G′′′ . If c(M ) < 0, then the original graph G has a negative cycle. Algorithm 1. UNCCD Algorithm based on b-matching cost. If there are no negative cost cycles in G, then the b-matching of zero cost is minimum. If there is a negative cost cycle C in G, then  there must be a perfect b-matching Mb with negative cost, and c(Mb ) = c(C) + i∈C / c((i, i)) = c(C).✷ Now we construct the equivalence of b-matchings in G′ and G′′ by (a) (i, j) in a b-matching Mb′ in G′ ⇔ (i, k) and (l, j) in a b-matching Mb′′ in G′′ . (b) (i, j) ∈ / Mb′ ⇔ (k, l) ∈ Mb′′ . Lemma 2. The equivalence between Mb′ and Mb′′ is well-defined, and so Mb′ and Mb′′ are equivalent. Lemma 3. A perfect b-matching Mb′′ in G′′ ⇔ a perfect matching M in G′′′ .

Proof: Notice that ∀ (p, q) ∈ E(G′′ ), either b(p) = 1 or b(q) = 1. Each node i with b(i) = 2 is split into two nodes i′ and i′′ . For each (i, j), b(j) = 1(because b(i) = 2), and so any perfect matching in G′′′ will contain at most one of the arcs (i′ , j) and (i′′ , j), corresponding to (i, j) ∈ Mb′′ . ✷ 3.1

Correctness and Analysis

Algorithm 1 solves the undirected negative cost cycle detection problem. We can reduce this to an instance of the shortest paths problem in an undirected network [1]. From Lemma 1, 2, and 3, we know that there is a negative cost cycle in G if and only if there is a perfect matching with negative cost in G′′′ . So the algorithm terminates with a minimum perfect matching M in G′′′ . If c(M ) < 0, there is a negative cycle in G. If c(M ) > 0, then we declare that there is no negative cycle in G. Theorem 1. The UNCCD Algorithm based on b-matching can be solved in O(n6 ) time.

44

X. Gu et al.

Proof: From [2], we know that the Minimum Perfect Matching Algorithm on 3 G′′′ runs in O(|V (G′′′ )| ) time. G has n nodes and m arcs, and from the con′ ′′ struction of G , G , and G′′′ , each node in G is split into two nodes in G′′′ . Also, for each arc in G, there are two nodes in G′′′ . So, |V (G′′′ )| = 2(m + n). Therefore, the running time of the algorithm is O((m + n)3 ). As for the simple . Hence the total running time is O(n6 ). ✷ graph, m ≤ n·(n−1) 2

4

UNCCD Algorithm Based on T -join

Notice that when T = ∅, a T -join in a graph G is exactly an edge set of some cycles in G, or just ∅. We have the following lemma. Lemma 4. There is a negative cycle in G if and only if there exists an ∅-join with weight < 0. Thus, in order to determine if the graph has negative cycles, we need to find a minimum weight T -join when T = ∅. Lemma 5. Let G be a graph, c : E(G) → R+ , and T ⊆ V (G) such that |T | is even. Every optimum T -join in G is the disjoint union of the edge sets of |T2 | paths, whose ends are distinct and in T . According to this lemma, the minimum weight T -join problem can be solved in the case of non-negative weights. Minimum weight T -join problem with non-negative weights Input: An undirected graph G, weight c : E(G) → R+ , and a set T ⊆ V (G) with even cardinality. Objective: Find a minimum weight T -join in G. 1. Solve an All pairs shortest paths problem in (G, c). 2. From the output of the All Pairs Shortest Paths problem, construct the ¯ c¯). metric closure (G, ¯ ], c¯). 3. Find a minimum weight perfect matching M in (G[T 4. Consider the shortest x-y-path in G for each edge (x, y) ∈ M . Let J be the symmetric difference of the edge sets of all these paths. Then J is optimum. Algorithm 2. Minimum weight T -join problem with non-negative weights Theorem 2. The minimum weight T -join problem with non-negative weights can be solved in O(n3 ) time. Proof: Steps 1 and 2 (which require all-pairs shortest paths) can be executed in O(n3 ) time. Step 3, Minimum Weight perfect matching, can be solved in O(m′ · n + n2 · log n) time using Gabow’s algorithm [2,3], where m′ is the number ¯ ], c¯), which is O(n2 ). Hence, the total running time is O(n3 ). ✷ of edges in (G[T

Improved Algorithms for Detecting Negative Cost Cycles

45

This method no longer works if we allow negative weights. However, we next show that the minimum weight T -join problem with arbitrary weights can be reduced to that with non-negative weights. Theorem 3. Let G be a graph with weights c : E(G) → R, and T ⊆ V (G) with |T | even. Let E − be the set of edges with negative weights, T − the set of vertices that have an odd number of negative weighted edges incident on them, and d : E(G) → R+ : d(e) = |c(e)|. Then J is a minimum c-weight T -join if and only if J △ E − is a minimum d-weight (T △ T − )-join, where △ means the symmetric difference. Proof: Please refer to [2].



Corollary 1. J is a minimum c-weight ∅-join if and only if J △ E − is a minimum d-weight T − -join. Because d ≥ 0, we can find a minimum d-weight T − -join J ′ through the above algorithm. According to Theorem 3, there must be a c-weight ∅-join J such that J ′ = J △ E − . So J = J ′ △ E − is the minimum weight ∅-join. UNCCD Algorithm based on T -join Input: An undirected graph G with edge costs c : E(G) → R. Objective: Find a negative cycle in G. 1. Let E − be the set of edges with negative cost, T − the set of vertices that are incident with an odd number of negative edges, and graph Gd with edge costs d : E(Gd ) → R+ : d(e) = |c(e)|. 2. Implement Algorithm 2 on Gd with edge costs d to find the minimum T − -join J ′. 3. We state J = J ′ △ E − is a ∅-join of G. 4. if c(J) < 0 then 5. There is a negative cycle formed by some edges in J. 6. else 7. There is no negative cycle in G. 8. end if Algorithm 3. UNCCD Algorithm based on T -join 4.1

Correctness and Analysis

Algorithm 3 describes the method of T -join to solve the UNCCD problem. From Lemma 4, we know that to detect a negative cycle, we just need to find a ∅-join with negative cost. Then, from Theorem 3, we can reduce ∅-join with arbitrary costs in G to a T − -join with non-negative costs in Gd . The algorithm terminates with a minimum perfect matching M in G¯d [T − ]. From the construction of the graph G¯d , each arc (x, y) in M is a shortest path from x to y in Gd . So, M corresponds to a union of edge sets (each shortest path

46

X. Gu et al.

is an edge sets) in G. Let J be the symmetric difference of all these edge sets. Then, J ′ be the minimum T − -join in Gd . From Theorem 3, we know that the minimum ∅-join J = J ′ △ E − according to J ′ = J △ E − . Theorem 4. The UNCCD Algorithm based on T -join can be solved in O(n3 ) time. 4.2

A Special Case of UNCCD

Now we consider a special case of the UNCCD problem where integer weights belong to ∈ {−K ··K}, where K is a positive integer. According to Algorithms 2, 3 and Theorems 2, 4, we know that the running time of the T -join approach is mainly dominated by the time for all pairs shortest path problem with nonnegative weights, and the minimum perfect matching problem. Currently, O(m · n + n2 · log n) is the best time bound for the shortest path problem with non-negative weights in undirected graphs, as well as the minimum perfect matching problem. When the edge weights are integers, however, we can use faster algorithms. For all pairs shortest paths problem with integer weights in undirected graphs, ˜ an O(N · n2.38 ) time bound algorithm was described by Shoshan and Zwick in ˜ (n)) is the abbreviation for O(f (n) · (log n)t ) for some constant t [4], where O(f and N is the largest edge weight in the graph. As for minimum perfect matching with integer weights, Gabow presents an 3 O(n 4 m log N ) in [5] by scaling techniques, where N is the largest edge weight in the graph. So, we can still use the T -join approach. The only difference is that now edge weights are integers ranging in {−K · ·K}. The algorithm is described as follows. Theorem 5. UNCCD problem with integer weights ∈ {−K · ·K} can be solved in O(n2.75 · log n) time. Proof: In Algorithm 4, step 2, all pairs shortest path problem in (G, d) can be ˜ computed in O(K · n2.38 ) = O(K · n2.38 · (log n)t ) time for a constant t. Step 3, ¯ needs O(n 34 · m′ · log N ) time, ¯ − ], d) minimum perfect matching problem in (G[T ¯ and m′ is the number of edges ¯ − ], d) where N is the largest edge weight in (G[T − ¯ 2 ¯ − ], d) ¯ corresponds ¯ in (G[T ], d), which is O(n ). We know that an edge in (G[T to a shortest path in (G, d), where d = |c| ≤ K and K is a positive integer constant. The number of edges in any shortest path in (G, d) is not more than n, 3 so N ≤ nK. So the total running time is O(K · n2.38 · (log n)t + n 4 · n2 · log nK). lim

K·n2.38 ·(log n)t 3

n→∞ n 4 ·n2 ·log nK

time.

5

= 0, and hence Algorithm 4 can be solved in O(n2.75 ·log n) ✷

Implementation

To empirically evaluate the performance of the T-join approach, we implement Algorithm 4 and experiment with networks from several different graph families.

Improved Algorithms for Detecting Negative Cost Cycles

47

UNCCD Algorithm with integer weights ∈ {−K · ·K} Input: An undirected graph G with edge weights c : E(G) → Z ∩ {−K · ·K}. Objective: Find a negative cycle in (G, c). 1. Let E − be the set of edges with negative cost, T − the set of vertices that are incident with an odd number of negative edges, and graph (G, d) with edge costs d(e) = |c(e)|. 2. Solve an All Pairs Shortest Paths Problem in (G, d). ¯ denote the metric closure of (G, d) and (G[T ¯ denote the ¯ d) ¯ − ], d) 3. Let (G, − ¯ ¯ subgraph of (G, d) induced by T . ¯ ¯ − ], d). 4. Find a minimum weight perfect matching M in (G[T 5. We consider the shortest x-y-path in (G, d) for each edge (x, y) ∈ M . Let J ′ be the symmetric difference of the edge sets of all these paths. Then J ′ is a minimum T − -join in (G, d). 6. We state J = J ′ △ E − is a ∅-join of (G, c). 7. if c(J) < 0 then 8. There is a negative cycle formed by some edges in J. 9. else 10. There is no negative cycle in (G, c). 11. end if Algorithm 4. UNCCD Algorithm with integer weights ∈ {−K · ·K} We report performance on a 2.4 GHz Intel Xeon Linux system with 4 MB L2 cache and 8 GB DRAM memory. We build our code with the GNU C compiler version 4.2.4 and the optimization flags -O3 -funroll-loops. Observe that the overall UNCCD running time is dominated by two steps: all pairs shortest paths (APSP) on the original graph, and minimum weight perfect matching (MWPM) on an induced subgraph of the graph closure. We reformulate the APSP computation as running n single-source shortest paths (SSSP), and use a fast SSSP implementation from the 9th DIMACS Challenge on shortest paths [6]. For MWPM, we modify an implementation of Gabow’s algorithm [7], the source code for which is freely available online [8]. We experiment with several graph families used in the DIMACS Implementation Challenge for the single-source shortest paths problem with arbitrary edge weights [6]. Specifically, we give performance results for four different families in this paper: – LMesh: We generate synthetic two-dimensional meshes with grid dimensions n and y = 10 for our experiments. The graphs are sparse with x and y. x = 10 m ≈ 2n. The diameter of these graphs is O(n). √ – SqMesh: Square meshes are fully-connected grids with x = y = √n. The graphs are sparse with m ≈ 2n. The diameter of these graphs is O( n). – SpRand: We generate graphs according to the Erdos-Renyi random graph model, and ensure that the graph is connected. The ratio of the number of edges to the number of vertices is set to 10 to generate sparse graphs, and

48

X. Gu et al.

√ K is set to n. Random graphs have a low diameter and a Gaussian degree distribution. – DRand: We generate dense random graphs by increasing the ratio of edges to √ vertices in the above family. It is set to 100 (or n for the case of n = 10000.) Figure 4 plots the execution time of the APSP and MWPM steps in the algorithm for various problem instances from these four families. The number of vertices is varied from n = 1000 to n = 8000 in our study. The average memory footprint is larger than the L2 cache size for all the problem instances, and the largest case uses 20% of the main memory. The execution time on the Y-axis is depicted in the logarithmic scale, as the time grows quadratically with the problem size. We observe that in general, the APSP step is faster than MWPM for large problem instances. The cross-over point varies depending on the problem size and sparsity. For instance, for the dense random graphs, MWPM starts to dominate only for n > 4000. We also observe that the running times of both the steps do not vary much across graph families, i.e., the running time does not seem to be sensitive to the graph topology. The reported running times relate closely with the asymptotic complexity bounds. We performed a linear regression analysis on the data given in Figure 4,

n (a) Long mesh graphs ( 10 × 10)

√ √ (b) Square mesh graphs ( n × n)

(c) Sparse random graphs, m = 10n

(d) Dense random graphs, m = 100n

Fig. 4. Execution time of the APSP and MWPM steps for various graph instances

Improved Algorithms for Detecting Negative Cost Cycles

(a) All-Pairs Shortest Paths (APSP)

49

(b) Minimum Weight Perfect Matching (MWPM)

Fig. 5. The actual and expected (from regression analysis) execution times for the APSP and MWPM steps in the T-join algorithm, on a graph of 10,000 vertices. m is determined by the graph family, and K = 1000.

to compute the additive and multiplicative constants for the m · n complexity term, separately for the APSP and the MWPM steps. With these values, we can predict the running times for larger graph instances. Figure 5 plots the predicted (from the data obtained through regression analysis) and actual execution times for four large-scale instances from different graph families. The number of vertices is set to 10,000 in all four cases, and the number of edges is dependent on the specific graph family (see above discussion). We plot the running times for AWSP and MWPM separately. We observe that the actual running times are only slightly lower than the predicted values (the difference is less than 5% in most cases), confirming that we realize the asymptotic bounds in practice.

6

Conclusion

In this paper, we specialized the T -join approach for solving the UNCCD problem to the case in which the edge weights are integers in {−K · ·K}, where K is a fixed constant. We were able to show that in this special case, the existing time bound of O(n3 ) could be improved to O(n2.75 · log n). Our result is particularly relevant for sparse graphs. We also provided a detailed implementation profile of the algorithms discussed in this paper. There are several open issues that will be addressed in future work: (i) Improving the running time to O(m · n): Our improved algorithm depends on the existence of a fast all-pairs shortest path algorithm for fixed integral weights. It would be interesting to see if we can avoid the shortest paths approach altogether in order to obtain an O(m · n) time bound for the case of arbitrarily weighted graphs. (ii) Parameterizing the running time in terms of edge weights: For the case of directed graphs, there exist a number of negative cycle detection algorithms

50

X. Gu et al.

in the literature whose running times are parameterized by edge weights, for instance [9,10]. At this juncture, it is unknown whether similar algorithms exist for UNCCD. (iii) Producing short certificates of non-existence: Recent work in algorithm design has increasingly emphasized the role the of certifying algorithms [11,12]. The idea here is that the algorithm provides a witness to its output, which is easily certifiable. In case of UNCCD, for a “yes” instance, a negative cost cycle can serve as a certificate. It is not clear what an easily verifiable certificate is, for “no” instances.

References 1. Ahuja, R.K., Magnanti, T.L., Orlin, J.B.: Network Flows: Theory, Algorithms and Applications. Prentice-Hall, Englewood Cliffs (1993) 2. Korte, B., Vygen, J.: Combinatorial Optimization. Algorithms and Combinatorics, vol. 21. Springer, New York (2000) 3. Gabow, H.N.: Data structures for weighted matching and nearest common ancestors with linking. In: Proceedings of the First Annual ACM-SIAM Symposium on Discrete Algorithms, Association for Computing Machinery, pp. 434–443 (1990) 4. Shoshan, A., Zwick, U.: All pairs shortest paths in undirected graphs with integer weights. In: FOCS, pp. 605–615 (1999) 5. Gabow, H.N.: A scaling algorithm for weighted matching on general graphs. In: Proceedings 26th Annual Symposium of the Foundations of Computer Science, pp. 90–100. IEEE Computer Society Press, Los Alamitos (1985) 6. Demetrescu, C., Goldberg, A., Johnson, D.: 9th DIMACS implementation challenge – Shortest Paths (2005), http://www.dis.uniroma1.it/~ challenge9/ 7. Gabow, H.: Implementation of algorithms for maximum matching on non-bipartite graphs. PhD thesis, Stanford University (1974) 8. Rothberg, E.: Implementation of H. Gabow’s weighted matching algorithm (1992), ftp://dimacs.rutgers.edu/pub/netflow/matching/weighted/ 9. Goldberg, A.V.: Scaling algorithms for the shortest paths problem. SIAM Journal on Computing 24, 494–504 (1995) 10. Goldberg, A.: Shortest path algorithms: Engineering aspects. In: ISAAC: 12th International Symposium on Algorithms and Computation, pp. 502–513 (2001) 11. Guo, L., Mukhopadhyay, S., Cukic, B.: Does your result checker really check? In: Dependable Systems and Networks, pp. 399–404 (2004) 12. Kratsch, D., McConnell, R.M., Mehlhorn, K., Spinrad, J.: Certifying algorithms for recognizing interval graphs and permutation graphs. In: SODA, pp. 158–167 (2003)

Covering-Based Routing Algorithms for Cyclic Content-Based P/S System Chen Mingwen1,2, Hu Songlin1, and Liu Zhiyong1 1 Institute of Computing Technology, Chinese Academic of Sciences, Beijing 100190, China 2 Graduate University of Chinese Academy of Sciences, Beijing 100190, China [email protected]

Abstract. The covering-based routing, which maintains a compact routing table and reduces the costs of communications and matching computations by removing redundant subscriptions, is a typical optimization method in content-based distributed publish/subscribe systems. Although it has been widely used as a fundamental part in acyclic systems, no research on covering-based routing for cyclic networks has been reported as we know. As the cyclic systems become a new focus of research for they have advantages over acyclic ones, developing covering-based protocols and algorithms for routing optimization on cyclic networks is significant to distribute publish/subscribe systems. Since current covering optimization methods of acyclic topologies can not be directly utilized on cyclic networks, this paper contributes the Cyclic Covering-Based Routing protocol with corresponding algorithms to support covering-based protocol in cyclic network, which enable efficiently path sharing among related subscriptions with covering relationships so as to reduce the costs of communications and matching computations in cyclic systems. Correctness proofs of the proposed algorithms are also presented in this paper. Keywords: cyclic topology, covering-based routing, content-based routing, publish/subscribe system.

1 Introduction Publish/subscribe (P/S for short) paradigm, which is fully decoupled in time, space and control flow [1], provides asynchronous, anonymous and one-to-many mechanisms for communication [1]. A P/S system consists of three main parts with different roles: the publisher, who produces information, the subscriber, who consumes information, and the broker network, who delivers information. In such a system, subscribers first specify their interests in certain expression form, and then they will be notified via the broker network, while any event fired by publishers matches the registered interests [1]. The content-based P/S system [2-3] utilizes event content for event matching and routing, and provides a fine-granularity event dissemination and high-level transparency. So far, most existing content-based P/S systems are based on an acyclic overlay, X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 51–62, 2009. © Springer-Verlag Berlin Heidelberg 2009

52

C. Mingwen, H. Songlin, and L. Zhiyong

in which a “subscription tree” is constructed to show interests of each subscriber and every matched notification will be forwarded to the subscriber along the reverse path in the tree. The objective of covering-based routing [4-6] is to utilize the nature of the path sharing for the subscriptions with covering relationships in acyclic overlay to reduce the size of the routing table and the number of transmitted messages as much as possible. Recently, the content-based P/S system based on cyclic overlay [2,9] becomes a new focus of research for multiple paths between two brokers providing advantages for failure recovery, load balancing, path reservation, or splitting message streams across multiple paths [9]. Some typical systems such as SIENA [2], PADRES [9] have made explorations on routing protocols for cyclic networks, but none of them support covering-based routing on cyclic networks. In cyclic networks, a certain subscription can be broadcasted in different ways and each way results in a different form of “subscription tree”. The challenge faced by applying the covering-based routing on cyclic networks is how to control the construction process of subscription path to validate and maximize the potential of path sharing for subscriptions with covering relationships as much as possible. In this paper, we develop a protocol and corresponding algorithms of coveringbased routing for cyclic networks. In our strategy, a cyclic network is regarded as an overlay of multiple dynamically generated acyclic topologies, so we can enforce subscriptions with covering relationships to construct their subscription paths in one acyclic topology, so as to achieve the maximal overlapping in their subscription paths. Based on this, the algorithm used to implement the traditional covering-based routing in specified acyclic topologies is refined in order to fit the automatically generated acyclic topologies. The paper continues with Section 2 provides a brief overview of related work; section 3 proposes the basic idea of Cyclic Covering-Based Routing protocol; section 4 describes corresponding algorithms with correctness proof; section 5 gives some concluding remarks.

2 Background and Related Work To keep this paper self-contained, we provide an overview of key concepts used in the reminder of this paper. These include the content-based routing and the coveringbased routing on acyclic networks, the content-based routing on cyclic networks. We also discuss related works along these dimensions. 2.1 The Content-Based Routing on Acyclic Networks The goal of content-based routing (CBR) is to direct messages from their sources to the destinations entirely based on their contents [3] rather than their “addresses”. In the CBR protocol, each subscription consists of a conjunction of predicates with the format of [attribute, comparision operator, value] [7], and the event is represented by a set of [attribute, value] . In most P/S systems with acyclic topology, the reverse path forwarding [12] method is adopted for routing. When a subscriber submits a subscription S to its

Covering-Based Routing Algorithms for Cyclic Content-Based P/S System

53

subscriber hosting broker (SHB), the SHB forwards S to all its neighboring brokers. When a broker receives a subscription S , a routing entry {S, U } (where U is the last hop of S ) is added in its own publication routing table (PRT for short) and S is broadcasted to all its neighbors except U . After several iterations, a spanning tree of S is established. While a publisher sends an event to its publisher hosting broker (PHB), the event will be sent to the last hops of matched subscriptions, and finally arrive at the subscriber through the SHB. 2.2 The Covering-Based Routing on Acyclic Networks The covering-based routing has been well developed on acyclic networks [4-6,8], Let N (S ) represent events which match S , then the covering relationship between the subscription S1 and S 2 in acyclic networks is defined as[6]: if N (S1 ) ⊇ N (S 2 ) , then S1 covers S 2 , denoted by S1 ⊇ S 2 . The main strategy of the covering-based routing is to explore the potential of pathsharing so as to discard “unnecessary messages”. In acyclic networks, when a broker forwards subscriptions S1 and S 2 to its neighbor U , and S1 ⊇ S 2 , then only S 1 needs to be forwarded. In Fig. 1, the subscription S 2 stops being forwarded at B1 and B4 , because both the paths B4 → B7 → B8 → B9 and B1 → B2 → B3 are parts of paths of S 1 , and S 1 can fully represent interests of S 2 because of the covering relationship. S1 ⊇ S 2 B1

B4

B7

B2

B5

B8

B3

B6

B9

S1 S2

Fig. 1. A demonstration of the covering-based routing on acyclic networks

It has been proved [8] that the covering-based routing has advantages of 1) reducing items in broker’s routing table, 2) saving communication costs of network, and 3) reducing computational time for event matching. However, as far as we know, there is no research concerning about the covering-based routing on cyclic networks. 2.3 Content-Based Routing on Cyclic Networks SIENA [2] proposes a routing protocol for general overlay networks. The subscription path is built upon the distance vector, which enables events to be sent to the subscriber through the shortest path. It uses the reverse path forwarding method to detect and discard duplicate messages, but it can not avoid the generation of copies. In the case of a network with 500 brokers, and each broker has 10 neighbors on average, a single advertisement can astonishingly result in 1485 redundant message copies [9].Moreover, because of lack of intersection paths among inter-covering subscriptions, the covering-based routing can not be adopted.

54

C. Mingwen, H. Songlin, and L. Zhiyong

In order to solve the message loop problem on cyclic networks, Padres [9] presented an extended content-based routing (ECBR) protocol which avoids message loops based on “Tree ID”. Under the non-advertisement pattern, the ECBR protocol could be depicted as: 1) when a subscriber sends a subscription to its SHB, the SHB will assign a unique ID to the subscription and floods it out to form a spanning tree; 2) a greedy method is used to control the flooding procedure so that only the first arriving subscription among multiple ones from different neighbors will be kept. This can also enable to find the shortest time-delay path between the subscriber and each node; 3) when PHB receives an event from a publisher, it adds an existential TID predicate to the event, i.e., [TID, =, $Z], where $Z is a variable binding mechanism [14] supported in Padres. This mechanism extracts the value of a matching attribute; if the event matches an subscription in the SRT, the subscription t’s TID is bound to the variable $Z, the event will be sent to the last hop of the subscription. The ECBR protocol can prevent message loops, avoid generations of message copies, but it can not discard “unnecessary messages” whose interests can be represented by other messages. Therefore, developing covering-based protocols and algorithms for cyclic networks becomes a significant issue that needs to be addressed.

3 The Cyclic Covering-Based Routing Protocol In cyclic networks, A subscription S1 can represent interests of a subscription S 2 , if and only if: 1) S1 ⊇ S 2 ; 2) the remaining path of S1 and S 2 entirely overlap. In cyclic networks, if subscriptions with covering relationships constructing their subscription paths in the same topology, they can achieve the maximal overlapping in subscription paths, which satisfies the second condition. To fit the property, we propose the new protocol, called Cyclic Covering-based Routing (CCBR for short) protocol. 3.1 The Related Definitions Our CCBR protocol is built upon the original ECBR protocol. We add some definitions to make it exploring the potential of path-sharing of subscriptions with covering relationships. Definition 1. The independent subscription. If a subscription is NOT covered by other subscriptions, or there is a high time-delay requirement for receiving events, then the subscription is an independent subscription. For every independent subscription, the following properties should be satisfied: 1) It must be assigned a unique ID for its subscription path. 2) It must be flooded to the entire network. Definition 2. The grafted subscription. If the subscription is covered by one or more subscriptions, and there is no high time-delay requirement for receiving events, then this subscription is a grafted subscription. For every grafted subscription: 1) It must choose an independent subscription to graft. 2) It must share the identical ID with the chosen independent subscription.

Covering-Based Routing Algorithms for Cyclic Content-Based P/S System

55

Definition 3. The newly uncovered subscriptions [6]. If a subscription S is canceled. We call the grafted subscriptions used to be only covered by S the newly uncovered subscriptions of S . Definition 4. In cyclic networks, a subscription S1 can represent interests of a subscription S 2 , if and only if: 1) S1 ⊇ S 2 ; 2) S1 and S 2 have the identical ID. 3.2 The Basic Idea of CCBR Protocol The basic idea of CCBR protocol is described as the following: When a client submits a subscription to its SHB, only the SHB has the ability to decide whether it is an independent subscription or a grafted subscription according to its covering relationship and the time-delay requirement submitted by user. For handling an independent subscription IS : 1) A unique ID will be assigned for IS from its SHB. 2) IS must be flooded to the entire network and form a spanning tree. For handling a grafted subscription GS : 1) An independent subscription IS which covers GS will be chosen, and the ID of IS will be assigned to GS as its ID. 2) The subscription path of GS is grafted on the subscription tree of IS , which is actually from the SHB of GS to the SHB of IS along the reverse direction of IS ’s subscription tree (see Lemma 1 in the following). 3) Acyclic covering optimization is used among grafted subscriptions with the identical ID (see Lemma 2 in the following). For cancelling an independent subscription IS : 1) The SHB of IS will send the unsub message along its spanning tree to remove its subscription path. 2) The SHB will check out all the newly uncovered subscriptions of IS . All of them should be upgraded to independent subscriptions, and construct their own subscription tree based on IS ’s acyclic topology (see Lemma 3 in the following). 3) For a newly uncovered subscriptions of IS , NUS , all the subscriptions covered by NUS , must prolong their paths from the meeting points of NUS to NUS ’s SHB ( see Lemma 4 in the following) unless they are covered by other grafted subscriptions. For cancelling a grafted subscription GS : 1) Its SHB will send unsub message along its linear subscrption path to delete its subscrption path. 2) The newly uncovered subscriptions of GS , must prolong their paths from the meeting points of GS to the SHB of the corresponding independent subscription. The prolonging process for each of the newly uncovered subscriptions will stop when it meets another grafted subscription which covers it and has the identical ID. Fig. 2 shows the process of constructing subscription paths. There are 9 brokers ( B1 ,..., B9 ) and three subscriptions A, B, C , where A ⊇ B ⊇ C . A is an independent

56

C. Mingwen, H. Songlin, and L. Zhiyong

subscription, who maintains a subscription tree. The path of B and C are grafted on the tree of A , where the subscription path of B is a line : B6 → B3 → B2 → B1 , and the subscription path of C is from its SHB to the meeting point of B : B5 → B2 . old path of B

A‹B‹C B1

B4

B7

B2

B5

B8

path of A

B1

B4

B7

new added path of B

path of B B2

B5

B8

B3

B6

B9

path of C

old path of C new added path of C

B3

B6

B9

Fig. 2. A demo of constructing paths

Fig. 3. A demo of new path generations subscription for newly uncovered subscriptions

In Fig. 3, when A is canceled, the newly uncovered subscription B must construct its own spanning tree. Meanwhile, subscription C , which covered by B , must elongate its path from B2 (the meeting point of B and C ) to B6 (the SHB of B ). As shown in the figure, the new path of B has three sub-paths: B1 → B4 → B7 , B2 → B5 → B8 , B6 → B9 , and the new path of C is B2 → B3 → B6 . When a client submits an event to its PHB, the PHB will add an existential TID predicate to the event, and duplicate the event. Every copy of the event is assigned a matched independent subscription ID as its value in its TID predicate, and forwarded to the acyclic topology generated by the independent subscription. In this way, every related acyclic topology can get one copy of the event, and this copy will deliver to all the matched subscriber in that acyclic topology according to traditional covering based routing algorithm. The optimization strategy used by ECBR can also be used by CCBR to reduces event copies,we didn’t trace details of it for the limitations of space.

4 Algorithms and Corresponding Correctness Proofs 4.1 Key Algorithms of CCBR Processing an independent subscription: We use the greedy strategy in ECBR [9] to form subscription path for independent subscriptions. As shown in Fig. 4, when a broker receives an independent subscription IS , the broker will check out whether it is already in the broker’s PRT . If so, the broker will discard it; otherwise, the broker will record it, and broadcast it to all neighbors. Thus, every broker receives multiple copies of IS , but only keeps the first one. Finally a spanning tree is formed for IS . Processing a grafted subscription: As shown in Fig. 5, if a broker receives a grafted subscription GS , it will be sent to the independent subscription IS who covers it.

Covering-Based Routing Algorithms for Cyclic Content-Based P/S System

57

This process will stop if it meets another graft subscription that covers it; the same time, the grafted subscriptions who covered by GS must be canceled. After several iterations, a linear subscription path will be formed for GS . Processing cancellation of an independent subscription: In our scheme, when a client cancels an independent subscription IS , its SHB will generate a combined message, {unsub(IS ), {NUSs}} , to remove the spanning tree of IS and to build spanning trees for the entire newly uncovered grafted subscriptions, {NUSs} .As shown in Fig. 6, if a broker receives this message, it will delete the routing entry {IS , U } in PRT, and check the existence of every NUS . If a NUS do not exist, a routing entry {NUS ,U } will be added in PRT. Meanwhile, all the grafted subscription GS i once being stopped forwarding due to meeting NUS , must be sent to the last hop of NUS . Processing cancellation of a grafted subscription: when a client cancels a grafted subscription GS , its SHB generates a message unsub(GS ) . The algorithm for a broker handling unsub(GS ) is similar to the traditional covering-based routing in acyclic networks [6]: if GS is in the broker’s PRT, the broker will delete GS , and find out all newly uncovered subscription of GS , denoted by GSi ,and sent them to the last hop of IS .





Algorithm brokerhandle independent subscription IS * if it’s the first time to receive IS then store IS in PRT* 1. if IS exists in PRT

( 2. 3. 4. 5. 6.

then do nothing else item< { IS , IS.sender } PRT< PRT U item for each neighbor n where n ≠ IS .sender do send IS to n





Fig. 4. The independent subscription handler

( ) ( ) . 2.PRT ← PRT U item 3.if ∃GS ∈ PRT where GS ⊇ GS ∧ GS .ID = GS.ID 4. then do nothing 5. else send GS to IS.lasthop 6. if ∃GS ∈ PRT where GS ⊇ GS ∧ GS .ID = GS .ID then send unsub(GS ) to IS.lasthop 7. Algorithm brokerhandle grafed subscription GS *Store and forward the graft subscription* 1 item ← {GS , GS .sender} i

i

i

j

j

j

j

Fig. 5. The grafted subscription handler



58

C. Mingwen, H. Songlin, and L. Zhiyong

( {unsub(IS ),{NUSs}} ) {NUSs} in PRT *) ∃(IS, sender ) ∈ PRT then PRT ← PRT— (IS, sender )

Algorithm brokerhandle

(* Delete

1.

2. 3. 4. 5.

if

IS and store

//delete subscription of IS for each NUS ∈ {NUSs} do if ∃(NUS ) ∈ PRT

6. 7. 8.

//this broker is on the old subscription path of NUS then if ∃GSi // GSi stop forwarding because of meet NUS

9. 10.

// and do not covered by other grafted subscription with same id then send GSi to NUS.lasthop else PRT ← PRT U(NUS, sender )

11. 12. 13. 14. 15.

//constructions new subscription path of NUS for each neighbors n where n ≠ sender send {unsub(IS ){NUSs}} to n



else do nothing

Fig. 6. The message cancellation handler for an independent subscription

(message unsub(GS ) ) (*Delete and forward the graft subscription*) 1.if ∃(GS , GS .sender ) ∈ PRT 2. then PRT ← PRT— (GS , GS .sender ) Algorithm brokerhandle

3. 4. 5

. .

6

send unsub(GS ) to IS.lasthop if ∃(GSi , GSi .sender ) ∈ PRT where GS ⊇ GSi ∧ GSi .ID = GS .ID then send GSi to IS.lasthop else do nothing

Fig. 7. The message cancellation handler for a grafted subscription

4.2 Correctness Proof and Analysis of the Algorithms While the algorithm in Fig. 4 is from ECBR [9], and the algorithm in Fig. 7 is similar to the covering-based routing in acyclic networks [6], the algorithms in the Fig. 5 and Fig. 6 are the main contributions of CCBR. The following of this section proves the liveness condition [6] of the algorithms for the grafted subscription handler shown in Fig. 5, and the correctness of the algorithms for the message cancellation handler for an independent subscription shown in Fig. 6. Lemma 1. A grafted subscription GS only needs to be forwarded to the last hop of IS (See Line 5 in Fig. 5) rather than all neighbors. This schema won’t cause any missing of matched events.

Covering-Based Routing Algorithms for Cyclic Content-Based P/S System

59

Proof: After several iterations, a subscription path OGI which is from GB (the SHB of GS ) to IB (the SHB of IS , where IS.ID = GS .ID ) along the reverse direction of IS ’s subscription tree will be constructed. Let N (GS ) = N i U N j , where N i denotes the set of events which match GS and are submitted by brokers not on the path OGI , and N j denotes the matched events submitted by brokers on OGI . Following the definition of the covering relationship (Section 2.2): IS ⊇ GS ⇒ N ( IS ) ⊇ N (GS ) ⊇ N i . So IS can represent interests of GS on paths excluding OGI . This means N i will be forwarded to OGI along the subscription tree of IS . Then based on principles of the reverse path forwarding method, both N i and N j will be forwarded to GB along the newly established path of OGI . Lemma 2. A grafted subscription GS can stop constructing its subscription path when it meets another grafted subscription GS i (See Line 3,4 in Fig. 5), where GS i ⊇ GS , and GS i .ID = GS .ID , and did not result in message lose. Proof: 1) Let IS represent the independent subscription who covers GS and GS i , In terms of Lemma 1, IB is the destination of both GS and GS i . 2) Because of the limitation of path building the, only a unique path exists between the meeting point to IB . So when GS meets GS i , the remaining subscription paths of each of them are the same. 3) Based on the definition of the covering-based routing, when GS i ⊇ GS and subscription paths of them are the same, GS i can represent interests of GS , thus, all the N (GS ) will be delivered to GS correctly. Theorem 1. Using the grafted subscription handler in Fig. 5, the cyclic P/S system will fulfill the liveness condition [6] after finite operations. Proof: According to Lemma 1,2, all the N (GS ) will be delivered to GS correctly, so the liveness condition is satisfied. Lemma 3. When canceling IS , the entire information of the newly uncovered subscriptions of IS can banding to one message, for IB can keep all the information of them. Proof: According to Definition 3, all the newly uncovered subscriptions are grafted subscriptions only covered by IS , so according to Lemma 1 and Lemma 2, all of them will be forwarded to IB without stopping in the midway. Hence, the PRT of IB can keeps all information of newly uncovered subscriptions, and banding all of them to one message.

60

C. Mingwen, H. Songlin, and L. Zhiyong

Lemma 4. For constructing path for a newly uncovered subscription NUS , if the brokers obey following rules: 1) if it already has a term of NUS in its PRT, then maintains the old path of NUS (Fig. 6 Line 4-6 ); 2), otherwise, it creates a new path for NUS , which has the same direction of the IS (Fig. 6 Line 11-12 ), then a spanning tree will be constructed for NUS upon the topology decided by IS . Proof: According to Fig. 6 Line 4-6 the old path of NUS is preserved. It is a linear path, so every broker in this path except the SHB of NUS records the last hop of NUS . Based on Fig. 6 Line 11-12, other brokers will record the last hop of IS as the last hop. So in the entire network, every broker points to another broker by recording it as the last hop of NUS , except NUS ’s SHB. Because the old path of NUS is built upon the spanning tree of IS , and the new path of NUS has the same topology with IS . So, NUS is built upon the connected graph decided by IS . In terms of the definition [13] :“A tree is a connected graph with V vertices and V1 edges”, the path of NUS is a spanning tree .



Lemma 5. When constructing the subscription tree of NUS , the subscription GS i , which stops being forwarded because of meeting NUS , only needs to be forwarded to the last hop of NUS , and is not necessary to unsubscribe the original path ( Fig. 6 Line 7-10 ). Proof: 1. Let b denote the meeting point of GS i and NUS . Due to Lemma 1 and 2, the original subscription path of GS i is the path from GB to b , denoted by OGb . 2. After finite iterations of Line 5, a new path from b to the SHB of NUS will be added, denoted by ObN . To sum up, the whole path of GS i is from the SHB of GS i to the SHB of NUS ( OGb + ObN ), and due to Lemma 1, the path of GS i is added correctly. Theorem 2. After flooding the message cancellation handler (shown in Fig. 6), the subscription path of IS can be removed besides with the spanning tree of each NUS being constructed. And meanwhile the subscription path of every GS i covered by NUS is constructed. Proof: 1. Referring to the pseudo code of Line 3, the subscription path of IS will be removed after the flooding operation. 2. According to Lemma 3, all the information of NUS is recorded in IB , so it can be combined to one information {NUSs} . According to Lemma 4, after flooding of {NUSs} , every NUS forms a spanning tree. 3. And through flooding operation, all the GS i covered by NUS can construct right subscription path based on Lemma 5.

Covering-Based Routing Algorithms for Cyclic Content-Based P/S System

61

For quantitative analysis, we define e as the number of edges, n as the number of brokers, k 1 as the number of independent subscriptions, k 2 as the number of grafted subscriptions. Let d denote the distance between a grafted subscription to the nearest subscription who covers it, avg (d ) denote average value of d . Thus communication complexity can be measured in terms of the total messages, the communication complexity in CCBR protocol is k 1 * e + k 2 * avg ( d ) , which is significantly smaller than ( k 1 + k 2 ) * e in the traditional protocol. Furthermore, in traditional protocol, the total routing table size is (k 1 + k 2) * n , which is decreased to k 1 * n + k 2 * avg (d ) in CCBR. In view of time complexity of matching time is expected to be sub-linear of the routing table size [15], our protocol can also reduce the cost of matching time effectively.

5 Conclusion Cyclic networks for content-based P/S systems have advantages over acyclic ones and become a new research focus. However, the covering-based routing, which can reduces message transmission and matching computation costs, can not be used for cyclic networks directly. A covering-based routing protocol CCBR and corresponding algorithms for cyclic networks have been proposed in this paper. The proposed routing protocol and algorithms can support covering-based routing on cyclic networks such that transmitted messages can be reduced by applying the covering relationship of the subscriptions. Correctness proofs are presented as well. Moreover, our design preserves the original simple P/S interface to clients, and does not require any change to a broker's internal matching algorithm. Thus the proposed approach can be easily integrated into existing systems. Based on it, a prototype system is being implemented. Experiments will be carried out on the prototype to evaluate the performance of the proposed protocol and corresponding algorithms. Future work also includes load balancing strategies and dynamical subscription path selection method.

Acknowledgment The paper is supported by the National Basic Research Program, China (grant 2007CB310805), the National Science Foundation (grant 60752001), and the Beijing Natural Science Foundation (grant 4092043).

References 1. Eugster, P.T., Felber, P.A., Guerraoui, R., Kermarrec, A.M.: The many faces of publish/subscribe. ACM Computing Surveys 35(2), 114–131 (2003) 2. Carzaniga, D.S., Rosenblum, Wolf, A.L.: Design and evaluation of a wide-area event notification service. ACM ToCS 19(3), 332–383 (2001) 3. Carzaniga, Wolf, A.: Forwarding in a content-based network. In: SIGCOMM (2003) 4. Carzaniga: Architectures for an Event Notification Service Scalable to Wide-area Networks. PhD thesis, Politecnico di Milano, Milano, Italy (1998)

62

C. Mingwen, H. Songlin, and L. Zhiyong

5. Li G.L., Hou S., Jacobsen H.A: A unified approach to routing, covering and merging in publish/subscribe systems based on modified binary decision diagrams. In: ICDCS 2005 (2005) 6. Muhl, G.: Large-scale content-based publish/subscribe systems. PhD thesis, Darmstadt University of Technology, Germany (2002) 7. Dalal Yogen, K., Metcalfe Robert, M.: Reverse Path Forwarding of Broadcast Packets. Communications of the ACM 21(12), 1040–1047 (1978) 8. Yuan, H.L., Shi, D.X., Wang, H.M., Zou, P.: Research on Routing Algorithm Based on Subscription Covering in Content-Based Publish/Subscribe. Chinese Journal Of Computers 29(10) (2006) 9. Li, G.L., Muthusamy, V., Jacobsen, H.A.: Adaptive Content-Based Routing in General Overlay Topologies. In: Middleware (2008) 10. Fiege, L., Mezini, M., Mühl, G., Buchmann, A.P.: Engineering event-based systems with scopes. In: Magnusson, B. (ed.) ECOOP 2002. LNCS, vol. 2374, pp. 309–333. Springer, Heidelberg (2002) 11. Cugola, G., Nitto, E.D., Fuggetta, A.: The JEDI event-based infrastructure and its application to the development of the OPSS WFMS. ToSE 27(9) (2001) 12. Dalal Yogen, K., Metcalfe Robert, M.: Reverse Path Forwarding of Broadcast Packets. Communications of the ACM 21(12), 1040–1047 (1978) 13. Bollobas, B.: Morden Graph Theory. Spriger-Verlag, New York (1988) 14. Li, G., Jacobsen, H.-A.: Composite subscriptions in content-based publish/Subscribe systems. In: Alonso, G. (ed.) Middleware 2005. LNCS, vol. 3790, pp. 249–269. Springer, Heidelberg (2005) 15. Aguilera, M.K., Strom, R.E., Sturman, D.C., Astley, M., Chandra, T.D.: Matching events in a content-based subscription system. In: Proceedings of the Eighteenth Annual ACM Symposium on Principles of Distributed Computing (1999)

On the α-Sensitivity of Nash Equilibria in PageRank-Based Network Reputation Games Wei Chen1 , Shang-Hua Teng1,⋆ , Yajun Wang1 , and Yuan Zhou2 1

Microsoft Research {weic,t-shaten,yajunw}@microsoft.com 2 Tsinghua University [email protected]

Abstract. Web search engines use link-based reputation systems (e.g. PageRank) to measure the importance of web pages, giving rise to the strategic manipulations of hyperlinks by spammers and others to boost their web pages’ reputation scores. Hopcroft and Sheldon [10] study this phenomenon by proposing a network formation game in which nodes strategically select their outgoing links in order to maximize their PageRank scores. They pose an open question in [10] asking whether all Nash equilibria in the PageRank game are insensitive to the restart probability α of the PageRank algorithm. They show that a positive answer to the question would imply that all Nash equilibria in the PageRank game must satisfy some strong algebraic symmetry, a property rarely satisfied by real web graphs. In this paper, we give a negative answer to this open question. We present a family of graphs that are Nash equilibria in the PageRank game only for certain choices of α.

1

Introduction

Many web search engines use link-based algorithms to analyze the global link structure and determine the reputation scores of web pages. The popular PageRank [3] reputation system is one of the good examples. It scores pages according to their stationary probability in a random walk on the graph that periodically jumps to a random page. Similar reputation systems are also used in peer-to-peer networks [11] and social networks [8]. A common problem in reputation systems is manipulation: strategic users arrange links attempting to boost their own reputation scores. On the web, this phenomenon is called link spam, and usually targets at PageRank. Users can manage to obtain in-links to boost their own PageRank [6], and can also achieve this goal by carefully placing out-links [2,4,7]. Thus PageRank promotes certain link placement strategies that undermine its original premise, that links are placed organically and reflect human judgments on the importance and relevance of web pages. ⋆

Affiliation starting from the Fall of 2009: Department of Computer Science, University of Southern California, Los Angeles, CA, U.S.A.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 63–73, 2009. c Springer-Verlag Berlin Heidelberg 2009 

64

W. Chen et al.

There are a number of works focusing on understanding, detecting [6,2,4,7] and preventing link manipulations [5,9,12]. Other works investigate the consequences of manipulation. In [10], Hopcroft and Sheldon introduce a network formation game called the network reputation game, where players are nodes attempting to maximize their reputation scores by strategically placing out-links. They mainly focus on the game with the PageRank reputation system, which we refer to directly as PageRank game, and study the Nash equilibria of the game. Each Nash equilibrium is a directed graph, where no player can further improve his own PageRank by choosing different out-links. They present several properties that all Nash equilibria hold, and then provide a full characterization of α-insensitive Nash equilibria, those graphs that are Nash equilibria for all restart probability α, a parameter in the PageRank algorithm. They show that all α-insensitive Nash equilibria must satisfy some strong algebraic symmetry property, which is unlikely seen in real web graphs. However, the work of [10] leaves an important question unanswered, which is whether all Nash equilibria are α-insensitive. In this paper, we give a negative answer to this open question. In particular, we construct a family of graphs and prove that for α close to 0 and 1 they are not Nash equilibria. At the same time, by applying the mean value theorem, we argue that for every graph in the family, there must exist an α for which the graph is a Nash equilibrium. In Section 2, we give the definition of PageRank functions and some known properties of α-random walk and best response in PageRank games. In Section 3, we present the construction of a family of graphs and prove that they are α-sensitive Nash equilibria.

2 2.1

Preliminaries PageRank

Let G = (V, E) be a simple directed graph, i.e., without multiple edges and self-loops. Furthermore, we assume each node has at least one out-link. Let V = [n] = {1, 2, . . . , n}. We denote (i, j) as the directed edge from node i to node j. The PageRank of the nodes in G can be represented by the stationary distribution of a random walk as follows. Let α ∈ (0, 1) be the restart probability. The initial position of the random walk is uniformly distributed over all nodes in the graph. In each step, with probability α, the random walk restarts, i.e., jumps to a node uniformly at random. Otherwise, it walks to the neighbors of the current node, each with the same probability. The PageRank of a node u is the probability mass of this random walk in its stationary distribution. We refer to this random walk as the PageRank random walk. Note that this random walk is ergodic, which implies the existence of the unique stationary distribution. Mathematically, let A be the adjacency matrix of G, such that the entry Aij = 1 if and only if there exists an edge from node i to j in G. Let di be the out degree of node i in G. Define matrix P as P = AD−1 , where D = diag{d1 , d2 , . . . , dn }. Thus P is the transition matrix for the random walk on G without the random

On the α-Sensitivity of Nash Equilibria in PageRank Games

65

restart. By defining Mα = I − (1 − α)P , it is well known (e.g. see [10]) that the PageRank (row) vector πα is: α [1, 1, · · · , 1](I − (1 − α)P )−1 n α = [1, 1, · · · , 1]Mα−1 . n

πα =

The i-th entry of πα is the PageRank value of node i in G. In particular, the PageRank of node i is: n α (1) M −1 . πα [i] = n j=1 α ji Returning Probability 

i −1 It is easy to see that Mα−1 = I + ∞ i=1 [(1 − α)P ] . Therefore the entry Mα ij is the expected number of times to visit j starting from i before the next restart, in the PageRank random walk. Suppose that the random walk currently stops at i. We define φij to be the probability of reaching j in the random walk before the next restart. We set φii = 1. Let φ+ ii be the probability of returning to i itself from i before the next restart. The following lemma holds.

Lemma 1 (Hopcroft and Sheldon [10]). Let i, j ∈ [n]. For any simple directed graph G and restart probability 0 < α < 1, we have ∀ i = j, Mα−1 ij = φij Mα−1 jj 1 ∀ j, Mα−1 jj = . 1 − φ+ jj 2.2

PageRank Game and Best Responses

In the PageRank game, each node is building out-links. Let Ei = {(i, j) | j ∈ V \ {i} } be the set of possible out-links from node i. The strategy space of node i is all subsets of Ei . The payoff function for each node is its PageRank value in the graph. A best response strategy for node i in the PageRank game is a strategy that maximizes its PageRank in the graph, given the strategies of all other nodes. By Lemma 1 and Equation (1), the best response for i is maximizing the following statement in the new graph: 

n j=1

φji . 1 − φ+ ii

Note that φji is the probability of reaching node i from j before the next restart in the random walk, which is independent of the out-links from i. (φii = 1 by definition.) Based on this observation, following lemma from [10] holds.

66

W. Chen et al.

Lemma 2 (Lemma 1 of Hopcroft and Sheldon [10]). In the PageRank game, a best response strategy for node i is a strategy that maximizes φ+ ii in the new graph. By definition, φ+ ii is the probability of returning to i from i before the next restart in the random walk. Therefore, φ+ ii =

α |N (i)|



φji . j∈N (i)

Corollary 1. In the PageRank game, a best response strategy for node i is a nonempty set S ⊆ Ei that maximizes 1  |S|

φji . j∈S

Note that the out-links of node i does not affect φji for j = i. Since Corollary 1 means that the best response of node i is to maximize the average φji of its outgoing neighbors, it is clear that i should only select those nodes j with the maximum φji as its outgoing neighbors. This also implies that in the best response S of i, we have for all j, k ∈ S, φji = φki . 2.3

Algebraic Characterization of a Nash Equilibrium

A graph G is a Nash equilibrium if for any node i, its out-links in G is a best response. The following lemma is a directly consequence of Corollary 1. Lemma 3. If a strongly-connected graph G = (V, E) is a Nash equilibrium, the following conditions hold: (1) for all different i, j, k ∈ V , Mα−1 ji < Mα−1 ki =⇒ (i, j) ∈ E; and (2) ∀ (i, j), (i, k) ∈ E, Mα−1 ji = Mα−1 ki . It has been shown that any strongly connected Nash equilibrium should be bidirectional [10]. Lemma 4 (Theorem 1 of Hopcroft and Sheldon [10]). If a stronglyconnected graph G = (V, E) is a Nash equilibrium, then for any edge (i, j) ∈ E, we have (j, i) ∈ E. The proof of Lemma 4 uses the fact that only the nodes having out-links to vertex i can achieve the maximum value of Mα−1 ·,i . The following lemma states that the necessary conditions given in Lemma 3 (2) and Lemma 4 are actually sufficient to characterize a Nash equilibrium. Lemma 5 (Equivalent condition for a Nash equilibrium). A stronglyconnected graph G = (V, E) is a Nash equilibrium if and only if G is bidirectional and ∀(i, j), (i, k) ∈ E, Mα−1 ji = Mα−1 ki .

On the α-Sensitivity of Nash Equilibria in PageRank Games

67

Proof. The necessary conditions are given by Lemma 3 (2) and Lemma 4. We focus on the sufficient condition. Since Mα−1 ji = Mα−1 ki is true for all nodes j, k ∈ V \ {i} that have out-links to i by our condition, we have φji = φki from Lemma 1. By Lemma 2 of Hopcroft and Sheldon [10], only the incoming neighbors j of i can achieve the maximum φji . Therefore, all incoming neighbors of i actually achieve this maximum. By Corollary 1, node i selecting all incoming neighbors as outgoing neighbors is certainly a best response, which implies that G is a Nash equilibrium.

3

Existence of α-Sensitive Nash Equilibria

A Nash equilibrium is α-insensitive if it is a Nash equilibrium for all possible parameter 0 < α < 1. Otherwise, we say that it is α-sensitive. Hopcroft and Sheldon asked the following question about the α-insensitivity property for Nash equilibria. Question 1 (Hopcroft and Sheldon’s question on α-insensitivity [10]). Are all the Nash equilibria α-insensitive or there exist other α-sensitive Nash equilibria in the PageRank game? We are interested in this question because if all the Nash equilibria are α-insensitive, the set of Nash equilibria can be characterized by the set of Nash equilibria at some specific α. In particular, we can characterize the set of Nash equilibria when α is arbitrary close to 1 (e.g. 1 − 1/n3 ). However, if the answer to this question is positive, all Nash equilibria must satisfy some strong algebraic symmetry as illustrated in [10], making them less likely the right choice for modeling web graphs. We show below that there exist α-sensitive Nash equilibria, which implies that the set of equilibrium graphs in the PageRank game is much richer. Theorem 1 (Answer to Question 1). There exist an infinite number of αsensitive Nash equilibria in the PageRank game. The rest part of this section is devoted to the construction of such α-sensitive Nash equilibria. 3.1

Construction of Gn,m

For all n, m ∈ Z+ , we construct an undirected graph Gn,m as follows. Definition 1 (Gn,m ). As shown in Figure 1, the vertex set of graph Gn,m consists of U and V . U = {u1 , u2 , · · · , un } and V = {vi,j | i ∈ [m], j ∈ [n]}. Each Vi = {vij | j ∈ [n]} is fully connected. For each node ui ∈ U, there are m edges {(ui , vj,i )} adjacent to ui for j ∈ [m]. Note that we define Gn,m as an undirected graph for the simplicity of presentation. This is because each Nash equilibrium is bidirectional. Nevertheless, we can change Gn,m to a directed graph, by replacing each edge with two direct edges. All the following treatment assumes Gn,m is directed.

68

W. Chen et al. n vertices with degree m u1

U

u2

un

···

n × m cross edges ···

v2,n v2,1

v1,n v1,1 v1,2

v2,2

vm,n vm,1 vm,2

······

V

m n-cliques

Fig. 1. The graph Gn,m

3.2

Equivalent Condition of Gn,m Being Nash Equilibria

By Lemma 5, given α, n and m, Gn,m is a Nash equilibrium if and only if the following statements hold ∀ different i, i′ ∈ [m], j ∈ [n],

Mα−1 vi,j ,uj = Mα−1 vi′ ,j ,uj

(2)

∀ i ∈ [m], different k, k ′ , j ∈ [n], Mα−1 vi,k ,vi,j = Mα−1 vi,k′ ,vi,j

(3)

∀ i ∈ [m], different k, j ∈ [n],

(4)

Mα−1 vi,k ,vi,j = Mα−1 uj ,vi,j

It is easy to see that equations in (2) and (3) hold for any α, n, m by symmetry. Moreover, for all i ∈ [m] and different k, j ∈ [n], Mα−1 vi,k ,vi,j has the same value, and for all i ∈ [m] and j ∈ [n], Mα−1 uj ,vi,j has the same value in Gn,m . We define two functions based on this observation: fn,m (α) = Mα−1 vi,k ,vi,j , for i ∈ [m] and j, k ∈ [m], j = k, gn,m (α) = Mα−1 uj ,vi,j , for i ∈ [m] and j ∈ [n].

The above argument together with Lemma 5 implies the following lemma. Lemma 6. Given α, n and m, Gn,m is a Nash equilibrium for the PageRank game with parameter α ∈ (0, 1) if and only if fn,m (α) − gn,m (α) = 0 3.3

(5)

α-Sensitivity of Gn,m : Proof Outline

Given n, m, by Lemma 6, to prove Gn,m is α-sensitive, we only need to show that there is some α satisfying Equation (5), while there is also some other α that does not. Note that fn,m (α) (resp. gn,m (α)) is the expected number of times the random walk starting from vi,k (resp. uj ) visiting vi,j before the next restart.

On the α-Sensitivity of Nash Equilibria in PageRank Games

69

We use this interpretation to both explain the intuitive idea of the proof and carry out the detailed proof. Intuitively, when α is very close to 1 (i.e. the random walk restarts with a very high probability), we only need to compute the first few steps of the random walk to give a good estimate of Mα−1 i,j , since the random walk is very likely to restart after a few steps and the contribution of the longer steps of the walk is negligible. Thus, in this case, by estimating the first step, for all i ∈ [m], different k, j ∈ [n], 1−α n 1−α . ≈ m

fn,m (α) = Mα−1 vi,k ,vi,j ≈ gn,m (α) = Mα−1 uj ,vi,j

When m < n, there exists α such that fn,m (α) − gn,m (α) is indeed negative. The following lemma formalizes the intuition. We defer its proof to the next section. Lemma 7. Given 1 ≤ m ≤ n − 2, if α ≥ n−3 n−2 , fn,m (α) − gn,m (α) < 0 and Gn,m is not a Nash equilibrium for the PageRank game with parameter α. On the other hand, when α is very close to 0, random walks starting from both uj and vi,k tend to be very long before the next restart. In this case, the random walk starting at vi,k has an advantage to be in the same clique as the target vi,j , such that the expected number of time it hits vi,j before the walk jumps out of the clique is close to 1. The random walk starting at uj , however, has (m − 1)/m chance to walk into a clique different from the i-th clique where the target vi,j is in, in which case it cannot hit vi,j until it jumps out of its current clique. After both walks jump out of their current clique for the first time, their remaining stochastic behaviors are close to each other and thus contributing to fn,m (α) and gn,m (α) approximately the same amount. As a result, gn,m (α) gains about 1 (m − n1 ) over fn,m (α) in the case where the random walk from uj hit the target vi,j in the first step, but fn,m (α) gains about 1 over gn,m (α) in the rest cases. 1 larger than gn,m (α) when m is Therefore, fn,m (α) is approximately 1 + n1 − m large. The following lemma gives the accurate statement of this intuition while the next section provides the detailed and rigorous analysis. 1 ), fn,m (α) − gn,m (α) > 0. Lemma 8. Assume 4 ≤ m < n. If α ∈ (0, n(n−1)

Lemma 9. fn,m (α) and gn,m (α) are continuous with the respect of α ∈ (0, 1). Proof. For any graph, the corresponding Mα is invertible for α ∈ (0, 1). Note that each entry of Mα is a continous function with respect to α ∈ (0, 1). By Cramer’s rule, Mα−1 =

Mα∗ , |Mα |

where |Mα | is the determinant and Mα∗ is the co-factor matrix of Mα . Therefore, Mα−1 i,j is continuous with respect to α ∈ (0, 1), since it is a fraction of two finite-degree polynomials and |Mα | is non-zero.

70

W. Chen et al.

With the continuity of fn,m (α) and gn,m (α) and the results of Lemma 7 and 8, we can apply the mean value theorem on fn,m (α) − gn,m (α) and know that it must have a zero point. With Lemma 6, we thus have 1 Corollary 2. Given 4 ≤ m ≤ n − 2, there exists α ∈ ( n(n−1) , n−3 n−2 ) such that Gn,m is a Nash equilibrium for the PageRank game with parameter α.

Lemma 7 and Corollary 2 immediately imply Theorem 1. 3.4

Proof Details

In this section, we provide the complete proofs to the results presented in last section. To make our intuitive idea accurate, the actual analysis is sufficiently more complicated. Proof. [of Lemma 7] By Lemma 1, fn,m (α)−gn,m (a) < 0 if and only if φvi,j′ ,vi,j < φuj ,vi,j . (n−2)(1−α) φvi,j′ ,vi,j + By symmetry of the graph, we have φvi,j′ ,vi,j = 1−α n + n 1−α 2 ′ ′ n φuj′ ,vi,j for j = j. Since uj is at 2 hops away from vi,j , φuj′ ,vi,j ≤ (1 − α) . n−3 From α ≥ n−2 , we have n − (n − 2)(1 − α) ≥ n − 1. Therefore, we have (1 − α) + (1 − α)3 . n−1 √ ≥ 1 − 1/ n − 2, we have (1 − α)2 ≤ 1/(n − 2),

φvi,j′ ,vi,j ≤ Finally, since α ≥ and thus

n−3 n−2

1 = 1 − n−2

φvi,j′ ,vi,j ≤

1−α (1 − α) + (1 − α)3 ≤ . n−1 n−2

On the other hand, φuj ,vi,j > n − 2.

1−α m .

Therefore, the lemma holds when m ≤

Definition 2. To simplify the notation, by symmetry of the graph, we define 1. 2. 3. 4. 5.

r = Mα−1 vi,j ,vi,j , x = Mα−1 vi′ ,j ,vi,j , i′ = i, y = Mα−1 vi,j′ ,vi,j , j ′ = j, z = Mα−1 vi′ ,j′ ,vi,j , i′ = i and j ′ = j, and µ = Mα−1 uj ,vi,j .

By definition, r ≥ max{x, y, z, u}. The proof of Lemma 8 requires the following result. 1 ), we have Lemma 10. Assume 1 < m ≤ n. If α ∈ (0, n(n−1) n n , n−1 ), 1. y − z ∈ ( n+1 n 2. r − y < n−1 , 2 3. x − z < n−1 .

On the α-Sensitivity of Nash Equilibria in PageRank Games

71

Proof. For any path L = (i1 , i2 , · · · , ik ), let P rα (L) be the probability of completing the path L exactly before next restart when starting from i1 . Therefore,  k−1 P rα (L) = α(1 − α)k−1 j=1 Pij ,ij+1 , where P is the transition matrix of the graph. Let V (L) be the set of nodes of L. Let CountL (i) be the number of occurrence of node i in L. Denote by L(i) the set of paths of finite length starting from vertex i. Therefore, Mα−1 ij =



P rα (L)CountL (j) L∈L(i) (j)

For the first claim, we define function Fi→i′ : L(vi,j ) → L(vi′ ,j ) to map any path L starting from vi,j to a path L′ starting from vi′ ,j , by replacing the longest prefix of L in Vi with a corresponding path in the Vi′ . It is easy to see (j) that Fi→i′ always outputs valid paths, and is a bijection. By symmetry, we have (j) P rα (L) = P rα (Fi→i′ (L)) for all L ∈ L(vi,j ). For a path L such that V (L) ⊆ Vi , (i) we define P rα (L) be the probability that the random walk exactly finishes L before leaving Vi or restarting. Then, y − z = Mα−1 vi,j′ ,vi,j − Mα−1 vi′ ,j′ ,vi,j 



= L∈L(vi,j′ )

P rα (L)CountL (vi,j ) −

P rα (L)CountL (vi,j ) L∈L(vi′ ,j′ )



= L∈L(vi,j′ )

P rα (L)(CountL (vi,j ) − CountF (j′ ) (L) (vi,j ))



=

i→i′

P rα(i) (L)CountL (vi,j )

L∈L(vi,j′ )∧V (L)⊆Vi

The last equality is because (a) CountF (j′ ) (L) (vi,j ) is zero before the walk i→i′

on L leaves clique Vi′ for the first time, and after it leaves Vi′ , it cancels with (i) CountL (vi,j ); and (b) P rα (L) with V (L) ⊆ Vi is the aggregate probability of all paths with L as the prefix.  (i) Therefore, y − z = L∈L(vi,j′ )∧V (L)⊆Vi P rα (L)CountL (vi,j ) is the expected number of times for a random walk visiting vi,j from vi,j ′ before leaving Vi or restarting. Since the probability for a random walk leaving Vi or restarting 1 . Let the is α + (1 − α)/n, the expected length of a such path is α+(1−α)/n ′ expected number of times vi,j appears in such paths is tj for j = j . Let t be the expected number of times vi,j ′ appears in such paths except the starting  1 and ∀ j, k = j ′ , tj = tk . Furthermore, node. Note that t + j =j ′ tj = α+(1−α)/n t=

(1−α)(n−1) tj n

< tj . We have

n 1 1 n < < tj = y − z < < . n+1 (α + (1 − α)/n)(n) (α + (1 − α)/n)(n − 1) n−1

72

W. Chen et al.

Consider the second claim. We have r =1+

(n − 1)(1 − α) 1−α (n − 1)(1 − α) 1−α µ+ y ≤1+ r+ y. n n n n

Therefore, r ≤

n n−1 .

1 1−(1−α)/n +(n−1)(1−α)y/(n−(1−α))

and r−y
We have

2 n − . n+1 n−1

1−α (m − 1)(1 − α) 1 m−1 r+ x< r+ x m m m m n m−1 n 2 1 < (y + )+ (y − + ) m n−1 m n+1 n−1 n (m − 1)n 2(m − 1) =y+ − + m(n − 1) m(n + 1) m(n − 1) (m − 1)n 2 2 ≤y+ − + b∗ , contradicting the maximality of b∗ . To show the claim, we indirectly assume that, for an antichain A′ ⊆ B ∗ in ′ ∗ H [0, hmax + r], there are vertices uh , u′h ∈ A′ such that H[0, 2(r + d − 2)] ′ contains a directed path P from uh to u′h . Note that A′ is an antichain in the digraph H ∗ [0, hmax +r] induced from H[0, hmax +r] by Vfrm (A)∩Vto (A+r ). Hence ˆ P must visit a vertex uˆh ∈ V [0, hmax +r]−(Vfrm (A)∩Vto (A+r )). By the structure ˆ < h′ ≤ hmax + r. Since uh ∈ Vfrm (A) and of H[0, hmax + r], it holds 0 ≤ h < h ˆ ′h′ +r ˆh is reachable from a vertex in A u ∈ Vto (A ), we see by transitivity that u ˆ ˆ < h′ ≤ hmax + r, it and that uˆh is reachable to a vertex in A+r . Since 0 ≤ h < h ˆ ˆ h +r h ˆ ∈ Vfrm (A) ∩ Vto (A+r ). must hold u ˆ ∈ Vfrm (A) ∩ Vto (A ), a contradiction to u This proves the lemma. ⊓ ⊔ We next show that Step 4 of the algorithm is executable. For a path P in H[0, hmax + r], let P −ir denote the path obtained by replacing each vertex uh in P with the vertex uh−ir (extending the digraph H[0, hmax + r] introducing ′ vertices uh with h′ < 0 if necessary). Lemma 6. The set of paths in P −ir = {P1−ir , P2−ir , . . . , Pb−ir }, i = 0, 1, . . . , ∗ ⌈hmax /r⌉ gives a set P ∗ of b∗ paths that cover all vertices in B[0, r]. Proof. Let A−ir = {uh−ir | uh ∈ A}, i = 0, 1, . . . , ⌈hmax /r⌉. We first claim that Bfrm (A) − Bfrm (A+r ) ⊆ B ∗ and Bto (A+r ) − Bto (A) ⊆ B ∗ hold, where Bfrm (X) (resp., Bto (X)) denotes the set of vertices in B[0, hmax + r] that are reachable from (resp., to) some vertex in X in H[0, hmax + r]. For any vertex uh ∈ Bfrm (A) − Bfrm (A+r ), if uh is not reachable to any vertex in A+r , then A+r ∪ {uh } would be an antichain in H[0, hmax + r] since uh ∈ Bfrm (A+r ), contradiction to the maximality of |A+r | = b∗ . Hence Bfrm (A)−Bfrm (A+r ) ⊆ B ∗ . We can obtain Bto (A+r ) − Bto (A) ⊆ B ∗ analogously. Hence the claim is proved. For each i = 0, 1, . . . , ⌈hmax /r⌉, the b∗ paths in P −ir cover only the vertices in Vfrm (A−ir ) ∩ Vto (A−(i−1)r ) and join the b∗ vertices in A−ir and the b∗ vertices in A−(i−1)r as their endvertices. Note that subsets Vfrm (A−ir ) ∩ Vto (A−(i−1)r ) and Vfrm (A−jr ) ∩ Vto (A−(j−1)r ) are disjoint for any i, j with 0 ≤ i < j ≤ ⌈hmax /r⌉ since H[0, hmax + r] is acyclic and no directed path joins any two vertices in an antichain A−kr . Therefore, the paths in ∪0≤i≤hmax /r⌉ P −ir give rise to a set P ∗ of b∗ paths that covers all vertices in V [0, hmax + r] which belong to Vfrm (A−ir ) ∩ Vto (A−(i−1)r ) for some i = 0, 1, . . . , ⌈hmax /r⌉. Thus the set P ∗ of b∗ paths cover also all vertices in B[0, r], as required. ⊓ ⊔ By Lemma 6, Step 4 can construct the b∗ paths in V [0, hmax + r].

Cop-Robber Guarding Game with Cycle Robber Region u0 u1 t0 t1

...

u7

...

u14

...

u21

...

u28

...

u35

...

u42

...

83 u49

...

|R|=12 t6

...

t11 t12 ...

t18

Fig. 4. H(0, 23) for the example with k = 6 and h = 7, where d = p(k + 1) = 49 holds

It is not difficult to see that the entire running time of algorithm PathRejoin is dominated by the computation in Step 1. By summarizing the above argument, we establish the following result. Theorem 1. Given an undirected graph G = (R ∪ C, E) such that G[R] is a cycle, the minimum number s∗ of cops to win against the robber and a compact strategy by s∗ cops can be found in O((|R| + d)2 |C|(|C| + |E|)) time.

4

Concluding Remarks

The polynomiality of our algorithm partly relies on Lemma 4, which provides the upper bound r + d − 2 on the sufficient size q of digraph H[0, q] which remains to contain a maximum antichain in H[0, ∞]. Hence it would be natural to consider whether the bound is achievable or improvable. We show that the bound cannot be improved up to a constant factor since there is an example G such that for any antichain A ⊆ B[0, r + d − 2] with b∗ = |A| in H[0, r + d − 2] it holds hmax = Ω(d). Such an example is constructed as follows. Choose any integers k ≥ 1 and p ≥ 1. Let R = {v0 , v1 , . . . , v2k−1 } and C = {u0 , u1 , . . . , up(k+1) }. The edge sets are defined as E(R, R) = {(vi , vi+1 ) | 0 ≤ i ≤ 2k − 2} ∪ {(v2k−1 , v0 )}, E(C, C) = {(ui , ui+1 ) | 0 ≤ i ≤ p(k + 1) − 1}, E(R, C) = {(vjk

(mod 2k) , uj(k+1) )

| 0 ≤ j ≤ p, uj(k+1) ∈ C, vjk

(mod 2k)

∈ R}.

Hence R induces a path from G, and d = |C|−1 = p(k +1) holds. Also b∗ ≤ p+1 holds. See Fig. 4 for the example with k = 6 and h = 7. The set of the vertices to be guarded in H[0, r + d − 2] is

84

H. Nagamochi

B[0, r + d − 2] = {uij(k+1) | 0 ≤ j ≤ p, 0 ≤ i = jk for some integer ℓ}.

(mod 2k) + ℓr ≤ r + d − 2

∗ Antichain A = {ujk j(k+1) | 0 ≤ j ≤ p} maximizes its size |A| = p + 1 = b , and satisfies hmax = pk. ′ For each j = 0, 1, . . . , p − 1, two vertices uij(k+1) , ui(j+1)(k+1) ∈ B[0, r + d − 2] form an antichain if and only if i′ = i+r (see Fig. 4). Therefore no other antichain with size p + 1 can have smaller hmax than pk, implying that hmax = Ω(d) holds. If G[R] is not a cycle or a path, then the problem is NP-hard. However, if G[R] contains only three vertices that are adjacent to vertices in C, then the instance can be redescribed as an instance such that G[R] is a cycle of length at most three (the new R consists of the three vertices and shortest paths among these vertices form such a cycle). In this paper, we considered only undirected graphs G = (R ∪ C, E). For directed graphs G = (R ∪ C, E), if G[R] induces a directed cycle, then we can obtain a periodic strategy with the minimum number of cops in the same algorithm since the robber-player can take only the cyclic strategy and Lemma 2(i) remains valid. The simplest open problem in digraphs would be the case where G[R] is a path oriented in the both directions (note that G[C] is a digraph now). Again we can solve the case where G[R] contains only two vertices that are adjacent to vertices in C by reducing to an instance such that G[R] is a cycle of length 2 (which is solvable with our algorithm even for a digraph G[C]).

References 1. Aigner, M., Fromme, M.: A game of cops and robbers. Discrete Appl. Math. 8(1), 1–11 (1984) 2. Fomin, F.V., Golovach, P.A., Hall, A., Mihal´aak, M., Vicari, E., Widmayer, P.: How to Guard a Graph? In: Hong, S.-H., Nagamochi, H., Fukunaga, T. (eds.) ISAAC 2008. LNCS, vol. 5369, pp. 318–329. Springer, Heidelberg (2008) 3. Fomin, F.V., Golovach, P.A., Hall, A., Mihal´ak, M., Vicari, E., Widmayer, P.: How to guard a graph? Technical Report 605, Dep. of Comp. Sc., ETH Zurich (2008), http://www.inf.ethz.ch/research/disstechreps/techreports 4. Nowakowski, R., Winkler, P.: Vertex-to-vertex pursuit in a graph. Discrete Math 43(2-3), 235–239 (1983) 5. Quilliot, A.: Some results about pursuit games on metric spaces obtained through graph theory techniques. European J. Combin. 7(1), 55–66 (1986) 6. Schrijver, A.: Combinatorial Optimization, Polyhedra and Efficiency. Springer, Berlin (2003)

Covered Interest Arbitrage in Exchange Rate Forecasting Markets Feng Wang, Yuanxiang Li, and Cheng Yang State Key Lab. of Software Engineering, Wuhan University, Wuhan 430072, China [email protected]

Abstract. The non-existence of arbitrage in an efficient foreign exchange markets is widely believed. In this paper, we deploy a forecasting model to predict foreign exchange rates and apply the covered interest parity to evaluate the possibility of an arbitrage opportunity. Surprisingly, we substantiate the existence of covered interest arbitrage opportunities in the exchange rate forecasting market even with transaction costs. This also implies the inefficiency of the market and potential market threats of profit-seeking investors. In our experiments, a hybrid model GA-BPNN which combines adaptive genetic algorithm with backpropagation neural network is used for exchange rate forecasting.

1 Introduction Foreign exchange rate market is one of the most important financial markets. Recently, the foreign exchange rate market has undergone many structural changes [1,2,3]. Those changes which emphasize on institutional developments and technological advances have a significant impact on various dimensions of the market, such as the mechanic of trading, the size of the market, and the efficiency of the market. In an efficient market, prices can fully and instantaneously reflect all available relevant information. Hence, the traders in an efficient market cannot make profits at no risk by exploiting current information. Exchange market efficiency has attracted more and more attention in recent years. Frenkel and Levich [4] studied the covered interest arbitrage and demonstrated that it does not entail unexploited profit opportunities. Taylor [5] suggested that profitable deviations from the covered interest parity represent riskless arbitrage opportunities and so indicate market inefficiency. Namely, no arbitrage opportunities exist if the market is considered as an efficient market. It was known that it is NP-complete to find an arbitrage opportunity in the friction markets. Maocheng Cai and Xiaotie Deng have studied the computational complexity of arbitrage in various models of exchange systems [6]. And since the exchange rates have affected the financial market so dramatically, in order to control the market better and keep the market back to efficiency, we employ a Genetic Algorithm based Neural Network model to predict the foreign exchange rates in future and make a forecast of the market efficiency by testing the arbitrage opportunity among the currencies. If there exist covered interest arbitrage opportunities in the prediction results, the market might be inefficient while the traders can do some arbitrage activities which lead the market back to be efficient. X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 85–96, 2009. c Springer-Verlag Berlin Heidelberg 2009 

86

F. Wang, Y. Li, and C. Yang

The structure of this paper is as follows. Section 2 describes the methodology employed here to predict the foreign exchange rates and give the experimental forecasting results using the in-sample data sets. The analysis work of the results which used the covered interest parity for testing arbitrage opportunities are detailed in Section 3. Finally, Section 4 summarizes and concludes.

2 GA-BPNN Forecasting Model and Empirical Results 2.1 GA-BPNN Forecasting Model Foreign exchange rates are affected by many highly correlated economic, political and even psychological factors. The prediction of them has many theoretical and experimental challenges. Thus, various kinds of forecasting methods have been developed by many researchers and experts. The Auto-Regressive Integrated Moving Average (ARIMA) technique proposed by Box and Jenkins’ [7] has been widely used for time series forecasting for more than two decades. And the artificial neural network (ANN), the well-known function approximates in prediction and system modeling, has recently shown its great applicability in time-series analysis and forecasting [8]. Meanwhile, many optimization techniques combining ANN were proposed in order to speed up the process and to promote accuracy.In the field of optimization methods, genetic algorithm (GA) is the most popular topic. The GA optimization process consists of searching a group of feasible solutions. This search goes along the orientation of general optimum avoiding the local optima. By utilizing the nonlinear mapping ability of ANN and the ability of GA to find the optimum solution, the hybrid prediction model is constructed. BP-NN Forecasting. In the following we will use Back-propagation (BP) as the training algorithm in our Neural Network based prediction model. The BP training algorithm uses steepest gradient descent technique to minimize the sum-of-squared error E over all training data. Suppose that a network has M layers and N nodes, and the transfer function of every node is usually a sigmoid function, where f( x) = 1+e1−x , yi is an output from the output layer i, Oi is an output of any unit i in a hidden layer. Wij is the weight of the connection from j − th unit to i − th unit. If the initial sample pairs are (xk , yk )(k = 1, 2, · · ·, n) and Oik is the output of unit i connected with k − th sample, the input of unit j is  wij Oik (1) netjk = i

So the output of unit j is

Ojk = f (netjk )

(2)

During the training process, each desired output Oj is compared with actual output yj and E is calculated as sum of squared error at the output layer. n

E=

1 (yk − yˆk )2 2 k=1

(3)

Covered Interest Arbitrage in Exchange Rate Forecasting Markets

87

The weight wij is updated in the n − th training cycle according to the following equation. The parameters η and α are the learning rate and the momentum factor respectively. The learning rate parameter controls the step size in each iteration. ∆wij (n) = −η

∂E + α∆wij (n − 1) ∂wij

(4)

The performance of a neural network depends on a number of factors, e.g., initial weights chosen, different learning parameters used during the training process and the number of hidden units. The architecture of the neural network is also very important, and here we choose 5 neurons in the input layer, 3 neurons in the hidden layer and 1 neuron in the output layer. This 5-3-1 model has been testified as a good choice in some previous work [10]. For the prediction model, we used a time-delayed method combined with moving averages. The normalized exchange rates of the previous periods are fed to a neural network to do the forecasting work. In our 5-3-1 model, the inputs of the neural network are xi−4 , xi−3 , xi−2 , xi−1 and xi , while the output of the neural network is xi+1 , which stands for the next week’s exchange rate. The advantage of moving average is that it tends to smooth out some of the irregularities that exist between the market daily rates. Following Dow-Jones theory, moving averages are used as inputs to the neural network [11]. In our study, we use MA5 to feed to the neural networks to forecast the following week’s exchange rate, where the exchange rates should be pretreated as follows: x′i = (xi−2 + xi−1 + xi + xi+1 + xi+2 )/5

(5)

Where x′i denotes the new MA5 exchange rate which used in the training work of the neural network. GA Optimization. When using BP-NN, a number of parameters have to be set before any training, including the neural network topology and the weights of the connections. And as we mentioned above, ANN often gets trapped in local optima, which can affect the forecasting performance. In order to improve the performance of the neural network forecasting, we employ the genetic algorithm (GA) to optimize the weights of the connections before the BP training process. Genetic algorithm is a common tool in optimization engineering. When we form the optimization problem, the space of variables and the encoding scheme should be defined. Here we utilize real-coded chromosome to encode the weights of the neural network. The weights will be optimized by GA with Roulette wheel selection, one point crossover and random mutation. The selection probability of individual i can be defined as, n  fj ) pi = fi /( j=1

where fi is the fitness of individual i.

(6)

88

F. Wang, Y. Li, and C. Yang

Here we use one point crossover operator, and for each bit in the chromosome, the crossover probability pc is pc = (fmax − fi )/(fmax − f¯)

(7)

where f¯ represents the average fitness of the population, while fmax stands for the maximum fitness in the population. There are two reasons why we choose the crossover probability as shown in the formula 7. Firstly, it can speed up the convergence velocity while the individuals in the population can get to the maximum fitness as much as possible in the evolution process. Secondly, it can help the population evolve to achieve the global optima. And the crossover operation can be finished by choosing two individuals as follows according to the above crossover probability pc . S1′ = r ∗ S1i + (1 − r) ∗ S2i

(8)

S2′ = r ∗ S2i + (1 − r) ∗ S1i

(9)

pm = (fmax − fi )/100(fmax − f¯)

(10)

where r is randomly generated within the range (0, 1)and i is the crossover point. S1′ and S2′ are the offsprings of the two individuals S1 and S2 . The mutation probability pm for each bit in the individual is

Then we select a bit j from individual Si by random, and generate two random numbers ζ and η, where 0 < ζ, η < 1. The new individual Si′ is generated like this.  (1 − η) ∗ Si , 0 < ζ ≤ 0.5; ′ Si = (11) (1 + η) ∗ Si , 0.5 < ζ < 1.

One crucial aspect of GA is the selection of fitness function. The fitness function is defined as follows.  f = 1/( (yi − oi )2 ) (12) where yi is the output of the network i, as well as oi is the expected output.

2.2 Evaluation of GA-BPNN Forecasting Model The forecasting performance of the GA-BPNN is evaluated against a number of widely used statistical metric, namely, Normalized Mean Square Error (NMSE), Mean Absolute Error (MAE), Directional Symmetry (DS), Correct Up trend (CU) and Correct Down trend (CD). Here we employed the most common and effective measurement NMSE to evaluate the performance of the forecasting results.  (xk − xˆk )2 1  = 2 (xk − x ˆk )2 (13) N M SE = k 2 (x − x ¯ ) σ N k k k k

Where x ˆk is the forecasting value of xk , σ 2 is the estimated variance of the data, x ¯k is the mean, and N is the size of the forecasting results. If the estimated mean of the data is used as predictor, NMSE is 1.0.

Covered Interest Arbitrage in Exchange Rate Forecasting Markets

89

Table 1. Prediction performance evaluation for the currencies Exchange Rates AUD/USD EUR/USD GBP/USD JPY/USD

N M SE 0.0898 0.1091 0.1578 0.1263

Dsat 0.7121 0.7283 0.6979 0.6917

In order to help the investor to make a trading strategy of buying or selling in one currency to go long in the other, another evaluation measure which represents the directional change is involved. As we mentioned above, x ˆk is the forecasting value of xk , directional change statistics can be expressed as 1  Dsat = ak (14) N k

where ak = 0 if (xt+1 −xt)(ˆ xt+1 −xt ) < 0, and ak = 1 otherwise. When the predicted exchange rate change is positive, the trading strategy is to buy the domestic currency at the spot exchange rate. When the predicted exchange rate is negative, the trading strategy is to switch the domestic currency to another currency. 2.3 Experimental Results Here we present the performance of the GA-BPNN model developed for the four major internationally traded exchange rates, namely AUD/USD, EUR/USD, GBP/USD, and JPY/USD rates. The data used are daily spot rates which obtained from Pacific Exchange Rate Service (http://fx.sauder.ubc.ca/data.html), provided by Professor Werner Antweiler, University of British Columbia, Vancouver, Canada. We take the daily exchange rate data from 1 October 2004 to 31 December 2005 as the training data sets, while the daily data from 1 January 2006 to 1 November 2006 as the testing data sets. And we use the NMSE which mentioned above to evaluate the forecasting performance. Table 1 shows the performance of the currencies. From the viewpoint of two indicators, NMSE and Dsat , the BP-NN model here performs well compared with some similar works [?,10]. We can make a further confirmation of this from the actual forecasting results to be shown later. The forecasting results and the actual time series of the exchange rates of AUD/USD, EUR/USD, GBP/USD and JPY/USD are showed in figure 1. Conclusions can be drawn by the graphs presented here that, the neural networks can simulate the results very close to the actual ones and the forecasts are convincible. In the following section, we will try to find the arbitrage opportunities in the foreign exchange market by analyzing these forecasting results.

3 Arbitrage Analysis with Forecasting Exchange Rates Arbitrage is an activity which traders or investors take advantage of the disequilibrium existed in the financial market to benefit themselves. It widely exists in the modern

90

F. Wang, Y. Li, and C. Yang 1.42

0.86 NN OUTPUT AUD/USD TARGET

1.4

NN OUTPUT EUR/USD TARGET 0.84

1.38

Simulation result

Simulation result

0.82 1.36 1.34 1.32

0.8

0.78

1.3 0.76 1.28 0.74

1.26 1.24

0

100

200

300

400

0.72

500

0

100

200

Time

300

400

500

Time

0.59

122 NN OUTPUT GBP/USD TARGET

0.58

NN OUTPUT JPY/USD TARGET

120 118

0.57 Simulation result

Simulation result

116 0.56 0.55 0.54

114 112 110 108

0.53 106 0.52 0.51

104 0

100

200

300 Time

400

500

102

0

100

200

300

400

500

Time

Fig. 1. Forecasting results using time-delay model combined with MA5, Oct 2004- Nov 2006

financial economy. The existence of the disequilibrium implies that the market goes against the law of one price, and as a matter of fact, arbitrage is a process which arbitragers make use of these opportunities and make the market move to equilibrium. The disequilibrium of financial market has many types of arbitrage. The exchange arbitrage involves the simultaneous purchase and sale of a currency in different foreign exchange markets. Arbitrage becomes profitable whenever the price of a currency in one market differs from that in another market. In order to keep the equilibrium of the exchange rate trading market, arbitrage is not available or taken as a close position. 3.1 Covered Interest Arbitrage without Transaction Costs It is widely believed that the interest rates are the most important variables determining the exchange rates. And the interest arbitrage is caused by the transfer of funds from one currency to another by taking advantage of higher interest rates of return. If the interest rates of two currencies are not suitable to their current exchange rates, it might have interest arbitrage opportunities in the market. The covered interest parity (CIP), which ensures that equilibrium prices in forward currency markets are maintained based on interest rate differentials, is very important in the foreign exchange markets [12]. Profitable deviations from CIP represent the existence of riskless arbitrage opportunities and may indicate the inefficiency of the market. A true deviation from CIP represents a profitable arbitrage opportunity at a particular point in time to a market trader. In order to measure such deviations, therefore, it is important to have data on the appropriate exchange rates and interest rates recorded at the same instant in time and at which a trader could have dealt with. With respect to CIP and following [13,14], we give a definition about the covered interest arbitrage model without transaction costs between the spot and forward exchange rates as follows.

Covered Interest Arbitrage in Exchange Rate Forecasting Markets

91

Definition 1. Let es denotes the spot exchange rate, ef denotes forward exchange rate (forecasting rate), im denotes domestic interest rate and im ∗ denotes foreign interest rate. Then, due to the CIP theory, we have ef 1 + im = es 1 + im ∗

(15)

Suppose C denotes the equilibrium rate, we can make a further illation that (16)

C = ef (1 + im ∗) − es (1 + im ) if C > 0, then arbitrage exists, otherwise no arbitrage.

We deploy the potential arbitrage opportunities by applying the covered interest parity into the analysis of the forecasting results. According to the GA-BPNN model introduced in Section 2, we firstly do the experiments with one week (five transaction days) forecasting results. Figure 2 depicts the arbitrage profits denoted by C value which we computed according to the formula in definition 1 by using our forecasting exchange rates. In definition 1, it is clear that if C > 0, then arbitrage opportunities exist in the market. The corresponding interest rates of the domestic and foreign currencies are obtained from the IMF’s website (www.imf.org/external/data.html). The graphs in figure 2 obviously show that about half of the C values are positive, that means, if the forecasting data are reasonable, the forecasting foreign exchange markets do have potential arbitrage opportunities without the transaction cost. And those Profits in JPY&USD WITHOUT transaction cost

Profits in EUR&USD WITHOUT transaction cost

0.007

JPY/USD USD/JPY

0.006 0.005

) e 0.004 u l a 0.003 V C 0.002 ( s e 0.001 u l a 0 V t i -0.001 f o -0.002 r P

1

2

3

4

5

-0.003 -0.004 -0.005

0.009 0.008 0.007 0.006 ) e 0.005 u 0.004 l a 0.003 V C 0.002 ( 0.001 s e 0 u l a -0.001 V -0.002 t i -0.003 f o -0.004 r P -0.005 -0.006 -0.007 -0.008 -0.009

Time(day) Profits in GBP&USD WITHOUT transaction cost 0.012 0.011 0.01 0.009 0.008 ) e 0.007 u 0.006 l a 0.005 V 0.004 C 0.003 ( 0.002 s e 0.0010 u l -0.001 a -0.002 V -0.003 t i -0.004 f -0.005 o r -0.006 P -0.007 -0.008 -0.009 -0.01 -0.011 -0.012

2

3

Time(day)

4

1

2

3

4

5

Time(day)

Profits in AUD&USD WITHOUT transaction cost

GBP/USD USD/GBP

1

EUR/USD USD/EUR

5

0.012 0.011 0.01 0.009 ) 0.008 e 0.007 u 0.006 l a 0.005 V 0.004 C 0.003 ( 0.002 s 0.001 e u 0 l a -0.001 V -0.002 t -0.003 i f -0.004 o -0.005 r -0.006 P -0.007 -0.008 -0.009 -0.01 -0.011

AUD/USD USD/AUD

1

2

3

4

5

Time(day)

Fig. 2. Covered interest arbitrage profits among currencies without transaction cost(one week)

92

F. Wang, Y. Li, and C. Yang

days with positive C values are the possible arbitrage time of the corresponding currencies in the market. To make a further confirmation, we do the same experiments by using one month forecasting rates. The arbitrage profits derived by one month’s forecasting exchange rates with 22 transaction days are showed in figure 3, which indicate that nearly half of C values are positive. That reveals there are many potential arbitrage opportunities in the market. However, the distribution of C values is not the same as in figure 2. As showed in figure 3, the arbitrage can be obtained in duplex way in the one month forecasting market. While in figure 2, the arbitrage profits are obtained in simplex way for US dollar against the currencies EUR, GBP and AUD, except for JPY. And under most circumstances, if the trader sells dollar and buys other currencies, he can make profits at no risk. But this is not true if he buy JPY. 3.2 Covered Interest Arbitrage with Transaction Costs In Section 3.1, we have testified the arbitrage opportunities in the forecasting exchange rate markets without transaction cost. But in the actual exchange market, transaction cost is very important for covered interest parity. As is well known, transaction cost in foreign exchange market implies the existence of a neutral range around the interest parity line. No additional arbitrage profitable if the market choose an appropriate transaction cost in that range. The transaction cost is not absent in real market, so the previous formula should be defined considering the real cost of transaction. Supposing the one-way transaction cost between the domestic currency and the foreign currency is t, the model on the covered interest arbitrage with transaction costs is established as follows.

Profits in JPY&USD WITHOUT transaction cost 0.021 0.0189 0.0168 0.0147 ) 0.0126 e u 0.0105 l a 0.0084 V C 0.0063 ( s 0.0042 e u 0.0021 l 0 a V -0.0021 t -0.0042 i f -0.0063 o r -0.0084 P -0.0105 -0.0126 -0.0147 -0.0168

JPY/USD USD/JPY

1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Profits in EUR&USD WITHOUT transaction cost 0.0189 0.0168 0.0147 0.0126 ) 0.0105 e u 0.0084 l a 0.0063 V C 0.0042 ( s 0.0021 e 0 u l -0.0021 a V -0.0042 t -0.0063 i f -0.0084 o r -0.0105 P -0.0126 -0.0147 -0.0168 -0.0189

EUR/USD USD/EUR

1

2

Time(day)

GBP/USD USD/GBP

1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Time(day)

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Time(day) Profits in AUD&USD WITHOUT transaction cost

Profits in GBP&USD WITHOUT transaction cost 0.0189 0.0168 0.0147 0.0126 ) e 0.0105 u l 0.0084 a 0.0063 V C 0.0042 ( 0.0021 s e 0 u l -0.0021 a V -0.0042 t i -0.0063 f o -0.0084 r -0.0105 P -0.0126 -0.0147 -0.0168 -0.0189

3

0.0189 0.0168 0.0147 0.0126 ) e 0.0105 u l 0.0084 a 0.0063 V C 0.0042 ( 0.0021 s e 0 u l -0.0021 a V -0.0042 t i -0.0063 f o -0.0084 r -0.0105 P -0.0126 -0.0147 -0.0168 -0.0189

AUD/USD USD/AUD

1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Time(day)

Fig. 3. Covered interest arbitrage profits among currencies without transaction cost(one month)

Covered Interest Arbitrage in Exchange Rate Forecasting Markets

93

Profits in EUR&USD WITH transaction cost

Profits in JPY&USD WITH transaction cost 0.007

0.006 0.005

1

2

EUR/USD USD/EUR

0.006 0.005

JPY/USD USD/JPY

0.004

) e 0.003 u l 0.002 a V C 0.001 ( s 0 e u l -0.001 a V -0.002 t i -0.003 f o r P -0.004

3

4

5

-0.005

) 0.004 e 0.003 u l 0.002 a V 0.001 C 0 ( s e -0.001 u l -0.002 a V -0.003 t -0.004 i -0.005 f o -0.006 r P -0.007

1

2

3

4

5

-0.008 -0.009

-0.006 -0.007

-0.01

Time(day)

Time(day) Profits in AUD&USD WITH transaction cost

Profits in GBP&USD WITH transaction cost 0.0105

0.0105

) 0.0063 e u l 0.0042 a V 0.0021 C 0 ( s e -0.0021 u l a V -0.0042 t i -0.0063 f o -0.0084 r P -0.0105

1

2

3

4

AUD/USD USD/AUD

0.0084

GBP/USD USD/GBP

0.0084

) e u l a V

5

0.0063 0.0042 0.0021

C 0 ( s e u -0.0021 l a -0.0042 V t -0.0063 i f o r -0.0084 P

1

2

3

4

5

-0.0105

-0.0126

-0.0126

-0.0147

-0.0147

Time(day)

Time(day)

Fig. 4. Covered interest arbitrage profits among currencies with transaction cost(one week)

Profits in JPY&USD WITH transaction cost 0.02 0.019 0.018 0.017 0.016 0.015 0.014 ) 0.013 e 0.012 u 0.011 0.01 l 0.009 a V 0.008 0.007 C 0.006 0.005 ( 0.004 s e 0.003 u 0.002 0.001 l 0 a -0.001 V -0.002 -0.003 t -0.004 -0.005 i -0.006 f o -0.007 r -0.008 P -0.009 -0.01 -0.011 -0.012 -0.013 -0.014 -0.015 -0.016 -0.017

JPY/USD USD/JPY

1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Profits in EUR&USD WITH transaction cost 0.019 0.018 0.017 0.016 0.015 0.014 0.013 ) 0.012 e 0.011 u 0.01 l 0.009 a 0.008 V 0.007 0.006 C 0.005 ( 0.004 s 0.003 0.002 e 0.001 u 0 l -0.002 -0.001 a -0.003 V -0.004 t -0.005 i -0.006 f -0.007 o -0.008 r -0.009 -0.01 P -0.011 -0.012 -0.013 -0.014 -0.015 -0.016 -0.017 -0.018

EUR/USD USD/EUR

1

2

3

Time(day) Profits in GBP&USD WITH transaction cost 0.019 0.018 0.017 0.016 0.015 0.014 0.013 ) 0.012 e 0.011 0.01 u 0.009 l a 0.008 V 0.007 0.006 C 0.005 0.004 ( s 0.003 e 0.002 0.001 u -0.0010 l a -0.002 V -0.003 -0.004 t -0.005 i -0.006 f -0.007 o -0.008 r -0.009 -0.01 P -0.011 -0.012 -0.013 -0.014 -0.015 -0.016 -0.017 -0.018

GBP/USD USD/GBP

1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Time(day)

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Time(day) Profits in AUD&USD WITH transaction cost 0.019 0.018 0.017 0.016 0.015 0.014 0.013 ) 0.012 e 0.011 0.01 u 0.009 l a 0.008 V 0.007 0.006 C 0.005 0.004 ( s 0.003 e 0.002 0.001 u -0.0010 l a -0.002 V -0.003 -0.004 t -0.005 i -0.006 f -0.007 o -0.008 r -0.009 -0.01 P -0.011 -0.012 -0.013 -0.014 -0.015 -0.016 -0.017 -0.018

AUD/USD USD/AUD

1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22

Time(day)

Fig. 5. Covered interest arbitrage profits among currencies with transaction cost(one month)

Definition 2. Let es denotes the spot exchange rate, ef denotes forward exchange rate (forecasting rate), im denotes domestic interest rate and im ∗ denotes foreign interest rate. Then, if the transaction cost is taken into account, due to the CIP theory, we have

94

F. Wang, Y. Li, and C. Yang

ef 1 + im = es (1 − t)2 1 + im ∗

(17)

C = ef (1 + im ∗)(1 − t)2 − es (1 + im )

(18)

The equilibrium rate C is

and the arbitrage opportunity exists if and only if C is positive. The estimation of the transaction cost is very difficult to implement in real trading market. Most research work have focused on estimating the transaction cost in recent years. Frenkel and Levich [15] reported that the transaction cost was extraordinary small, in the range of 0.05% to 0.1%. McCormick [16] measured the transaction cost through the analysis of triangular transaction condition for a different period and came up with estimates of 0.09% to 0.18%. Kevin Clinton [17] derived the strong theoretical result that the single transaction cost would be within 0.06%. Lyons [18] suggested that a transaction cost of 0.01-0.02% for institutional traders is the norm, and Neely and Weller [19] argued that a transaction cost of 0.03% between market makers was more realistic. To assess the robustness of our trading results, we consider the maximum value 0.2% which usually used in the literature for the one-way transaction cost t. Figure 4 shows the arbitrage probabilities in a one-week forecasting rates, while figure 5 illustrates the probabilities in a one-month forecasting rates. The arbitrage profits derived by one week forecasting rates between the currencies are showed in figure 4. From figure 4, for the currencies EUR, GBP and AUD against USD, arbitrage profits can be easily made by some simplex transactions. In one month forecasting rate case, the results are different. Lots of arbitrage profits are also gained by the duplex transaction which showed in figure 5. Here, conclusion can be safely given that, even though the transaction cost is taken into account, we can still make arbitrage profits while the forecasting exchange market still has potential arbitrage opportunities. 3.3 Remarks and Discussion Experimental results in finance markets have showed that arbitrage dose exist in reality. Some opportunities were observed to be persistent for a long time. Because of the asymmetry of information in the market, the arbitrage opportunity was not immediately identified. Zhongfei Li et al. have found the qualification of the existence of an arbitrage opportunity with fixed and proportional transaction cost from the aspect of theoretical analysis [20]. Taylor has tested the profitable deviations from the parity which represent riskless arbitrage opportunities using high-frequency, contemporaneously sampled data gathered in the London foreign exchange market [5]. The data they used are historical data, so the experiments just show the features of the foreign exchange market in the past but in future. In our work, we study the existence of arbitrage in a prediction way by using experimental results generated by a neural network forecasting model. Firstly, we assume that the transaction cost is fixed for every two currencies between the bid and ask spread and the equilibrium prices exist between spot and forward exchange rates. Furthermore, we discuss here the feasibility of the covered interest arbitrage transaction and calculate

Covered Interest Arbitrage in Exchange Rate Forecasting Markets

95

the covered interest arbitrage opportunities. What’s more important, we not only prove the existence of arbitrage opportunities in the market but provide the potential arbitrage opportunities by forecasting results. The identification of arbitrage implies that risk-free profitable opportunities exist. Traders or investors can take advantage of those opportunities simply by focusing their attention on the markets in which profitable opportunities are available. Comparing with the theoretical analysis results, it is more guidable and meaningful to the research on the real market.

4 Conclusion In this paper, we explored the existence of arbitrage by studying a large size data of five currencies to predict exchange rates. We firstly used a GA-BPNN model to predict the exchange rates among the currencies GBP, JPY, USD, EUR, and AUD. The results indicated forecasting has a good performance, which means the forecasting model and the corresponding results are reasonable. Then, we analyzed these forecasting rates by using the covered interest parity and triangular arbitrage model, and found that there are in fact potential arbitrage opportunities in the foreign exchange forecasting market. Although some researchers have testified the existence of arbitrage in the real exchange rate market, still no work has shown the forecasting of arbitrage opportunities. This finding is very inspiring and the investors could make statistically significant profits which would lead the arbitrage market move to equilibrium, if they follow the trading strategy with buy or sell signals generated by the exchange rate forecasts.

References 1. Goodhart, C., Figlioli, L.: Every minute counts in the foreign exchange markets. Journal of International Monetary and Finance 10, 23–52 (1991) 2. Oh, G., Kim, S., Eom, C.: Market efficiency in foreign exchange markets. Physica A 2 (2007) 3. Sarantis, N.: On the short-term predictability of exchange rates: A bvar time-varying parameters approach. Journal of Banking and Finance 30, 2257–2279 (2006) 4. Frenkel, J.A., Levich, R.M.: Covered interest arbitrage: Unexploited profits? The Journal of Political Economy 83(2), 325–338 (1975) 5. Taylor, M.P.: Covered interest parity: A high-frequency, high-quality data study. Economica 54(216), 429–438 (1987) 6. Cai, M., Deng, X.: Complexity of Exchange Markets. In: Handbook on Information Technology in Finance, ch. 28, pp. 689–705. Springer, Heidelberg (2008) 7. Box, G.E., Jenkins, G.M.: Time Series Analysis: Forecasting and Control. Holden Day (1976) 8. Green, H., Pearson, M.: Neural nets for foreign exchange trading, in: Trading on the Edge: Neural, Genetic, and Fuzzy Systems for Chaotic Financial Markets. Wiley, Chichester (1994) 9. McClelland, J.L., Rumelhart, D.E.: Parallel distributed processing: Explorations into the micro-structure of cognition. MIT Press, Cambridge (1986) 10. Yao, J., Tan, C.L.: A case study on using neural networks to perform technical forecasting of forex. Neurocomputing 34(1-4), 79–98 (2000) 11. Teweles, R., Bradley, E., Teweles, T.: The stock market, pp. 374–379. Wiley, Chichester (1992)

96

F. Wang, Y. Li, and C. Yang

12. Batten, J.A., Szilagyi, P.G.: Covered interest parity arbitrage and temporal long-term dependence between the US dollar and the Yen. Physica A 376, 409–421 (2007) 13. Crowder, W.J.: Covered interest parity and international capital market efficiency. International Review of Economics & Finance 4(2), 115–132 (1995) 14. Popper, H.: Long-term covered interest parity: evidence from currency swaps. Journal of International Money and Finance 4, 439–448 (1993) 15. Frenkel, J.A., Levich, R.M.: Transaction costs and interest arbitrage: Tranquil versus turbulent periods. Journal of Political Economy 85(6), 1209–1226 (1977) 16. McCormick, F.: Covered interest arbitrage: Unexploited profits? comment. Journal of Political Economy 87(2), 411–417 (1979) 17. Clinton, K.: Transactions costs and covered interest arbitrage: Theory and evidence. Journal of Political Economy 96(2), 358–370 (1988) 18. Lyons, R.K.: The Microstructure Approach to Exchange Rates. MIT Press, Cambridge (2001) 19. Neely, C.J., Weller, P.A.: Intraday technical trading in the foreign exchange market. Journal of International Money and Finance 22, 223–237 (2003) 20. Li, Z., Ng, K.W.: Looking for arbitrage or term structures in frictional markets. In: Deng, X., Ye, Y. (eds.) WINE 2005. LNCS, vol. 3828, pp. 612–621. Springer, Heidelberg (2005)

CFI Construction and Balanced Graphs⋆ Xiang Zhou1,2 1

State Key Laboratory of Computer Science, Institute of Software, Chinese Academy of Sciences 2 School of Information Science and Engineering, Graduate University of Chinese Academy of Sciences [email protected]

Abstract. In this article, we define a new variant of Cai-F¨ urerImmerman construction. With this construction and some conditions of Dawar and Richerby, we are able to show that inflationary fixed point logic with counting (IFP+C) does not capture PTIME on the class of balanced graphs.

1

Introduction

The question of whether there is a logic that captures polynomial time on finite unordered structures is the central open problem in descriptive complexity theory (see [6] for the exact definition of logics for PTIME and some related results). It was raised by Chandra and Harel in [3] and Gurevich in [12]. It is equivalent to whether there is a logic capturing PTIME on all graphs. Inflationary fixed point logic with counting, IFP+C, was once conjectured to be such a logic. But Cai, F¨ urer and Immerman [2] showed IFP+C cannot capture PTIME on all graphs, using one construction we refer to as CFI construction in this article. Although IFP+C has failed to express exactly the polynomial-time decidable properties on all graphs, it provides a natural level of expressiveness within PTIME. To get more understanding of this expressiveness, researchers wonder on what kind of restricted classes of graphs IFP+C can capture PTIME. Some classes of graphs have been shown to admit such capturing results, like trees [14], planar graphs [9], graphs with bounded tree-width [7], embeddable graphs [10] and K5 -free graphs [11]. Moreover, Grohe conjectured that IFP+C can capture PTIME on any proper minor-closed class of graphs [9][11]. It is also interesting to establish the non-capturing result for one specific graph class. A basic fact is that every formula of IFP+C is equivalent to a ω ω is the union of its , where C∞ω formula of the infinitary logic with counting, C∞ω  k ω bounded variable fragments, C∞ω = k∈ω C∞ω . Thus to show that IFP+C does not capture PTIME on graph class G, it suffices to show that in G there are two PTIME-distinguishable families of graphs {Gk } and {Hk } such that Gk and Hk k k are equivalent in C∞ω , Gk ≡C∞ω Hk , for every k. Obviously the central issue ⋆

Supported by the National Natural Science Foundation of China under Grant No. 60721061 and 60833001.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 97–107, 2009. c Springer-Verlag Berlin Heidelberg 2009 

98

X. Zhou

is to construct two required families of graphs. For this task, CFI construction accompanying with extra conditions seems to be the only tool developed in the literature. Cai et al. showed that for every graph G, we can construct two graphs k   X(G) and X(G) such that X(G) ≡C∞ω X(G) if G has no separator of size k.  explicit, and showed Dawar and Richerby [5] made the gadgets in X and X k C∞ω  X(G) if G is connected and G has minimum degree at least that X(G) ≡ 2 and tree-width at least k. With this variant of CFI construction, Dawar and Richerby established that IFP+C cannot capture PTIME on bipartite graphs and directed acyclic graphs, and moreover, that the CFI construction cannot be used to refute Grohe’s conjecture. In graph theory, perfect graphs and some other related graphs have been extensively studied (see [1][8][17] for introduction). They form a huge family of graph classes and give us much room to discuss the questions about logic for PTIME. Nevertheless, there are few works of this aspect done in the literature of descriptive complexity theory. In this article, we establish that IFP+C cannot capture PTIME on balanced graphs and thus make some progress. Balanced graphs are particular bipartite graphs which have no induced cycles of length 2 mod 4. They are special perfect graphs and play an important role in the theory of integer programming as with perfect graphs(see [17] chapter 6 for more details). To prove the non-capturing result, we define a new variant of CFI construction, with which we can construct two balanced graphs X(G) and  X(G) for every graph G. The same conditions of Dawar and Richerby are used k  to guarantee X(G) ≡C∞ω X(G). The remainder of the article is structured as follows: in Section 2, some backgrounds are introduced; and in Section 3, our variant of CFI construction is defined and its crucial properties are proved; in Section 4, it is shown that the conditions of Dawar and Richerby suffice for our construction and the noncapturing result is established; finally in Section 5, some conclusions are made.

2 2.1

Background Graph Notations

A graph is a pair G = (V, E) of sets such that E ⊆ [V ]2 , where [V ]2 denotes the set of all 2-element subsets of V . The elements of V are the vertices of the graph G, usually referred to as V (G); the elements of E are its edges, referred to as E(G). The number of vertices of G is its order, written as |G|. We also view graphs as relational structures with E(G) being a symmetric and irreflexive relation on V (G). Two vertices u, v of G are adjacent, or neighbours, if uv is an edge of G. The set of neighbours of a vertex v in G is denoted by NG (v), or briefly by N (v). The degree dG (v), or briefly d(v), of a vertex v is the number of neighbours of v. The number δ(G) := min{d(v)|v ∈ V } is the minimum degree of G. Subgraphs, induced subgraphs, union and disjoint union of graphs are defined in the usual way. We write G[W ] to denote the induced graph of G with vertex set W ⊆ V (G), and we write G − W to denote G[V (G) \ W ]. Paths and cycles in

CFI Construction and Balanced Graphs

99

graphs are defined in the usual way. The length of a path or cycle is the number of its edges. An inner vertex of a path is a vertex that is not an endpoint. Two or more paths are independent if none of them contains an inner vertex of another. Connectedness and connected components are defined in the usual way. Let G and H be two graphs. We call G and H isomorphic, written as G ≃ H, if there exists a bijection ϕ : V (G) → V (H) with uv ∈ E(G) ⇔ ϕ(u)ϕ(v) ∈ E(H) for all u, v ∈ V (G). Such a map ϕ is called an isomorphism; if G = H, it is called an automorphism. Let p be a map with do(p) ⊆ V (G) and rg(p) ⊆ V (H), where do(p) and rg(p) denote respectively the domain and the range of p . Then p is said to be a partial isomorphism from G to H if p is an isomorphism between G[do(p)] and H[rg(p)]. A tree is an acyclic and connected graph. A graph is complete if all the vertices are pairwise adjacent. A complete graph on n vertices is a K n . A graph is chordal if it contains no induced cycles of length more than 3. A bipartite graph is a graph whose vertices can be divided into two disjoint sets U and W such that every edge connects a vertex in U to one in W . A balanced graph is a bipartite graph without induced cycles of length 2 mod 4. A chordal bipartite graph is a bipartite graph without induced cycles of length more than 4. Obviously a chordal bipartite graph is balanced. 2.2

Tree-Width

Let G be a graph, T a tree, and let V = (Vt )t∈T be a family of vertex sets Vt ⊆ V (G) indexed by the vertices t of T . The pair (T, V) is called a treedecomposition of G if it satisfies the following three conditions:  - V (G) = t∈T Vt ; - if there is an edge uv ∈ E(G) then {u, v} ⊆ Vt for some t; and - for each v ∈ V (G), the graph T [{t : v ∈ Vt }] is connected. The width of (T, V) is the number max{|Vt | − 1 : t ∈ T }, and the tree-width tw(G) of G is the least width of any tree-decomposition of G. Tree-width can be characterized by the cops and robber game due to Seymour and Thomas [18]. The game is played on a graph G by k cops and one robber. Let S = [V (G)]≤k denote all of subsets of V (G) of cardinality ≤ k. A position of the game is a pair (X, y), where X ∈ S and y ∈ V (G) \ X. In the first move, the cops choose some vertices X1 ∈ S and afterwards the robber chooses a vertex y1 ∈ V (G) \ X1 . Then (X1 , y1 ) is the position after first move. If the robber cannot make a choice, then the game ends and the cops win. Suppose (Xi , yi ) is the position after i moves. In the (i + 1)th move, first the cops choose a set of vertices Xi+1 ∈ S such that Xi ⊆ Xi+1 or Xi+1 ⊆ Xi , and then the robber chooses a point yi+1 ∈ V (G) \ Xi+1 such that there is a path between yi+1 and yi in the graph G − (Xi ∩ Xi+1 ). Then (Xi+1 , yi+1 ) is the new position for the next move. If the robber cannot respond as required, the game ends and the cops win. The robber wins all infinite plays. Seymour and Thomas showed that the robber has a winning strategy in the k-cops and robber game on G if and only if tw(G) ≥ k.

100

2.3

X. Zhou

Counting Logics

IFP+C is the extension of first-order logic with inflationary fixed-points and a mechanism for counting. The logic C∞ω is the extension of first-order logic with infinitary conjunction and disjunction, and counting quantifiers ∃≥l for k consists ofthose formulas of C∞ω in which only every l ≥ 1. The fragment C∞ω ω k k distinct variables appear and C∞ω = k∈ω C∞ω . We refer to [6] for formal definitions of the above logics. One basic fact is that every IFP+C definable property is decidable in polynomial time. Another one is that every formula of ω . IFP+C is equivalent to a formula of C∞ω k Definability of C∞ω can be characterized by the k-pebble bijection game due to Hella [13]. The description of the game here is from [15]. The game is played on two graphs G and H using pebble x1 . . . , xk on G and y1 . . . , yk on H. xG i will denote the vertex of G which xi is placed on; similarly for yjH . The game has two players, the spoiler and the duplicator. If |G| = |H|, the spoiler wins immediately; otherwise, for each move, the spoiler chooses a pair of pebbles xi , yi , the duplicator chooses a bijection h : V (G) → V (H), and the spoiler chooses v ∈ V (G) and places xi on v and yi on h(v). If, after this move, the clause, H p(xG i ) = yi for all xi , yi which are currently on vertices of G and H respectively, does not define a partial isomorphism, the spoiler wins; the duplicator wins infinite plays. Hella has showed that the duplicator has a winning strategy in the k -equivalent, k-pebble bijection game on G and H if and only if G and H are C∞ω k C∞ω H. G≡ To show non-capturing results more conveniently, we recall one result of Otto [16]: Theorem 1 (Otto). If IFP+C captures PTIME on a class G of graphs that k is closed under disjoint union, then there is a k such that ≡C∞ω coincides with isomorphism on G.

3

CFI Construction

To separate IFP+C from PTIME, Cai et al. used graphs constructed through CFI construction [2]. In their proof, these graphs are treated as colored graphs, although the colors can be replaced by appropriate gadgets as Cai et al. mentioned. In [5], Dawar and Richerby made gadgets explicit in CFI construction for using properties of gadgets. In this section, we subdivide the graphs Dawar and Richerby constructed into balanced graphs and establish important properties of our new graphs. Some concepts and notations from [5] are adopted in this and the next sections.  Let G = (V, E) be a graph with δ(G) ≥ 2. Let m = v∈V d(v) and Dir(G) = {(v, w)|vw ∈ E}. Obviously m = |Dir(G)|. Let τ : Dir(G) → {1, . . . , m} be a bijection. For each v ∈ V , let br(v) be the set of new vertices, br(v) = {avw , bvw , cvw , dvw : w ∈ N (v)}∪{v Z : Z ⊆ N (v) and |Z| ≡ 0 (mod 2)}. For each edge vw ∈ E, let sub(vw) be the set of new vertices, sub(vw) = a b a b {xa{v,w} , xb{v,w} , y{v,w} , y{v,w} , z{v,w} , z{v,w} }. Let X∅ (G) be the graph which is  the union of the following independent paths between vertices in v∈V br(v):

CFI Construction and Balanced Graphs

101

- two paths of length 4 respectively with endpoints avw and cvw , bvw and cvw , and a path of length τ ((v, w)) with endpoints cvw and dvw , for each (v, w) ∈ Dir(G); - a path of length 4 with endpoints avw and v Z whenever w ∈ Z; - a path of length 4 with endpoints bvw and v Z whenever w ∈ Z; - two paths respectively with endpoints avw and awv , bvw and bwv for every edge vw ∈ E. These two paths are a a b b avw xa{v,w} y{v,w} z{v,w} awv and bvw xb{v,w} y{v,w} z{v,w} bwv , if τ ((v, w)) > τ ((w, v)), a a b b otherwise, avw z{v,w} y{v,w} xa{v,w} awv and bvw z{v,w} y{v,w} xb{v,w} bwv . For any (v, w) ∈ Dir(G), let outvw be the set of vertices on above paths which vw have endpoints avw , cvw , or bvw , cvw , or cvw , dvw ; let vO = outvw if τ ((w, v)) > vw a b a b a b τ ((v, w)), otherwise vO = outvw ∪ {x{v,w} , x{v,w} , y{v,w} , y{v,w} , z{v,w} , z{v,w} }. For any v ∈ V , let inn(v) be the set of vertices on above paths which have Z endpoints v Z , avw , or v Z , bvw for all v , avw , bvw ∈ br(v); let vI = inn(v) \ vw {avw , bvw |w ∈ N (v)}; let vˆ = vI ∪ w∈N (v) vO . The subgraph of X∅ (G) induced by vˆ for a vertex v of G with three neighbors w1 , w2 , w3 is illustrated in Fig. 1, where i = τ ((v, w1 )), j = τ ((v, w2 )), l = τ ((v, w3 )), and τ ((v, w1 )) > τ ((w1 , v)), τ ((v, w2 )) < τ ((w2 , v)), τ ((v, w3 )) < τ ((w3 , v)) , and the dashed lines indicate edges connecting this subgraph to the rest of X∅ (G). b a For any S ⊆ E, let XS (G) be X∅ with the edges z{v,w} bwv awv and z{v,w} b a deleted and the edges z{v,w} bwv and z{v,w} awv added if τ ((v, w)) > τ ((w, v)), or dvw1 a {v , w1 }

z

z{bv, w1 }

i

y{av, w1 }

y{bv , w1 }

cvw1

x{av, w1 }

x{bv , w1 } bvw1

avw1 v‡

v{2,3}

v{1,3}

v{1,2}

avw3

bvw2

avw2

bvw3

cvw2 j

cvw3 l

dvw2

d vw3

Fig. 1. The graph on the vertices vˆ in X∅ (G)

102

X. Zhou

a b b a the edges avw z{v,w} and bvw z{v,w} deleted and edges avw z{v,w} and bwv z{v,w} added if τ ((w, v)) > τ ((v, w)), for every edge vw ∈ S. We say that the edges in S have been twisted. The following fact can be easily verified:

Lemma 1. Let G be any graph with δ(G) ≥ 2. Let S ⊆ E(G). XS (G) are balanced. Proof. From the definition, we know that all of cycles in XS (G) are of length 4m, m ≥ 4. Thus XS (G) is bipartite and without induced cycles of length 4n+ 2.  So XS (G) is balanced. vw Obviously all the graphs XS (G) have the same  set of vertices. Thus vO , vI , vˆ are well defined for all these graphs. Let W = v∈V vˆ. Bijections from W to W which preserve vˆ for each v ∈ V will play important roles in our proof. For some of such bijections which are regarded as isomorphism from XS (G) and XT (G), S, T ⊆ E, we have the following observation:

Lemma 2. Let G be any graph with δ(G) ≥ 2. Let S, T ⊆ E(G). Let ϕ be an isomorphism from XS (G) to XT (G). Then (i) For any v ∈ V (G), ϕ(ˆ v ) = vˆ, ϕ({v Z : v Z ∈ br(v)}) = {v Z : v Z ∈ br(v)}, and ϕ({avw , bvw }) = {avw , bvw }, ϕ(cvw ) = cvw , ϕ(dvw ) = dvw for any w ∈ NG (v). (ii)For any v ∈ V (G), the restriction of ϕ on vˆ, ϕ ↾ vˆ, is determined by interchanging avw and bvw for each w in some subset Y of NG (v) of even cardinality. Proof. (i) In XS (G) and XT (G), the vertices with degree 1 are exactly in {dvw : (v, w) ∈ Dir(G)}. For any pair cvw , dvw , the length of the path between them is unique. Thus ϕ(dvw ) = dvw , ϕ(cvw ) = cvw for any (v, w) ∈ Dir(G), since ϕ is an isomorphism. Then it is trivial to check the other equations. (ii) Let η = ϕ ↾ vˆ : vˆ → vˆ. The essence of action of η on vˆ is: ϕ(avw ) = bvw , ϕ(bvw ) = avw for w ∈ Y , and ϕ(avw ) = avw , ϕ(bvw ) = bvw for w ∈ Y , and ϕ(v Z ) = v Z△Y for v Z ∈ br(v), where Z △ Y is the symmetric difference of Z and Y . Since each Z has even cardinality, only Y ⊆ NG (v) of even cardinality can work well.  For each v ∈ V , Y ⊆ N (v) of even cardinality, there is a bijection ηv,Y : W → W such that ηv,Y (x) = x for x ∈ W − vˆ and ηv,Y ↾ vˆ is determined by Y as the case in lemma 2(ii). The following two lemmas are crucial for the definition of  X(G) and X(G). Lemma 3. Let G be any graph with δ(G) ≥ 2. Let e be any edge of G. X∅ (G) and X{e} (G) are not isomorphic. Proof. By contradiction. Assume ϕ is an isomorphism from X∅ (G) to X{e} (G). Consider the action of ϕ on any pair {avw , bvw }, for each (v, w) ∈ Dir(G). According to Lemma 2(i), ϕ({avw , bvw }) = {avw , bvw }. Define ⊕ϕ to be the sum mod 2 over all such pairs in X∅ (G) of the number of times ϕ maps an a to a b. We use two ways to calculate ⊕ϕ. One is to consider the two pairs corresponding to every edge e1 ∈ E(G). If e1 = e, then the number of the switches is either

CFI Construction and Balanced Graphs

103

zero or two, else the number is one. Hence ⊕ϕ is one mod 2. The other way is in terms of each vˆ in X∅ (G). According to Lemma 2(ii), for any v ∈ V (G), the number of switches in vˆ is even. Thus ⊕ϕ is zero mod 2. The contradiction proves the lemma.  Lemma 4. Let G be any connected graph with δ(G) ≥ 2. Let e1 , e2 be any two edges of G. X{e1 } (G) ≃ X{e2 } (G) Proof. If e1 = e2 , obviously the lemma holds. We consider the case e1 = e2 . Let e1 be the edge uv and e2 be the edge xy. If v = x, then the required isomorphism is ηv,{u,y} . Otherwise, if the four vertices are distinct, then there is a path from e1 to e2 , because G is connected. Without loss of generality, we can assume the path is v1 . . . vm such that v1 = v, vm = x and neither u nor y occurs on the path. The required isomorphism from X{e1 } (G) to X{e2 } (G) is ϕ = ηv1 ,{u,v2 } ◦ ηv2 ,{v1 ,v3 } ◦ · · · ◦ ηvm−1 ,{vm−2 ,vm } ◦ ηvm ,{vm−1 ,y} .   for X{e} (G) for any Now we can write X(G) for the graph X∅ (G) and X(G) e ∈ E and call these, respectively, the untwisted and twisted CFI graphs of G. Moreover, we can see that we have constructed only two graphs modulo isomorphism. Proposition 1. Let G be any connected graph with δ(G) ≥ 2. Let S ⊆ E(G).  if and only if XS (G) ≃ X(G) if and only if |S| ≡ 0(mod 2). XS (G) ≃ X(G) |S| ≡ 1(mod 2). Proof. According to lemma 3 and 4, it suffices to show that for any S ⊆ E(G), |S| ≥ 2, there is a T ⊆ S satisfying |S| = |T | + 2 and XS (G) ≃ XT (G). Since G is connected, there must be a path in G which connect two distinct edges e1 and e2 in S and does not pass through any endpoints of other edges of S. Let T = S \ {e1 , e2 }. Using the analysis similar with one in the proof of lemma 4, we can get an isomorphism ϕ : XS (G) → XT (G). Thus T is the required subset of S. 

4

Main Results

 The CFI graphs, X(G) and X(G), of G have been constructed in the last section. k C∞ω  X(G), we adopt the same conditions of Dawar and To guarantee X(G) ≡ Richerby [5]. To establish that the conditions suffice for their CFI graphs, Dawar and Richerby constructed a winning strategy for the duplicator in the bijection game with the cops and robber game. But there are some flaws [4] in their construction. We propose a refined construction of the winning strategy by use of the cops and robber game. Although the refined construction is for our variant of CFI graphs, it can be easily transformed for the case of Dawar and Richerby, which is fully discussed in [20]. Theorem 2. Let G be any connected graph with δ(G) ≥ 2 and tw(G) ≥ k. k  X(G) ≡C∞ω X(G).

104

X. Zhou

 Proof. The k-pebble bijection game is played on X(G) and X(G). To exhibit a winning strategy for the duplicator, we need some special bijections from X(G)  to X(G). For (v, w) ∈ Dir(G), there is a bijection σvw : W → W such that σvw (x) = x vw vw vw vw  for x ∈ W \ vO and σvw ↾ vO is an automorphism on X(G)[vO ] or X(G)[v O ] satisfying σvw (avw ) = bvw , σvw (bvw ) = avw , σvw (cvw ) = cvw , and σvw (dvw ) =  is good dvw . For a vertex u of G, we say that a bijection f : X(G) → X(G) except at u if it satisfies the following conditions: - for every vertex v of G, h(ˆ v ) = vˆ; - h(cvw ) = cvw , h(dvw ) = dvw , h({avw , bvw }) = {avw , bvw } for every (v, w) ∈ Dir(G);  − uI ; and - h is an isomorphism between the graphs X(G) − uI and X(G) - {w|w ∈ NG (u), f (auw ) = buw } has odd cardinality.  For concreteness, say X(G) is the graph X{u1 u2 } (G). Then σu1 u2 is good except at u1 , similarly, σu2 u1 is good except at u2 . We claim that, if f is a bijection that is good except at u and there is a path P from u to u′ , then there is a bijection f ′ that is good at except at u′ such that for all vertices w not in P and all x ∈ w, ˆ f ′ (x) = h(x). To prove the claim, let the path P be v1 . . . vm with v1 = u and vm = u′ . Let Y = {w|w ∈ NG (u), f (auw ) = buw }. Since f is good except at u, then Y has odd cardinality. Thus we have a bijection θ such that θ(x) = ηu,Y △{v2 } (x) for every x ∈ u ˆ and θ(y) = y for every y ∈ W \ uˆ. Then f ′ = θ ◦ ηv2 ,{u,v3 } ◦ · · · ηvm−1 ,{vm−2 ,u′ } ◦ σu′ vm−1 satisfies the claim. Since G is connected and tw(G) ≥ k, the robber can win the k-cops and robber game on G with the initial position (∅, w) for any w ∈ V (G). The winning strategy for the duplicator is described as follows: Initially, the duplicator has a bijection that is good except at u1 for one of  and none of the pebbles in the the endpoints u1 of the twisted edge in X(G),  bijection game is placed on any vertex in X(G) or X(G), and the position of the cops and robber game on G is (∅, u1 ). Assume that after t-th move of the k-pebble bijection game, the duplicator has a bijection f that is good except at v, It = {i : xi , yi are placed on some X(G)

 X(G)

X(G)

 X(G)

∈ u ˆ, i ∈ It }, , yi for i ∈ It , Zt = {u|xi ) = yi elements}, f (xi v ∈ Zt , and the position of cops and robber game on G is (Zt , v). In the (t + 1)th move, the spoiler chooses a pair of pebbles xj , yj . There are two cases: – j ∈ It . For every w ∈ V (G), the duplicator uses a copy of the cops and robber game on G with the position (Zt , v). Suppose the cops choose Zt ∪{w} for the next move, then the robber answers with a vertex w′ and a path Pw in G from v to w′ which does not pass any vertex in Zt . Accordingto our claim, there is a  ˆ. ˆ = f ↾ u∈Zt u bijection fw′ that is good except at w′ such that fw′ ↾ u∈Zt u So in the  bijection game, the duplicator can answer the spoiler with a bijection h = w∈V (G) (fw′ ↾ w). ˆ The spoiler chooses x ∈ X(G) and places xj on x and yj on y = h(x).

CFI Construction and Balanced Graphs

105

Assume that x ∈ w ˆ0 for some vertex w0 of G. Then y = h(x) = fw′ 0 (x), X(G)

 X(G)

X(G)

X(G)

 X(G)

) = yi ) = f (xi . Further, fw′ 0 (xi ) = yj which means fw′ 0 (xj ′ for i ∈ It . Let w0 be the vertex answered by the robber when the cops choose Zt ∪ {w0 }, Since w0′ = w0 and fw′ 0 is good except at w0′ , then the clause, X(G)

 X(G)

X(G)

) for i ∈ It ∪{j} defines a partial isomorphism = fw′ 0 (xi ) = yi p(xi as required. The duplicator then use fw′ 0 , It+1 = It ∪ {j}, Zt+1 = Zt ∪ {w0 } and the cops and robber game on G with the position (Zt+1 , w0′ ) at the beginning of the next move of the bijection game. – j ∈ It .  X(G) X(G) ∈u ˆ. , yj Let u be the vertex of G such that xj X(G)

 X(G)

∈u ˆ, then let f ♮ = f , , yi • If there is i ∈ It satisfying i = j and xi ♮ ♮ It = It − {j}, Zt = Zt , and v ♮ = v. • Otherwise, let It♮ = It − {j}, Zt♮ = Zt − {u}. Suppose the cops choose Zt♮ in the cops and robber game on G with the position (Zt , v), then the robber answers with a new vertex v ♮ and a path P in G from v to v ♮ which does not pass any vertex in Zt♮ . According to our claim, there is a X(G)

 X(G)

for ) = yi bijection f ♮ that is good except at v ♮ such that f ♮ (xi i ∈ It♮ . Then the duplicator can play like the case j ∈ It using h♮ , It♮ , Zt♮ and w♮ . Finally we come to the non-capturing result: Theorem 3. IFP+C does not capture PTIME on the class of balanced graphs. Proof. For any n ≥ 2 , we have a graph Gn = K n+1 . δ(Gn ) ≥ 2 and tw(Gn ) ≥ n.  n ) are balanced. By Proposition 1 , X(Gn ) and By Lemma 1 , X(Gn ) and X(G n n  n ) are not isomorphic. By Theorem 2 , X(Gn ) ≡C∞ω  n ). Thus ≡C∞ω X(G X(G does not coincide with isomorphism on balanced graphs. According to Theorem 1, IFP+C does not capture PTIME on balanced graphs.  The class of balanced graph is GI-complete because the class of chordal bipartite graphs is GI-complete [19]. Immerman and Lander have proved that for each fixed k there are polynomial time algorithm deciding whether two given graphs k [14]. According to Theorem 1, it may be expected that are equivalent in C∞ω IFP+C does not capture PTIME on any GI-complete graph class closed under disjoint union. Our result conforms with this expectation.

5

Conclusion

We have shown that IFP+C fails to capture PTIME on balanced graphs. There are some remaining questions. One question is that whether we can go further to show that IFP+C does not capture PTIME on chordal bipartite graphs. The similar question can be asked for the class of chordal graphs, which is also

106

X. Zhou

 GI-complete. The lengths of induced cycles in X(G) and X(G) suggest that CFIconstruction does not work for these two graph classes. Thus we need to develop other tools. In addition, there are interesting subclasses of chordal graphs or chordal bipartite graphs, which are not GI-complete, like interval graphs etc. On these graph classes, the questions whether IFP+C captures PTIME are also worth investigating.

Acknowledgement We would like to thank Zhilin Wu for full discussions on the details of the proofs in this article. We also would like to thank Hongtao Huang for drawing Figure 1.

References 1. Brandst¨ adt, A., Le, V.B., Sprinrad, J.P.: Graph Classes: A Survey. SIAM, Philadelphia (1999) 2. Cai, J.-Y., F¨ urer, M., Immerman, N.: An optimal lower bound on the number of variables for graph identification. Combinatorica 12(4), 389–410 (1992) 3. Chandra, A., Harel, D.: Structure and complexity of relational queries. Journal of Computer and System Sciences 25, 99–128 (1982) 4. Dawar, A.: Personal Communication 5. Dawar, A., Richerby, D.: The Power of Counting Logics on Restricted Classes of Finite Structures. In Proc. 16th EACSL Annual Conference on Computer Science Logic. In: Duparc, J., Henzinger, T.A. (eds.) CSL 2007. LNCS, vol. 4646, pp. 84–98. Springer, Heidelberg (2007) 6. Ebbinghaus, H.D., Flum, J.: Finite Model Theory, 2nd edn. Springer, Heidelberg (1999) 7. Grohe, M., Mari˜ no, J.: Definability and descriptive complexity on databases of bounded tree-width. In: Beeri, C., Bruneman, P. (eds.) ICDT 1999. LNCS, vol. 1540, pp. 70–82. Springer, Heidelberg (1998) 8. Golumbic, M.C.: Algorithmic Graph Theory and Perfect Graphs, 2nd edn. Elsevier, Amsterdam (2004) 9. Grohe, M.: Fixed-point logics on planar graphs. In: Proc. 13th IEEE Annual Symposium on Logic in Computer Science, pp. 6–15. IEEE Computer Society Press, Los Alamitos (1998) 10. Grohe, M.: Isomorphism testing for embeddable graphs through definability. In: Proc. 32nd ACM Symposium on Theory of Computing, pp. 63–72. ACM Press, New York (2000) 11. Grohe, M.: Definable Tree Decompositions. In: Proc. 22nd IEEE Annual Symposium on Logic in Computer Science, pp. 406–417. IEEE Computer Society, Los Alamitos (2008) 12. Gurevich, Y.: Logic and the challenge of computer science. In: B¨ orger, E. (ed.) Current trends in theoretical computer science, pp. 1–57. Computer Science Press (1988) 13. Hella, L.: Logical hierarchy in PTIME. Information and Computations 129(1), 1–19 (1996)

CFI Construction and Balanced Graphs

107

14. Immerman, N., Lander, E.S.: Describing graphs: A first-order approach to graph canonization. In: Selman, A. (ed.) Complexity Theory Retrospective, pp. 59–81. Springer, Heidelberg (1990) 15. Immerman, N.: Descriptive Complexity. Springer, Heidelberg (1999) 16. Otto, M.: Bounded Variable Logics and Counting – A Study in Finite Models. Lecture Notes in Logic, vol. 9. Springer, Heidelberg (1997) 17. Ram´ırez Alfons´ın, J.L., Reed, B.A. (eds.): Perfect Graphs. John Wiley & Sons, Chichester (2001) 18. Seymour, P.D., Thomas, R.: Graph searching and a min-max theorem for treewidth. Journal of Combinatorial Theory Series B 58, 22–33 (1993) 19. Uehara, R., Toda, S., Nagoya, T.: Graph isomorphism completeness for chordal bipartite graphs and strongly chordal graphs. Discrete Applied Mathematics 145, 479–482 (2005) 20. Zhou, X., Wu, Z.: A Note on Using the Cops and Robber Game in the Bijection Game (Submitted)

Minimizing the Weighted Directed Hausdorff Distance between Colored Point Sets under Translations and Rigid Motions⋆ Christian Knauer, Klaus Kriegel, and Fabian Stehn Institut f¨ ur Informatik, Freie Universit¨ at Berlin {knauer,kriegel,stehn}@inf.fu-berlin.de

Abstract. Matching geometric objects with respect to their Hausdorff distance is a well investigated problem in Computational Geometry with various application areas. The variant investigated in this paper is motivated by the problem of determining a matching (in this context also called registration) for neurosurgical operations. The task is, given a sequence P of weighted point sets (anatomic landmarks measured from a patient), a second sequence Q of corresponding point sets (defined in a 3D model of the patient) and a transformation class T , compute the transformations t ∈ T that minimize the weighted directed Hausdorff distance of t(P) to Q. The weighted Hausdorff distance, as introduced in this paper, takes the weights of the point sets into account. For this application, a weight reflects the precision with which a landmark can be measured. We present an exact solution for translations in the plane, a simple 2-approximation as well as a FPTAS for translations in arbitrary dimension and a constant factor approximation for rigid motions in the plane or in R3 .

1

Introduction

The task of computing a matching of two geometric objects is a well investigated research topic in Computational Geometry. A central aspect in pattern recognition and matching applications is the measure which is used to compare two objects. A measure defines which features of the objects are relevant for deciding about their similarity. An established measure to compare two geometric objects A and B is the (directed) Hausdorff distance h(A, B), defined as h(A, B) := max min a − b, a∈A b∈B

where  ·  denotes the Euclidean norm. We present an extension of the directed Hausdorff distance which is motivated by a registration application for neurosurgical operations. The task is to compute a transformation that matches a patient in an operation theatre to a 3D model ⋆

Supported by the German Research Foundation (DFG), grant KN 591/2-2.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 108–119, 2009. c Springer-Verlag Berlin Heidelberg 2009 

Minimizing the Weighted Directed Hausdorff Distance

a)

109

b)

Fig. 1. Examples of anatomic landmarks a) three landmarks that have an anatomic counterpart on the patient (e.g. nasal bone) b) additionally arbitrary surface points

of that patient, which is generated from CT/MRT scans. The translation, in this context also called registration, is used to visualize the surgical instruments within the 3D model at the appropriate relative position and orientation. The methods that are commonly used to compute registrations differ in the nature of the geometric features that represent the two coordinate systems that have to be aligned. In the application considered here, a matching is computed based on point sets consisting of so-called anatomic landmarks. Anatomic landmarks are spots in the relevant anatomic area that are easy to locate in the model and on the patient, like the nasal bone (LM2 in Figure 1a) or the outer corners of the eyes (LM1 and LM3 in Figure 1a). Landmarks are defined in the model by the surgeon during the operation planning phase. The corresponding feature set are measurements of these landmarks, gained by touching the appropriate spots of the patient with a traceable device. These measurements take place in the first phase of the operation. In contrast to other registration methods for neurosurgical applications, the objective function considered here allows to take the different precisions into account with that geometric features can be measured. The precision of measuring a landmarks depends on its spatial position and on the positioning of the patient in the operation theatre (the positioning of a patient again depends on the location of the tumor that has to be operated on). The weighted directed Hausdorff distance that we are about to introduce is defined for sequences of weighted point sets. The coordinates of a point in these sets are the defined or measured positions of a landmark. Landmarks that can be measured with the same precision are collected in the same set. The weight of a point is proportional to the precision with that the landmark can be measured and is based on an empirical study about the precision of measuring landmarks, which will be published in a medical journal.

110

C. Knauer, K. Kriegel, and F. Stehn

Computing matchings to align geometric objects is a well studied area in Computational Geometry, see Alt and Gubias [1] for an exhaustive survey of this research area. A significant body of research concentrates on computing registrations for the specific application of navigated surgery. These methods can be categorized into exact solutions, heuristics or absolute-/relative approximation algorithms. A point-to-point registration method that is currently used in several navigation systems is based on so-called fiducials. Fiducials are artificial landmarks that are attached to the patient before the patient is scanned (CT-/MRT scan) and that remain attached until registration time, at the beginning of an operation. A method for computing registrations based on fiducials by minimizing the root-mean squared distance is described in [2]. Drawbacks of this method are the limited time between the imagine method and the operation, additional effort for the medical staff for attaching and maintaining the fiducials, additional stress for the patient, and lost or shifted landmarks due to transpiration. A well studied heuristic for computing matchings of geometric objects is the iterative closest point method (ICP)[3] where a registration is computed in an iterative fashion minimizing the least-square distance of the considered features. The drawback of this method and other heuristics is that it can not guarantee to provide either optimal solutions or solutions that hold guarantee bounds. Dimitrov et at. [4,5] presented relative and absolute point-to-surface registration approximations with respect to the directed Hausdorff distance. In that papers however, the different precisions of the features are not taken into account. 1.1

Problem Definition

Given two sequences of finite point sets P = (P1 , . . . , Pk ) and Q = (Q1 , . . . , Qk ) with Pi , Qi ⊂ Rd and a sequence of weights w = (w1 , . . . , wk ) with wi ∈ R+ k and w1 ≥ w2 ≥ · · · ≥ wk . For ni := |Pi | and mi := |Qi | let n = i=1 ni and k m = i=1 mi . For the purpose of illustration one can think of P and Q being colored in k different colors, where all points in Pi and Qi are colored with the ith color. Definition 1. The weighted directed Hausdorff distance h(P, Q, w) for P, Q and w is defined as: h(P, Q, w) = max wi h(Pi , Qi ). 1≤i≤k

For points in the plane, h(P, Q, w) can be computed in O ((n + m) log m) time using Voronoi diagrams to compute the directed Hausdorff distance for every color; for higher dimensions it trivially can be computed in O (mn) time. Problem 1. In this paper we discuss the problem of matching two sequences of weighted point sets under the weighted directed Hausdorff distance. Formally, given P, Q and w defined as before and a transformation class T , find the transformations t ∈ T that minimize the function f (t) = h(t(P), Q, w),

(1)

Minimizing the Weighted Directed Hausdorff Distance

111

where t(P) := ({t(p) | p ∈ Pi })1≤i≤k . For the remainder of this paper, let µopt denote the minimum of f . 1.2

Generalization of the Problem

In the following sections we present approximations and exact solutions for Problem 1 for various transformation classes and dimensions. A reasonable generalization of the problem is to maintain the partitioning of the points into k sets but assigning a weight to each point individually. The originally stated problem then becomes a special variant of this formulation. The generalized problem can be solved using the same techniques and with the same runtime as for solving Problem 1. We decided to present the solutions for Problem 1 as it simplifies the notation and meeds the specification of the motivating application. In section two we present a 2-approximation for colored point sets in arbitrary dimension under translations and extend it to a FPTAS in section three. In section four a constant-factor approximation for rigid motions is presented. An exact algorithm optimizing the Hausdorff distance under translations for points in the plane is presented in section five.

2

A 2-Approximation for Translations in Rd

Theorem 1. A 2-approximation for translations of colored points can be computed in O (m1 (m + n) log m) time in R2 and in O (m1 mn) time for point sets in higher dimensions. Proof. Choose a point p ∈ P1 and let T be the set of all translation vectors that move p upon a point of Q1 : T := {q − p | q ∈ Q1 }. Then, the translations t2app of T that realize the smallest Hausdorff distance are 2-approximations of µopt : f (t2app ) = min h(t(P), Q, w) ≤ 2µopt . t∈T

To show this, assume P to be in optimal position and let nn (p, Qi ) ⊆ Qi be the set of nearest neighbors of p ∈ Pi in Qi and let ni (p) be one representative of this set. In optimal position, all weighted distances are bounded by µopt : ∀ 1 ≤ i ≤ k ∀ p′ ∈ Pi wi p′ − ni (p′ ) ≤ µopt . Consider the translation tq ∈ T that moves the chosen point p upon one of its nearest neighbors q ∈ nn (p, Q1 ). By applying tq to P, all points in any Pi are moved away from their optimal position by p − q, see Figure 2. The new

112

C. Knauer, K. Kriegel, and F. Stehn

tq (˜ p) p˜ ≤ µopt

l q

q = tq (p)

∈ P1 ∈ Q1

p nn (˜ p, Qh )

nn (˜ p, Qh )

a)

∈ Ph

∈ Qh ∈T

b)

Fig. 2. Illustration of an aligned point configuration

weighted distance l of any p˜ ∈ Pi to one of its closest neighbors after applying tq is at most: l = wi h(tq (˜ p), Qi ) ≤ wi (˜ p − ni (˜ p) + p − n1 (p)) ≤ µopt + wi p − n1 (p) ≤ µopt + w1 p − n1 (p) ≤ 2µopt .

For a fixed p ∈ P1 all translations that move p upon a point q ∈ Q1 have to be tested, which yields the stated runtime. ⊓ ⊔ The key argument that guarantees an approximation factor of 2 is that w1 is at least as large as any other weight. Choosing a p′ ∈ Pi for any color i and testing all translation vectors that move p′ onto a point q ′ ∈ Qi yields in a 1 + w1/wi -approximation that can be computed in O (mi (m + n) log m) respectively in O (mi m n) time. Together with the the pigeonhole principle, this implies  that 2 there is a 1 + (w1/wk )-approximation that can be computed in O m /k n time for general d and in O (m/k (m + n) log m) time in the plane.

3

A FPTAS for Translations in Rd

Theorem 2. For every ǫ > 0 a (1 + ǫ)-approximation for translations  √ d can be 2 2 d/ǫ 1 m1 m n computed in O ( /ǫ m1 (m + n) log m) time in R and in O time for higher dimensions. Proof. Let µ2app = f (t2app ) where t2app is a solution of the 2-approximation as described in Section 2. For the given ǫ, choose any p ∈ P1 and for every q ∈ Q1 build a regular squared grid Gǫq centered in q with side length µ2app /w1 √ where each cell has a side length of (ǫ µ2app )/( d w1 ), see Figure 3. Let T be the set of all translations, that move a p ∈ P1 onto a grid point of a grid Gǫq for any q ∈ Q1 . Then, the translations tapp of T that realize the smallest weighted Hausdorff distance satisfy f (tapp ) = min h(t(P), Q, w) ≤ (1 + ǫ)µopt . t∈T

Minimizing the Weighted Directed Hausdorff Distance

113

√  μ2app/ d w1

μ2app/w1

l √  μ2app/ d w1 μ2app/w1

q

Fig. 3. Illustration of Gǫq

Assume P to be in optimal position and let q = n1 (p) be one of the nearest neighbors of the chosen p ∈ P1 . By construction, the point p lies within the boundaries of the grid Gǫq . Due the choice of the cell length, the furthest distance √ l of p to one of its closest grid points is at √ most l ≤ (ǫ µ2app )/(2 dw1 ) and as µopt ≥ µ2app /2 we have that l ≤ (ǫ µopt )/( dw1 ). As all wi for 1 < i ≤ k are at most as large as w1 , the weighted distance of all other points increases by at √ d most ǫ · µopt when translated along the distance l. There are d/ǫ grid points ⊓ ⊔ for each Gǫq that need to be tested, which implies the stated runtime. Using the same arguments as for the 2-approximation, its easy to show that a √ d 2 d c/ǫ (1 + ǫ) approximation can be computed in O m n/k time for points   2 sets in dimension d ≥ 3 or in O (c/ǫ) m/k(m + n) log m time in R2 with c = w1/wk .

4

A Constant Factor Approximation for Rigid Motions in the Plane

The constant factor approximation described in Section 2 for a planar setting can easily be extended to cover rigid motions, i.e., translations plus rotations. √ Theorem 3. A 2(1 + 2)-approximation for rigid motions can be computed in O (m1 mi (m + n) log m) time for point sets in the plane.  Proof. Choose any p ∈ P1 . Let P := 1≤i≤k Pi and let ω : P → R be the function that maps a point x ∈ P to its weight ω(x) = wi for x ∈ Pi . Let p′ be a point that maximizes the weighted distance to p: p′ ∈ arg max ω(x)x − p, x∈P

without loss of generality let ω(p′ ) = wi . This choice of p′ ensures that the change of the Hausdorff distance of any point p˜ ∈ P when rotated around p is bounded by the change of the weighted Hausdorff distance of p′ .

114

C. Knauer, K. Kriegel, and F. Stehn q

tq

q = t(p)

q = tq (p)

p tq,q′ q′

q′ p

q′ tq (p′ )



a)

l tq (p′ )



t(p )

b)

c)

Fig. 4. a) The translational part tq , b) the rotational part tq,q′ , c) the aligned configuration

tq (p′ )

p



q

≤ 2µopt /wi q′

p



√ l ≤ 2 2µopt /wi

q



t(p )

t(p′ ) q′



p′

p tq (p′ )

tq (˜ p) t(˜ p) a)

b)

Fig. 5. a) Example of a constant factor approximation, b) Illustration of an aligned √ configuration that could realize an approximation factor of 2(1 + 2)µopt

For any q ∈ Q1 and any q ′ ∈ Qi let t be defined as t := tq,q′ ◦ tq , where tq is the translation that moves p upon q and tq,q′ is the rotation around q by the smallest absolute angle such that q, q ′ and tq,q′ ◦ tq (p′ ) are aligned, see Figure 4. Let T be the set of all transformations that align p ∈ P1 and p′ ∈ Pi with some q ∈ Q1 and q ′ ∈ Qi in the described manner. The transformations trapp of T that realize the smallest Hausdorff distance satisfy the stated approximation factor: √ √ f (trapp ) = min h(t(P), Q, w) ≤ 2 µopt + 2 2 µopt = 2(1 + 2)µopt . t∈T

The fist summand is due to the influence of translational component tq as dis√ cussed in the proof of Theorem 1. The second term, 2 2 µopt , reflects the furthest weighted distance that a point p˜ can possibly cover while moving from position p) to t(˜ p), see Figure 5. tq (˜ ′ Scenarios where q q ′ and q tq (p′ ) are orthogonal and additionally √ q−tq (p ) = µopt (see Figure 5 b) almost reach the upper bound of 2(1 + 2)µopt . ⊓ ⊔

Minimizing the Weighted Directed Hausdorff Distance

4.1

115

Extending the Result to R3

In R3 one additional degree of freedom has to be fixed. Based on the registration in the previous section, this freedom is a rotation around the axis p p′ . The algorithm can be adjusted by choosing p and p′ as before and by choosing a point p′′ ∈ Pj such that   p′′ ∈ arg max ω(x) dist x, p p′ , x∈P

  where dist a, b c is the distance of the point a to its orthogonal projection onto the line through b and c. For any q ′′ ∈ Qj consider additionally the rotation tq,q′ ,q′′ around the axis q q ′ such that tq,q′ ,q′′ ◦ tq,q′ ◦ tq (p′′ ), q, q ′ and q ′′′ are√ coplanar. It is easy to see, that the additional rotation results in a (6 + 2 2)-approximation (≈ 11.657) of the optimum and the runtime increases to O (m1 mi mj mn).

5

An Exact Algorithm for Computing a Registration in the Plane under Translations

The minima of the objective function f (t) (Equation 1) under translations in the plane can be computed similar to the approach from Huttenlocher et. al. [6] by partitioning the translation space into cells such that for all translations of one cell the weighted Hausdorff distance is realized by the same point pair. As we consider translation throughout this section, we write a translation of a point p by a translation vector t as p + t instead of t(p). Recall, that the objective function f is given as: f (t) = max wi h(t(Pi ), Qi ) 1≤i≤k

= max wi max min (p + t) − q 1≤i≤k

p∈Pi q∈Qi

= max wi max min (q − p) − t) 1≤i≤k

p∈Pi q∈Qi

Computing the distance of the point p + t to q is equivalent to computing the distance of the translation vector t to the point q − p. By introducing the sets Si (p) := {q − p | q ∈ Qi } we can reformulate f (t) as f (t) = max wi max min c − t. 1≤i≤k

p∈Pi c∈Si (p)

To compute the minima of f , we compute the decomposition of the translation space into (potentially empty) cells C(p, q) ⊆ R2 with p ∈ Pi and q ∈ Qi , such that C(p, q) := {t | f (t) = wi (p + t) − q}.

116

C. Knauer, K. Kriegel, and F. Stehn

Theorem 4. The decomposition of the translation space into cells C(p, q) and with t that minimize f (t) can be computed in  it the transformations  O m2 n2 α(m2 n2 ) log mn time, where α(·) is the inverse Ackermann function. Proof. To characterize C(p, q) with p ∈ Pi and q ∈ Qi we fist observe, that f (t) = wi (p + t) − q implies t ∈ Vor (q − p, Si (p)), where Vor (a, A) is the Voronoi cell of the side a ∈ A in the Voronoi diagram of the set A. Otherwise, another point q ′ of color i would be closer to p than q, implying that f (t) would not by realized by p and q. There are two possible reasons why for a translation t ∈ Vor (q − p, Si (p)) the value of f (t) might not be realized by p and q. This is either because another point p′ ∈ Pi of the same color has a larger distance to its nearest neighbor for this translation, or because the weighted distance of a closest point pair of another color j = i exceeds wi (p + t) − q, that is, f (t) = wi (p + t) − q implies ∀1≤j≤k ∀p′ ∈Pj min wj (p′ + t) − q ′  ≤ wi (p + t) − q. ′ q ∈Qj

We define B(p, q) as the blocked area for the pair p and q, i.e., all translations t ∈ Vor (q − p, Si (p)) for which the value of f (t) is not realized by p and q due to either of the mentioned reasons. The characterization of the shape of B(p, q) for a point pair of the ith color follows directly from the previous observation and is given as  B(p, q) := Vor (q − p, Si (˜ p) ∪ Si (p)) ∪ p∈P ˜ i \{p}





1≤j≤k p∈P ˆ j i=j

MWVor (q − p, Si (p), Sj (ˆ p), wi , wj ) ,

where MWVor (a, A, B, w, w′ ) is the Voronoi cell of a point a ∈ A in the multiplicatively weighted Voronoi diagram of the set A ∪ B where all points in A have weight w and all points in B have weight w′ . Note, that the Voronoi cells that are united in the characterization of B(p, q) correspond to the portions of the translation space for which wi (p + t) − q is not the maximal distance shortest pair. A cell C(p, q) of a point pair of the ith color is then fully characterized by C(p, q) = Vor (q − p, Si (p)) \ B(p, q). For a non empty cell that has an empty blocking area the value of f (t) is minimal at the site that defined the cell and increases linear to the distance to this site. Therefore, the minimal value of f (t) is either realized at a site or at the boundary of a blocking area. This means that the minima of f (t) can be computed while computing the decomposition of the translation space into cells. Let bp,q denote the number of edges contributing to the boundary of B(p, q).

Minimizing the Weighted Directed Hausdorff Distance

117

  Lemma 1. The combinatorial complexity of B(p, q) is O bp,q 2α(bp,q ) . Proof. By introducing polar coordinates (r, θ) with q − p as the origin, the boundary of B(p, q) can be seen as the upper envelope of the partially-defined, continuous, univariate functions given as the edges of the Voronoi diagrams parametrized by θ. Two Voronoi edges can intersect in at most two points. Applying the theory of Davenport-Schinzel sequences [7], this results in a com plexity of O bp,q 2α(bp,q ) . ⊓ ⊔    Let b = 1≤i≤k p∈Pi q∈Qi bp,q be the total number of edges that contribute to the boundary of any blocking region.   Lemma 2. b = O m2 n2 Proof. First, fix a color i and a point p ∈ Pi . The edges e that contribute to the boundaries of any blocking area of a facet of Vor (Si (p)) result from the edges of the Voronoi diagrams e∈



p∈P ˜ i \p

Vor (Si (p) ∪ Si (˜ p)) ∪





MWVor (Si (p), Sj (ˆ p), wi , wj ) .

1≤j≤k p∈P ˆ j i=j

Let bip be the number of edges contributing to the boundaries of the blocking areas for the facets of Vor (Si (p)). The combinatorial complexity of a standard Voronoi diagram of n sites is O (n), the complexity of an multiplicatively weighted Voronoi diagram for the same number of sites however is Θ(n2 ) as shown by Aurenhammer et al. [8], even if just two different weights are involved. This is the main reason, why the runtime for colored points increases compared to the monochromatic variant discussed by Huttenlocher et al. [6]. This leads to a combinatorial complexity for bip of ⎛

⎜ bip = O ⎜ (mi + mi ) + ⎝ p∈P ˜ i \{p}



⎜ = O⎜ ⎝ n i mi + ⎛

= O⎝

1≤j≤k i=j



1≤j≤k



1≤j≤k p∈P ˆ j i=j



⎟ nj (mi + mj )2 ⎟ ⎠ ⎞

nj (mi + mj )2 ⎠



⎟ (mi + mj )2 ⎟ ⎠

118

C. Knauer, K. Kriegel, and F. Stehn

Summing over all colors i and all points p ∈ Pi gives b= bip 1≤i≤k p∈Pi



= O⎝



= O⎝



= O⎝





1≤i≤k p∈Pi 1≤j≤k



ni

1≤i≤k





1≤j≤k

ni

1≤i≤k

  = O m2 n 2 .



i≤j≤k

nj (mi + mj )2 ⎠ ⎞

nj (mi + mj )2 ⎠ ⎞

nj (mi + mj )2 ⎠ ⊓ ⊔

Lemma 1 and Lemma 2 together imply that   the combinatorial complexity of the 2 2 α(m2 n2 ) whole decomposition is O m n 2 . The algorithm to compute the translations that minimize the directed Hausdorff distance involves two steps. First, all (multiplicatively weighted) Voronoi diagrams have to be computed. Aurenhammer et al. [8] presented an algorithm    to compute weighted Voronoi diagrams of n sites in O n2 . It takes O m2 n2 time to compute all diagrams, as argued for Lemma 2. In the second step, the blocking areas of all facets of all Voronoi diagrams have to be computed. As shown by Hershberger [9] the upper envelope of n partially defined functions that mutually intersect in at most s points can be computed in O (λs+1 (n) log n) time, where λs (n) denotes the maximum possible length of a (n, s) Davenport–Schinzel sequence. This leads to runtime of  ⊓ ⊔ O m2 n2 α(m2 n2 ) log mn , as stated in the theorem. As shown by Rucklidge [10], the lower bound of the geometric complexity of the graph of f (t) for a single color, i.e., two point sets in the plane, both of size n already is Ω(n3 ). Note, that an exact solution for the special case where all weights of all points are equal (w1 = wk ), can be computed faster. For this case, all multiplicatively weighted Voronoi diagrams are just regular Voronoi diagrams consisting of line segments only. This reduces the complexity of the upper envelope of the boundary of the blocking areas, as two line segments can mutually intersect at most once. For this case, the algorithm and the analysis of the method presented by Huttenlocher et al. [6] can be applied. Corollary 1. The transformations t that minimize f (t) for uniformly weighted  point sets in the plane under translations can be computed in O n2 m log nm time.

Minimizing the Weighted Directed Hausdorff Distance

6

119

Conclusion and Open Problems

We believe that the presented algorithms are a step towards combining established methods of the Computational Geometry community to gain guarantee bounds under the awareness of imprecise data for point-to-point registrations. Further research in this direction is necessary to develop registration algorithms that can be used in medical navigation systems in practice. Probably the most interesting problem – from a practical and theoretical point of view – are exact algorithms for rigid motions, or even “almost rigid” affine transformations, in R3 . For rigid motions, the standard techniques, such as parametric search or the computation of the upper envelope of the involved distance functions, do indeed lead to poly-time algorithms. But unfortunately the actual runtime of these methods is too high to be of any practical use. Another promising direction is to extend the presented results to point-tosurface approximations. This modeling of the problem is closer to the application (surgeons navigate through triangulated surfaces) but on the other hand results in a considerably harder problem.

References 1. Alt, H., Guibas, L.: Discrete geometric shapes: Matching, interpolation, and approximation. In: Handbook of Computational Geometry, pp. 121–153. Elsevier B.V., Amsterdam (2000) 2. Hoffmann, F., Kriegel, K., Sch¨ onherr, S., Wenk, C.: A Simple and Robust Geometric Algorithm for Landmark Registration in Computer Assisted Neurosurgery. Technical Report B 99-21, Freie Universit¨ at Berlin, Fachbereich Mathematik und Informatik, Germany (December 1999) 3. Besl, P.J., McKay, N.D.: A Method for Registration of 3-D Shapes. IEEE Transactions on Pattern Analysis and Machine Intelligence 14(2), 239–256 (1992) 4. Dimitrov, D., Knauer, C., Kriegel, K.: Registration of 3D - Patterns and Shapes with Characteristic Points. In: Proceedings of International Conference on Computer Vision Theory and Applications - VISAPP 2006, Set´ ubal, Portugal, pp. 393– 400 (2006) 5. Dimitrov, D., Knauer, C., Kriegel, K., Stehn, F.: Approximation algorithms for a point-to-surface registration problem in medical navigation. In: Proc. Frontiers of Algorithmics Workshop, Lanzhou, China, pp. 26–37 (2007) 6. Huttenlocher, D.P., Kedem, K., Sharir, M.: The upper envelope of Voronoi surfaces and its applications. In: SCG 1991: Proceedings of the seventh annual symposium on Computational geometry, pp. 194–203. ACM, New York (1991) 7. Sharir, M., Agarwal, P.K.: Davenport-Schinzel sequences and their geometric applications. Cambridge University Press, New York (1996) 8. Aurenhammer, F., Edelsbrunner, H.: An optimal algorithm for constructing the weighted Voronoi diagram in the plane. Pattern Recognition 17(2), 251–257 (1984) 9. Hershberger, J.: Finding the upper envelope of n line segments in O(n log n) time. Inf. Process. Lett. 33(4), 169–174 (1989) 10. Rucklidge, W.: Lower Bounds for the Complexity of the Graph of the Hausdorff Distance as a Function of Transformation. Discrete & Computational Geometry 16(2), 135–153 (1996)

Space–Query-Time Tradeoff for Computing the Visibility Polygon Mostafa Nouri and Mohammad Ghodsi 1

Computer Engineering Department Sharif University of Technology 2 IPM School of Computer Science [email protected], [email protected]

Abstract. Computing the visibility polygon, VP, of a point in a polygonal scene, is a classical problem that has been studied extensively. In this paper, we consider the problem of computing VP for any query point efficiently, with some additional preprocessing phase. The scene consists of a set of obstacles, of total complexity O(n). We show for a query point q, V P (q) can be computed in logarithmic time using O(n4 ) space and O(n4 log n) preprocessing time. Furthermore to decrease space usage and preprocessing time, we make a tradeoff between space usage and query √ √ time; so by spending O(m) space, we can achieve O(n2 log( m/n)/ m) 2 4 query time, where n ≤ m ≤ n . These results are also applied to angular sorting of a set of points around a query point. Keywords: Visibility polygon, logarithmic query time, space–querytime tradeoff, (1/r)-cutting.

1

Introduction

The visibility polygon, or simply VP, of a point is defined as the set of all points of the scene that are visible from that point. In this paper we consider the problem of computing VP of a query point when the scene is a fixed polygonal scene. We can use a preprocessing phase to prepare some data structures based on the scene, then for any query point, we use these data structures to quickly compute VP of that point. The problem of computing VP when the scene is a polygonal domain, is more challenging than for simple polygon scene, which has been studied extensively. In these problems, a scene with total complexity of O(n) consists of a simple polygon with h holes. Without any preprocessing V P (q) can be computed in time O(n log n) by algorithms of Asano [3] and Suri and O’Rourke [15]. This can also be improved to O(n+ h log h) with algorithm of Heffernan and Mitchell [10]. Asano et al. [4] showed that with a preprocessing of O(n2 ) time and space, V P (q) can be reported in O(n) time. It is remarkable that even though |V P | may be very small, the query time is always O(n). Vegter [16] showed that with O(n2 log n) time and O(n2 ) space for preprocessing, we can report V P (q) in an output sensitive manner in time O(|V P (q)| log(n/|V P (q)|)). Pocchiola and X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 120–131, 2009. Springer-Verlag Berlin Heidelberg 2009

Space–Query-Time Tradeoff for Computing the Visibility Polygon

121

Vegter [13] then showed that if the boundary polygon of the scene and its holes are convex polygons, using visibility complex, V P (q) can be reported in time O(|V P (q)| log n) after preprocessing the scene in time O(n log n + E) time and O(E) space, where E is the number of edges in the visibility graph of the scene. Very recently Zarei and Ghodsi [17] proposed an algorithm that reports V P (q) in O((1 + min(h, |V P (q)|)) log n + |V P (q)|) query time. The preprocessing takes O(n3 log n) time and O(n3 ) space. One of the problems with the above mentioned algorithms in the polygonal scene, is the large query time in the worst cases. For example when h = Θ(n) and |V P (q)| = Θ(n) the algorithms of Pocchiola and Vegter [13] and Zarei and Ghodsi [17] degrade to the algorithms without any preprocessing time. For Vegter’s algorithm, we can also generate instances of the problem that use more time than the required time to report V P (q). Another problem with these algorithms, as far as we know, is that they cannot efficiently report some other properties of the VP, like its size without actually computing it. For example in Asano et al. [4], we should first compute V P (q) to be able to determine its size. In this paper, we have introduced an algorithm which can be used to report V P (q) in a polygonal scene in time O(log n+ |V P (q)|), using O(n4 log n) preprocessing time and O(n4 ) space. The algorithm can be used to report the ordered visible edges and vertices of the scene around a query point or the size of V P (q) in optimal time O(log n). The solution of the algorithm can also be used for further preprocessing to solve many other problems faster than before (e.g., line segment intersection with VP). Because the space used in the preprocessing is still high, we have modified the algorithm to obtain a tradeoff between the space and query time. With √ this modifications, using O(m) space and O(m log( m/n)) time in the preprocessing, where n2 ≤ m ≤ n4 , we can find the combinatorial √ representation √ (to be described later) of V P (q) in time O(n2 log( m/n)/ m). If we need to report the actual V P (q), additional O(|V P (q)|) time is required in query time. The above algorithms are also described for the problem of angular sorting of some points around a query point and the same results are also established for it, i.e., we can return a data structure containing √ the set of n points sorted √ around a√query point in time O(n2 log( m/n)/ m) using O(m) space and O(m log( m/n)) preprocessing time where n2 ≤ m ≤ n4 . The actual sorted points can then be reported using O(n) additional time. The remaining of this paper is organized as follows: In Section 2 we first describe how we can sort n points around a query point in logarithmic time using a preprocessing. We then use this solution to develop a similar result for computing VP. In Section 3 we obtain a tradeoff between space and query time for both problems. Section 4 describes some of immediate applications of the new algorithms, and finally, Section 5 summarizes the paper.

122

2

M. Nouri and M. Ghodsi

Logarithmic Query Time

In this section we develop an algorithm with optimal query time for computing VP of a query point. Since the problem of angular sorting points is embedded in the computation of VP, we first consider it. 2.1

Angular Sorting

Let P = {p1 , . . . , pn } be a fixed set of n points and q, a query point in the plane. Let θq (pi ) denote the counterclockwise angle of the line connecting q to pi with the positive y-axis. The goal is to find the sorted list of pi in increasing order of θq (pi ). Let θq denote this sorted list. The idea is to partition the plane into a set of disjoint cells, totally covering the plane, such that for all points in a cell r, the sorted sequences are the same. Let the sequence be denoted by θr . This partitioning is obtained by some rays, called critical constraints. A critical constraint cij lies on the line through the points pi , pj . It is the ray emanating from pi in the direction that points away from pj . That is, every line through two points contains two critical constraints (see Fig. 1). If q moves slowly, it can be shown that θq changes only when q crosses a critical constraint. When q crosses cij , pi and pj , which are adjacent in θq , are swapped. The following lemma, summarizes this observation, which is an adaptation of a similar lemma in [2] for our case. Lemma 1. Let P = {p1 , . . . , pn } be a set of non-degenerate points in the plane, i.e., no three points lie on a line. Let q and q ′ be two points not on any critical constraint of points of P . The ordered sequences of points of P around q and q ′ , i.e., θq and θq′ differ iff they are on the opposite sides of some critical constraint. Proof. The lemma can be proved by a similar argument to that used by Aronov et al. [2] ⊓ ⊔ Let C denote the set of critical constraints cij , for 1 ≤ i, j ≤ n, and A(C) denote the arrangement of the constraints in C. In Fig. 1 the arrangement of critical

Fig. 1. Arrangement of critical constraints for P = {p1 , p2 , p3 , p4 }. q1 , q2 and q4 see the points in different angular orders, while q2 and q3 see in the same order.

Space–Query-Time Tradeoff for Computing the Visibility Polygon

123

constraints for a set of four points is illustrated. The  complexity of A(C) is not greater than the complexity of the arrangement of n2 lines, so |A(C)| = O(n4 ). This implies the following corollary. Corollary 1. The plane can be decomposed into O(n4 ) cells, such that all points in a cell see the points of P in the same angular order. From the above corollary, a method for computing θq for a query point q can be derived. In the preprocessing phase, for each cell r in A(C), θr is computed and stored. Moreover A(C) is preprocessed for point location. Upon receiving a query point q, the cell r in which q lies is located, and θr is simply reported. In spite of the simplicity of the algorithm, its space complexity is not satisfactory. The required space (resp. time) to compute the sorted sequences of points for each cell of A(C) is O(n) (resp. O(n log n)). So for computing θr for all the cells in the arrangement, O(n5 ) space and O(n5 log n) time is required. For any two adjacent cells r, r′ in A(C), θr and θr′ differ only in two (adjacent) position. To utilize this low rate of change and reduce the required time and space for the preprocessing, a persistent data structure, e.g., persistent red-black tree, can be used. A persistent red-black tree, or PRBT, introduced by Sarnak and Tarjan [14], is a red-black tree capable of remembering its earlier versions, i.e., after m updates into a set of n linearly ordered items, any item of version t of the red-black tree, for 1 ≤ t ≤ m can be accessed in time O(log n). PRBT can be constructed in O((m + n) log n) time using O(m + n) space. In order to use PRBT, a tour visiting all the cells of A(C) is needed. Using a depth-first traversal of the cells, a tour visiting all the cells and traversing each edge of A(C) at most twice is obtained. Initially, for an arbitrary cell in the tour, θr is computed from scratch and stored in PRBT. For the subsequent cells in the tour, we update PRBT accordingly by simply reordering two points. Finally, when all the cells of A(C) are visited, θr is stored in PRBT for all of them. Constructing A(C) and the tour visiting all the cells, takes O(n4 ) time. Computing θr for the first cell needs O(n log n) time and O(n) space, and subsequent updates for O(n4 ) cells need O(n4 log n) time and O(n4 ) space. A point location data structure for A(C) is also needed that can be created in O(n4 ) time and space [5]. Totally the preprocessing phase is completed in O(n4 log n) time using O(n4 ) space. The query time consists of locating the cell in which the query point q lies, and finding the related root of the tree for that cell. Each of these tasks can be accomplished in O(log n) time. Theorem 1. A set P of n points in the plane can be preprocessed in O(n4 log n) time using O(n4 ) space, such that for any query point q, a pointer to a red-black tree which stores θq can be returned in time O(log n). 2.2

Visibility Polygon Computation

In this section we consider the problem of computing VP in a polygonal scene. Let O = {o1 , . . . , on } be a set of line segments which may intersect each other

124

M. Nouri and M. Ghodsi

only at their end-points. These segments are the set of all edges of the polygonal scene. Let q be a query point in the scene. The goal is to compute V P (q) efficiently using enough preprocessing time and space. Since VP of each point is unique, the plane cannot be partitioned into cells in which all points have equal VP. But we can decompose it into cells such that in each cell all points have similar VP’s, or formally combinatorial structures of VP’s, denoted by VP, are equal. Combinatorial structure of V P (q) is a circular list of visible edges and vertices of the scene in the order of their angle around q. Let P = {p1 , . . . , pk } be the set of the end-points of the segments in O, where k ≤ 2n. With an observation similar to the one in the previous section, the arrangement of critical constraints (the rays emanating from pi in the direction that points away from pj for 1 ≤ i, j ≤ k, i = j), determines the cells in which VP(q) is fixed and for each two adjacent cells these structures differ only in O(1) edges and vertices. Due to the changes in the scene, the critical constraints differ from what previously described. If a pair of points are not visible from each other, they do not produce any critical constraint at all. Some critical constraints may also be line segments, this happens when a critical constraint encounters an obstacle. Since for two points q and q ′ in the opposite sides of an obstacle VP(q) = VP(q ′ ), the obstacles are also added to the set of critical constraints. Since these differences do not increase the upper bound on the number of cells in the arrangement of critical constraints asymptotically, the argument about the complexity of the arrangement of critical constraints, which is called in this case visibility decomposition, remains valid, so we can rewrite the corollary as below. Corollary 2. In a polygonal scene of complexity O(n), the plane can be decomposed into O(n4 ) cells, such that all points in a cell have equal VP. Moreover VP of each two adjacent cells can be transformed to each other by O(1) changes. Using the above result, the method in the previous section can be applied to compute VP(q) for any point q in O(log n) time, using O(n4 ) space and O(n4 log n) time for preprocessing. If the actual V P (q) (all the vertices and edges of VP) is to be computed, additional O(|V P (q)|) time is needed. This can be done by examining the vertices and edges of VP(q) and finding non-obstacle edges and the corresponding vertices of V P (q) (see Fig. 2). Theorem 2. A planar scene consists of n segment obstacles can be preprocessed in O(n4 log n) time and O(n4 ) space, such that for any query point q, a pointer to a red-black tree which stores VP(q) can be returned in time O(log n). Furthermore the visibility polygon of the point, V P (q), can be reported in time O(log n + |V P (q)|). It is easy to arrange a scene such that the number of combinatorially different visibility polygons is Θ(n4 ) (e.g., see [17]). Therefore it seems likely that the above result is the best we can reach for optimal query time.

Space–Query-Time Tradeoff for Computing the Visibility Polygon

125

Fig. 2. Part of the visibility polygon of a point. The thick dashed lines denote the visibility polygon of q. Non-obstacle edges and non-obstacle vertices of the visibility polygon are marked in the figure.

3

Space–Query-Time Tradeoff

In Section 2, an algorithm with logarithmic query time for computing VP is presented that uses O(n4 ) space and O(n4 log n) preprocessing time. Asano et al. [4] have shown that we can compute VP of a point in a polygonal scene in O(n) time by preprocessing the scene in O(n2 ) time using O(n2 ) space. In this section, these results are combined and a tradeoff between the memory usage and the query time for computing the visibility polygon is obtained. 3.1

Angular Sorting

As in Section 2, we first consider the problem of angular sorting points around a query point. In this problem, P , θq (pi ) and θq are defined similar to the previous section. We assume the points are in the general position in the plane, so that no three points are collinear and for 1 ≤ i ≤ n, pi q does not lie on a vertical line. In contrast to the previous section, here at most o(n4 ) space can be used. For this problem the plane can be partitioned into disjoint cells, such that θq does not change significantly when q moves in each cell (similar to the method of Aronov et al. [2] to obtain space–query-time tradeoff). Unfortunately with this method, using O(n3 ) space, query time of O(n log n) is achieved which is not adequate. Linear time algorithm for sorting points. To be able to use the technique used by Asano et al. [4], let us review their method with some modifications. Consider the duality transform that maps the point p = (px , py ) into the line p∗ : y = px x − py and the line l : y = mx + b into the point l∗ = (m, −b). This transformation preserves incidence and order between points and lines [8], i.e., p ∈ l iff l∗ ∈ p∗ and p lies above l iff l∗ lies above p∗ . Let A(P ∗ ) denote the arrangement of the set of lines P ∗ = {p∗1 , . . . , p∗n }. Line ∗ q can also be inserted in the arrangement in O(n) time [6]. Let rq denote the vertical upward ray from q and lq its supporting line. When rq rotates around q

126

M. Nouri and M. Ghodsi

counterclockwise 180 , it touches all the half-plane to the left of q, and lq∗ slides on line q ∗ from −∞ to +∞. Whenever rq reaches a point pi , lq∗ lies on p∗i . Thus the order of all points pi in the left half-plane of vertical line through q according to θq (pi ), is the same as the order of intersection points between q ∗ and the dual of those points according to x-coordinate. The same statement holds for the right half-plane of vertical line through q. Using this correspondence between orders, θq can be computed in linear time. Lemma 2. [Asano et al.] Using O(n2 ) preprocessing time and O(n2 ) space for constructing A(P ∗ ) by an algorithm due to Chazelle et al. [6], for any query point q, we can find the angular sorted list of pi , 1 ≤ i ≤ n, in O(n) time. Sublinear query time algorithm for sorting points. Before describing the algorithm with space–query-time tradeoff, we should explain another concept. Let L be a set of lines in the plane. A (1/r)-cutting for L is a collection of (possibly unbounded) triangles with disjoint interiors, which cover all the plane and the interior of each triangle intersects at most n/r lines of L. Such triangles together with the collection of lines intersecting each triangle can be found for any r ≤ n in time O(nr). The first (though not optimal) algorithm for constructing cutting is presented by Clarkson [7]. He showed that a random sample of size r of the lines of L can be used to produce a fairly good cutting. Efficient construction of (1/r)-cuttings of size O(r2 ) was given by Matouˇsek [11] and then improved by Agarwal [1]. As will be described later, a cutting that is effective for our purpose, has a specific property. To simplify the algorithm, in this section we describe the method using random sampling and give a simple (but inefficient) randomized solution. Later we show how an efficient cutting introduced by Chazelle [5] can be used with some modifications instead, to make the algorithm deterministic and also reduce the preprocessing and query time and space. The basic idea in random sampling is to pick a random subset R of r lines from L. It can be proved [7] that with high probability, each triangle of any triangulation of the arrangement of R, A(R), intersects O((n log r)/r) lines of L. Let R be a random sample of size r of the set of lines P ∗ = {p∗1 , . . . , p∗n }. Let A(R) denote the arrangement of R and R denote a triangulation of A(R). According to the random sampling theory, with high probability, any triangle t ∈ R intersects O((n log r)/r) lines of P ∗ . Lemma 3. Any line l in the plane, intersects at most O(r) triangles in R. Proof. It is a trivial application of the Zone Theorem [9] and is omitted.

⊓ ⊔

The above lemma states that the line q ∗ intersects O(r) triangles of R and for each such triangle t, the intersection segment q ∗ ∩ t is the dual of a double wedge wt , with q as its center, in the primal plane. Therefore the primal plane is partitioned into O(r) co-centered disjoint double wedges, totally covering all the plane. For computing θq , it is adequate to sort the points inside each double wedge, and then join these sorted lists sequentially. Let each sorted sublist be

Space–Query-Time Tradeoff for Computing the Visibility Polygon

127

denoted by θq (t). The sorted list θq (t) can be computed by first finding the sorted list of points whose dual intersect the triangle t, denoted by P (t), and then confining the results to the double wedge wt . In order to sort the points of P (t) in each triangle t ∈ R efficiently, we can use the method of Section 2. At the query stage, θq (t) is computed by performing four binary search in the returned red-black tree, to find the head and the tail of the two sublists that lie in the double wedge (one sublist for the left half-plane and one for the right half-plane). In this way, O(log |P (t)|) canonical subsets from the red-black tree are obtained whose union form the two sorted lists. This procedure is repeated for all triangles t ∈ R that are intersected by q ∗ and O(r) sorted lists θq (t) are obtained which should be concatenated sequentially to make θq . Constructing a (1/r)-cutting for P ∗ together with computing the lines intersected by each triangle uses O(nr) time and space, for 1 ≤ r ≤ n. Preprocessing a triangle t for angular sorting takes O(|P (t)|4 ) space and O(|P (t)|4 log |P (t)|) time, which sum up to O((n4 log4 r)/r2 ) space and O((n4 log4 r log(n log r/r))/r2 ) time for all O(r2 ) triangles. At query time, each sorted subsequence is found in O(log((n log r)/r)) time, and the resulting canonical subsets are joined in O(r log((n log r)/r)) time. Using efficient cutting. Efficient cuttings that can be used for our approach have a special property: Any arbitrary line intersect O(r) triangles of the cutting. We call this property the regularity of the cutting. Many algorithms have been proposed for constructing a (1/r)-cutting for a set of lines, but most of them do not fulfill regularity property. A good cutting which with some modifications satisfies the regularity was introduced by Chazelle [5]. Due to space limitations, we describe our modifications to make Chazelle’s algorithm regular in the full version of the paper. We here only mention the final result of applying this efficient cutting. Theorem 3. A set of n points in the plane can be preprocessed into a data √ structure of size O(m) for n2 ≤ m ≤ n4 , in O(m log( m/n)) time, such that for any query point √ q, the angular sorted list of points, θq , can be returned in √ O(n2 log( m/n)/ m) time. 3.2

Space–Query-Time Tradeoff for Computing the Visibility Polygon

We can use the tradeoff between space and query-time for computing θq , to achieve a similar tradeoff for computing VP. The set O of the obstacle segments and the set P of the end-points of the segments are defined as before. Let A(P ∗ ) denote the arrangement of dual lines of points of P . Based on this arrangement, we compute a regular (1/r)-cutting as described in Section 3.1 and decompose the plane into O(r2 ) triangles such that any triangle is intersected by at most O(n/r) lines of P ∗ , and the dual line of any point q intersects at most O(r) triangles of the cutting. As described in Section 3.1, the intersections of q ∗ with the triangles that are intersected by q ∗ , partition the primal plane into O(r) co-centered disjoint

128

M. Nouri and M. Ghodsi

Fig. 3. (a) In the dual plane, the triangle t, dual of t0 , is intersected by q ∗ . The dual of some of obstacle segments are also shown. (b) The arrangement of t0 , q and obstacle segments in the primal plane.

double wedges, totally covering all the plane. Therefore it is enough to compute VP(q) bounded to each double wedge and join the partial VP’s sequentially. Let the double wedge created by the triangle t be denoted by wt and VP(q) bounded to wt denoted by VP(q, t). VP(q, t) is computed very similar to the method described in Section 3.1 for computing θq (t). The only thing we should care is the possibility of the presence of some segments in VP(q, t) none of whose end-points lies in wt . In Fig. 3(a) the triangle t in the dual plane is shown which is intersected by q ∗ . The triangle t is also intersected by O(n/r) lines which are dual to the endpoints of O(n/r) segments of O. We call these segments the closed segments of t, denoted by the set CSt . At least the dual of one end-point of each segment in CSt intersects t. There are also some segments in O which are not in CSt , but may appear in VP(q), for example s8 in Fig. 3. We call these segments the open segments of t, denoted by the set OSt . OSt consists of all the segments whose dual double wedge contains t completely. The triangle t0 , whose dual is t, as in Fig. 3(b), partition the plane into three regions. A region, which is brighter in the figure, is the region that q and at least one end-point of each segment of CSt lie (for example segments s9 and s10 ). In contrast, we have two regions, which is shaded in the figure, and contains at most one end-point of each segment of CSt and both end-points of the other segments of O. If an end-point of a segment oi lies in a shaded region and the other endpoint in the other shaded region, oi belongs to OSt (for example segments s4 , s6 and s8 ). By the above observations, and the fact that the segments of O may intersect each other only at their end-points, we conclude that the segments in OSt partition the bright region, the region which contains q, into |OSt | + 1 subregions. Let |OS |+1 Rt = {rt1 , . . . , rt t } denote the set of subregions. In each region rtk , a set of k segments CSt ⊂ CSt is contained. Since VP(q, t) is limited to the subregion rtk

Space–Query-Time Tradeoff for Computing the Visibility Polygon

129

in which q lies, for computing VP(q, t), we should first find rtk , and then compute VP(q) which is bounded to rtk and the double wedge wt . First assume we know where q lies, i.e., we know the region rtk ∈ Rt that contains q, where 1 ≤ k ≤ |OSt | + 1. Any point inside rtk can see only the set of segments CStk . If in the preprocessing phase, for each region rtk we use the method of Section 2.2 with CStk as obstacles, we can find VP(q, t) bounded to wt in time O(log(|CStk |)) = O(log(n/r)). A trick is needed here to preprocess only non-empty regions of Rt , since otherwise an additional linear space is imposed, 3 which may be undesirable when r > O(n 4 ). If we do not preprocess empty regions rtk , in which no closed segment lies, i.e., CStk = ∅, the preprocessing time reduces to O((n/r)4 log(n/r)) and the space to O((n/r)4 ). Whenever a query point q is received, we first find the region rtk in which q lies. If CStk = ∅, we can use the related data structures to compute VP(q, t), otherwise rtk consists of only two segments, oi , oj ∈ OSt , and we can easily compute VP(q) bounded to wt in O(1) time. There are three data structures, Rt , CStk and CSt that should be computed in the preprocessing phase. CSt of complexity O(n/r), which is already computed during the construction of the cutting R, is the set of segments with an endpoint whose dual intersects t. However the process of computing Rt and CStk is somewhat complicated and due to space limitations we give the details of the computation in the full version of the paper. Briefly, Rt of complexity O(n) takes much space and time, so we cannot explicitly compute it for all the triangles of R. We use a data structure to compute Rt of a triangle t based on Rt′ where t′ is a neighbor triangle of t. By this data structure, we can also compute CStk for each triangle t and 1 ≤ k ≤ |OSt | + 1. This procedure takes O(rn log(n/r)) time and O(rn) space. At the query time rtk that contains q can be found in total O(r log(n/r)) time for all the triangles that are intersected by q ∗ . For each triangle t, from rtk , we can easily compute VP(q) bounded by wt in O(log(n/r)) time. Summing up these amounts, we can compute VP(q) in O(r log(n/r)) time. In summary, the total preprocessing time and space are O(n4 log(n/r)/r2 ) and O(n4 /r2 ) respectively and the query time is O(r log(n/r)). If the used space is denoted by m we can conclude the following theorem. Theorem 4. A planar polygonal scene of total complexity O(n) can be√prepro4 cessed into a data structure of size O(m) for n2 ≤ m ≤ O(m log( m/n)) √ n , in √ 2 time, such that for any query point q, in O(n log( m/n)/ m) time VP(q) can be returned. Furthermore √the visibility polygon of the point, V P (q), can be √ reported in O(n2 log( m/n)/ m + |V P (q)|) time.

4

Applications

In this section we use the previous results for computing the visibility polygon and apply them to some other related problems.

130

4.1

M. Nouri and M. Ghodsi

Maintaining the Visibility Polygon of a Moving Point

Let q be a point in a polygonal scene. The problem is to update V P (q) as it moves along a line. We can use the technique previously used to compute V P of a query point, to maintain V P of a moving point in the plane. Due to space limitations, we only describe the final result. Theorem 5. A planar polygonal scene of total complexity n can be √preprocessed into a data structure of size O(m), n2 ≤ m ≤ n4 , in time O(m log( m/n)), such that for any query point q which moves along a line, V P (q) can be maintained √ 2 2 in time O(( √nm + k)(log √nm + log nm )) where k is the number of combinatorial visibility changes in V P (q). It is remarkable that the moving path need not to be a straight line, but it can be broken at some points. In this case, the number of break points is added to the number of combinatorial changes in the above upper bounds. 4.2

The Weak Visibility Polygon of a Query Segment

The weak visibility polygon of a segment rs is defined as the set of points in the plane, that are visible from at least a point on the segment. Using the previous result about maintaining the visibility polygon of a moving point, the weak visibility polygon of a query segment can be computed easily. We here only mention the last theorem and leave the proof for the extended version of the paper. Theorem 6. A planar polygonal scene of total complexity n can be √ preprocessed into a data structure of size O(m), n2 ≤ m ≤ n4 , in O(m log( m/n)) time, 2 such that for any query segment rs, V P (rs) can be computed in time O(( √nm + |V P (rs)|)(log 4.3

n2 √ m

+ log



m n )).

Weak Visibility Detection between Two Query Objects

In [12] Nouri et al. studied the problem of detecting weak visibility between two query objects in a polygonal scene. Formally, a scene consists of some obstacles of total complexity n, should be preprocessed, such that given any two query objects, we can quickly determine if the two objects are weakly visible. They proved that using O(n2 ) space and O(n2+ǫ ) time for any ǫ > 0, we can answer queries in O(n1+ǫ ). In their paper, they mentioned that the bottleneck of the algorithm is the time needed to compute the visibility polygon of a query point, and if it can be answered in a time less than Θ(n) in the worst case, the total query time will be reduced. Here we summarize the result of applying the new technique for computing V P (q) and defer the details to the full version of the paper. Theorem 7. A planar polygonal scene of total complexity n can be preprocessed in O(m1+ǫ ) time to build a data structure of size O(m), where n2 ≤ m ≤ n4 , so that the √ weak-visibility between two query line segments can be determined in O(n2+ǫ / m) time.

Space–Query-Time Tradeoff for Computing the Visibility Polygon

5

131

Conclusion

In this paper we studied the problem of computing the visibility polygon. We present a logarithmic query time algorithm, when we can use O(n4 log n) time and O(n4 ) space in the preprocessing phase. As the algorithm requires much space, the algorithm was modified to get a tradeoff between space usage and query time. √ With√this tradeoff, VP of a query point can be computed in time O(n log( m/n)/ m) using O(m) space, where n2 ≤ m ≤ n4 . This problem may have many applications in other related problems. An interesting future work is to find more applications for the proposed algorithms. It is also an interesting open problem, whether our algorithms are optimal regarding space usage and preprocessing time.

References 1. Agarwal, P.K.: Partitioning arrangements of lines, part I: An efficient deterministic algorithm. Discrete Comput. Geom. 5(5), 449–483 (1990) 2. Aronov, B., Guibas, L.J., Teichmann, M., Zhang, L.: Visibility queries and maintenance in simple polygons. Discrete Comput. Geom. 27(4), 461–483 (2002) 3. Asano, T.: Efficient algorithms for finding the visibility polygon for a polygonal region with holes. Manuscript, University of California at Berkeley 4. Asano, T., Asano, T., Guibas, L.J., Hershberger, J., Imai, H.: Visibility of disjoint polygons. Algorithmica 1(1), 49–63 (1986) 5. Chazelle, B.: Cutting hyperplanes for divide-and-conquer. Discrete Comput. Geom. 9, 145–158 (1993) 6. Chazelle, B., Guibas, L.J., Lee, D.T.: The power of geometric duality. BIT 25(1), 76–90 (1985) 7. Clarkson, K.L.: New applications of random sampling in computational geometry. Discrete Comput. Geom. 2(2), 195–222 (1987) 8. de Berg, M., van Kreveld, M., Overmars, M., Schwarzkopf, O.: Computational geometry: algorithms and applications. Springer, New York (1997) 9. Edelsbrunner, H., Seidel, R., Sharir, M.: On the zone theorem for hyperplane arrangements. SIAM J. Comput. 22(2), 418–429 (1993) 10. Heffernan, P.J., Mitchell, J.S.B.: An optimal algorithm for computing visibility in the plane. SIAM J. Comput. 24(1), 184–201 (1995) 11. Matouˇsek, J.: Construction of ǫ-nets. Disc. Comput. Geom. 5, 427–448 (1990) 12. Nouri, M., Zarei, A., Ghodsi, M.: Weak visibility of two objects in planar polygonal scenes. In: Gervasi, O., Gavrilova, M.L. (eds.) ICCSA 2007, Part I. LNCS, vol. 4705, pp. 68–81. Springer, Heidelberg (2007) 13. Pocchiola, M., Vegter, G.: The visibility complex. Int. J. Comput. Geometry Appl. 6(3), 279–308 (1996) 14. Sarnak, N., Tarjan, R.E.: Planar point location using persistent search trees. Commun. ACM 29(7), 669–679 (1986) 15. Suri, S., O’Rourke, J.: Worst-case optimal algorithms for constructing visibility polygons with holes. In: Symp. on Computational Geometry, pp. 14–23 (1986) 16. Vegter, G.: The visibility diagram: A data structure for visibility problems and motion planning. In: Gilbert, J.R., Karlsson, R. (eds.) SWAT 1990. LNCS, vol. 447, pp. 97–110. Springer, Heidelberg (1990) 17. Zarei, A., Ghodsi, M.: Efficient computation of query point visibility in polygons with holes. In: Proc. of the 21st symp. on Comp. geom, pp. 314–320 (2005)

Square and Rectangle Covering with Outliers Hee-Kap Ahn1 , Sang Won Bae1 , Sang-Sub Kim1 , Matias Korman2 , Iris Reinbacher1 , and Wanbin Son1 1

Department of Computer Science and Engineering, POSTECH, South Korea {heekap,swbae,helmet1981,irisrein,mnbiny}@postech.ac.kr 2 Graduate School of Information Science, Tohoku University, Japan [email protected]

Abstract. For a set of n points in the plane, we consider the axis– aligned (p, k)-Box Covering problem: Find p axis-aligned, pairwise disjoint boxes that together contain exactly n − k points. Here, our boxes are either squares or rectangles, and we want to minimize the area of the largest box. For squares, we present algorithms that find the solution in O(n + k log k) time for p = 1, and in O(n log n + kp logp k) time for p = 2, 3. For rectangles we have running times of O(n + k3 ) for p = 1 and O(n log n + k2+p logp−1 k) time for p = 2, 3. In all cases, our algorithms use O(n) space.

1

Introduction

Motivated by clustering, we consider the problem of splitting a set of points into groups. From a geometric point of view, we want to group points together that are ’close’ with respect to some distance measure. It is easy to see that the choice of distance measure directly influences the shape of the clusters. Depending on the application, it may be useful to consider only disjoint clusters. It is important to take noise into account, especially when dealing with raw data. That means, we may want to remove outliers that are ’far’ from the clusters, or that would unduly influence their shape. In this paper, we will investigate the following problem: Given a set P of n points in the plane, the (p, k)-Box Covering problem is to find p pairwise disjoint boxes that together contain n − k points of P , such that the area of the largest box is minimized. Previous work on this problem has mainly focused on the problem without outliers. The (p, 0)-Rectangle Covering problem is closely related to the general rectilinear p-center problem where rectangles are of arbitrary size and are allowed to overlap. The p-center problem is of LP type for p ≤ 3 [15], and thus can be solved in linear time for these cases [11]. When p ≥ 4, Sharir and Welzl [15] show that the required time is O(n log n) or O(npolylogn), depending on the value of p. For p = 2, Bespamyatnikh and Segal [4] presented a deterministic algorithm that runs in O(n log n) time. Several papers consider variations of the problem without outliers, e.g., arbitrary orientation of up to two boxes, and achieve different running times, see for example [2,8,9,10,12]. X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 132–140, 2009. c Springer-Verlag Berlin Heidelberg 2009 

Square and Rectangle Covering with Outliers

133

There is less work when outliers are allowed, most of it considers the (1, k)Box Covering problem. Aggarwal et al. [1] achieved a running time of O((n − k)2 n log n) using O((n − k)n) space for the (1, k)-Box Covering, where the box is an axis-parallel square or rectangle. Later, Segal and Kedem [14] gave an O(n + k 2 (n − k)) algorithm for the (1, k)-Rectangle Covering problem using O(n) space. A randomized algorithm that runs in O(n log n) time was given for the (1, k)-Square Covering problem by Chan [5]. Our algorithms exploit the monotonicity of certain functions over n and k in the problem in depth and use a recursive approach to solve the (p, k)-Box Covering problem for p ≤ 3. We can achieve a running time of O(n + k log k) for the (1, k)-Square Covering problem, and of O(n + k 3 ) for the (1, k)Rectangle Covering problem. In both cases, we use only O(n) space. This improves all previous results in time complexity without increasing the space requirement. For p ∈ {2, 3}, our algorithms compute the optimal solutions of the (p, k)Square Covering problem in O(n log n + k 2 log2 k) time for p = 2, and in O(n log n + k 3 log3 k) time for p = 3. For the (p, k)-Rectangle Covering problem, we need O(n log n + k 4 log k) time for p = 2 and O(n log n + k 5 log2 k) time for p = 3. Note that our algorithms can be generalized to other functions than minimum area (e.g., minimizing the maximum perimeter of the boxes) as long as the function is monotone and we can solve the subproblems induced by the p boxes independently. We first focus on the (p, k)-Square Covering problem in Section 2. We will use the solution of the (1, k)-Square Covering problem as base case for larger p, which will be described in Subsections 2.2 and 2.3. In Section 3, we show the extension of the square covering solution to the case of axis-aligned rectangles.

2

Square Covering

Given a set P of n points in the plane, and an integer k, we consider the (p, k)Square Covering problem: Find p axis–aligned pairwise disjoint squares that together cover exactly n − k points of P , such that the area of the largest square is minimized. We will refer to the k points that are not contained in the union of all boxes as outliers, and we will consider the boxes to be axis-aligned squares or rectangles. Throughout the paper we assume that no two points in P have the same x-coordinate, or the same y-coordinate. Before we present our approach to the (p, k)-Square Covering problem, we give the following lower bound. Lemma 1. If k is part of the input, for any n points in the plane there is an Ω(n log n) lower bound on computing the p enclosing squares or rectangles with minimal area in the algebraic decision tree model. Proof. We reduce from set disjointness: Given a sequence S of n points in R2 , we want to decide whether there is any repeated element in S.

134

H.-K. Ahn et al.

Consider first the case in which the boxes are squares. Given any sequence x1 , . . . , xn , where xi ∈ R2 , we compute the p minimal enclosing squares allowing k = n − p − 1 outliers, which means that the union of the p squares must cover exactly p + 1 points. Thus, the enclosing squares will be degenerated squares of side length zero if and only if there is a repeated element in the sequence. Otherwise, by the pigeon hole principle, one of the covering squares must cover at least two points and hence, will have a positive area. The rectangle case can be shown similarly. ⊓ ⊔ Note that similar proofs for slightly different problems were given by Chan [5] (p = 1, bound in both parameters) and by Segal [13] (p = 2, k = 0, arbitrary orientation). In the following section, we will present the base case for our recursion. 2.1

(1, k)-Square Covering

Before focusing on our algorithm, we mention the previously fastest algorithm for the (1, k)-Square Covering problem by Chan [5]: Theorem 1 ([5]). Given a set P of n points in the plane, the (1, k)-Square Covering problem can be solved in O(n log n) expected time using O(n) space. A point p ∈ P is called (k + 1)-extreme if either its x- or y-coordinate is among the k + 1 smallest or largest in P . Let E(P ) be the set of all (k + 1)-extreme points of P . Lemma 2. For a given set P of n points in the plane, we can compute the set E(P ) of all (k + 1)-extreme points of P in O(n) time. Proof. We first select the point pL (pR , resp.) of P with (k + 1)-st smallest (largest, resp.) x-coordinate in linear time using a standard selection algorithm [7]. We go through P again to find all points with x-coordinates smaller (larger, resp.) than pL (pR , resp.). Similarly, we select the point pT (pB , resp.) of P that has the (k + 1)-st largest (smallest, resp.) y-coordinate in linear time, and we go through P again to find all points with y-coordinates larger (smaller) ⊓ ⊔ than pT (pB , resp.). It is easy to see that the left side of the optimal solution of the (1, k)-Square Covering problem lies on or to the left of the vertical line through pL , and that the right side lies on or to the right of the vertical line through pR (otherwise there are more than k outliers). Similarly, the top side of the optimal solution lies on or above the horizontal line through pT , and the bottom side lies on or below the horizontal line through pB , which leads to the following lemma: Lemma 3. The optimal square B ∗ that solves the (1, k)-Square Covering problem is determined by the points of E(P ) only. Using this lemma, we can improve the running time of Chan’s algorithm stated in Theorem 1. Note that, as we use Chan’s algorithm in our approach, our algorithms become randomized as well, if k is large.

Square and Rectangle Covering with Outliers



135

pn

pm pm+1

p1

m points (k ′ outliers)

n − m points (k − k ′ outliers)

Fig. 1. For given k′ and m, the optimal m∗ lies on the side with the larger square

Theorem 2. Given a set P of n points in the plane, the (1, k)-Square Covering problem can be solved in O(n + k log k) expected time using O(n) space. Proof. We first compute the set of extreme points E(P ) in linear time and then use Chan’s algorithm from Theorem 1 on the set E(P ). The time bound follows directly, since |E(P )| ≤ 4k + 4. ⊓ ⊔ 2.2

(2, k)-Square Covering

The following observation is crucial to solve the (2, k)-Square Covering problem, where we look for two disjoint squares that cover n − k points. Observation 1. For any two disjoint axis-aligned squares in the plane, there exists an axis-parallel line ℓ that separates them. This observation implies that there is always an axis-parallel line ℓ that separates the two optimal squares (B1∗ , B2∗ ) of the solution of a (2, k)-Square Covering problem. Let ℓ+ be the halfplane defined by ℓ that contains B1∗ . Let P + be the set of points of P that lie in ℓ+ (including points on ℓ), and let k + be the number of outliers admitted by the solution of the (2, k)-Square Covering problem that lie in ℓ+ . Then there is always an optimal solution of the (1, k + )-Square Covering problem for P + with size smaller than or equal to that of B1∗ . The same argument also holds for the other halfplane ℓ− , where we have B2∗ , and k − = k − k + . Thus, the pair of optimal solutions of B1∗ of the (1, k + )-Square Covering problem and B2∗ of the (1, k − )-Square Covering problem is an optimal solution of the original (2, k)-Square Covering problem. Lemma 4. There exists an axis-parallel line ℓ and a positive integer k ′ ≤ k such that an optimal solution of the (2, k)-Square Covering problem for P consists of the optimal solution of the (1, k ′ )-Square Covering problem for P + and the (1, k − k ′ )-Square Covering problem for P − .

136

H.-K. Ahn et al.

We assume w.l.o.g. that ℓ is vertical, and we associate ℓ with m, the number of points that lie to the left of (or on) ℓ. Let p1 , p2 , . . . , pn be the list of points in P sorted by x-coordinate. Then ℓ partitions the points of P into two subsets, a left point set, PL (m) = {p1 , . . . , pm } and a right point set, PR (m) = {pm+1 , . . . , pn }, see Fig. 1. Then the optimal left square is a solution of the (1, k ′ )-Square Covering problem for PL (m) for 0 ≤ k ′ ≤ k, and the optimal right square is a solution of the (1, k − k ′ )-Square Covering problem for PR (m). We can efficiently compute the optimal solutions for PL (m) and PR (m) on each halfplane of a vertical line ℓ using the above (1, k)-Square Covering algorithm. However, as we will consider many partitioning lines, it is important to find an efficient way to compute the (k + 1)-extreme points for each PL (m) and PR (m) corresponding to a particular line ℓ. For this we will use Chazelle’s segment dragging query algorithm [6]. Lemma 5 ([6]). Given a set P of n points in the plane, we can preprocess it in O(n log n) time and O(n) space such that, for any axis–aligned orthogonal range query Q, we can find the point p ∈ P ∩ Q with highest y-coordinate in O(log n) time. Using the above algorithm k + 1 times allows us to find the k + 1 points with highest y-coordinate in any halfplane. We can rotate the set P to find all other elements of E(P ) in the according half plane, and we get the following time bound. Corollary 1. After O(n log n) preprocessing time, we can compute the sets E(PL (m)) and E(PR (m)) in O(k log n) time for any given m. Before presenting our algorithm we need the following lemma: Lemma 6. For a fixed k ′ , the area of the solution of the (1, k ′ )-Square Covering problem for PL (m) is an increasing function of m. Proof. Consider the set PL (m + 1) and the optimal square B1∗ of the (1, k ′ )Square Covering problem for PL (m + 1). Clearly, PL (m + 1) is a superset of PL (m), as it contains one more point pm+1 . Since k ′ is fixed, the square B1∗ has k ′ outliers in PL (m+1). If the interior of B1∗ intersects the vertical line ℓ through pm , we translate B1∗ horizontally to the left until it stops intersecting ℓ. Let B be the translated copy of B1∗ , then B lies in the left halfplane of ℓ and there are at most k ′ outliers admitted by B among the points in PL (m). Therefore we can shrink or translate B and get a square lying in the left halfplane of ℓ that has exactly k ′ outliers and a size smaller or equal to that of B1∗ . This implies that the optimal square for PL (m) has a size smaller or equal to that of B1∗ . ⊓ ⊔ Lemma 6 immediately implies the following corollary. Corollary 2. Let (B1 , B2 ) be the solution of the (2, k)-Square Covering problem with a separating line ℓ with index m, and let k ′ be the number of outliers in the left halfplane of ℓ. Then, it holds for the optimal separating line ℓ∗ with index m∗ that m∗ ≤ m if the left square B1 is larger than the right square B2 , and m∗ ≥ m otherwise.

Square and Rectangle Covering with Outliers

137

To solve the (2, k)-Square Covering problem, we start with the vertical line ℓ at the median of the x-coordinates of all points in P . For a given m, we first compute the sets E(PL (m)) and E(PR (m)). Then we use these sets in the call to the (1, k ′ )-Square Covering problem for PL (m) and the (1, k − k ′ )Square Covering problem for PR (m), respectively, and solve the subproblems independently. The solutions of these subsets give the first candidate for the solution of the (2, k)-Square Covering problem, and we now compare the areas of the two obtained squares. According to Corollary 2, the optimal index m∗ ≤ m if the left square has larger area, and m∗ ≥ m otherwise (see Fig. 1). This way, we can use binary search to find the optimal index m∗ for the given k ′ . As the value of k ′ that will lead to the overall optimal solution is unknown, we need to do this for every possible k ′ . Finally, we also need to examine horizontal separating lines ℓ by reversing the roles of x- and y-coordinates. Theorem 3. For a set P of n points in the plane, we can solve the (2, k)Square Covering problem in O(n log n + k 2 log2 k) expected time using O(n) space. √ Proof. If k 4 ≤ n we have k 2 log2 n ≤ n log2 n ∈ O(n) and thus O(n log n + k 2 log2 n) = O(n log n). Otherwise, if k 4 > n we have log n < log k 4 ∈ O(log k), therefore O(n log n + k 2 log2 n) = O(n log n + k 2 log2 k). In both cases we can bound the running time of the algorithm by O(n log n+ k 2 log2 k) expected time. ⊓ ⊔ 2.3

(3, k)-Square Covering

The above solution for the (2, k)-Square Covering problem suggests a recursive approach for the general (p, k)-Square Covering case: Find an axisparallel line that separates one square from the others and recursively solve the induced subproblems. We can do this for p = 3, as Observation 1 can be easily generalized as follows. Observation 2. For any three pairwise disjoint axis-aligned squares in the plane, there always exists an axis-parallel line ℓ that separates one square from the others. Again we assume that the separating line ℓ is vertical and that the left halfplane only contains one square. Since Corollary 2 can be generalized to (3, k)-Square Covering, we solve this case as before: fix the amount of outliers permitted on the left halfplane to k ′ and iterate k ′ from 1 to k to obtain the optimal k ∗ . For each possible k ′ , we recursively solve the two subproblems and use it to obtain the optimal index m∗ such that the area of the largest square is minimized. Preprocessing consists of sorting the points of S in both x- and y-coordinates and computing the segment dragging query structure, which can be done in O(n log n) time. Each (2, k −k ′ )-Square Covering algorithm is executed as described above, except that preprocessing in the recursive steps is no longer needed: The segment dragging queries can be performed since the preprocessing has been done in the

138

H.-K. Ahn et al.

higher level. Also, for the binary search, we can use the sorted list of all points in P , which is a superset of PR (m). This algorithm has a total time complexity of O(n log n + k 3 log3 n) = O(n log n + k 3 log3 k) as before (by distinguishing k 6 ≤ n from k 6 > n). Theorem 4. For a set P of n points in the plane, we can solve the (3, k)Square Covering problem in O(n log n + k 3 log3 k) expected time using O(n) space.

3

Rectangle Covering

We now look at the (p, k)-Rectangle Covering problem, where the boxes are pairwise disjoint rectangles. Again, we only look at the case when p ≤ 3, and Lemma 3 as well as Observations 1 and 2 can be easily extended to rectangles. With this, it is easy to see that we can use the same approach to solve the (p, k)-Rectangle Covering problem as for the (p, k)-Square Covering problem when p ≤ 3. However, since Theorem 1 only applies to (1, k)-Square Covering, once we have computed the set of (k + 1)-extreme points, the best we can do is to test all rectangles that cover exactly n − k points. Our approach is brute force: We store the points of E(P ) separately in four sorted lists, the top k + 1 points in T (P ), the bottom k + 1 points in B(P ), and the left and right k + 1 points in L(P ), and R(P ), respectively. Note that some points may belong to more than one set. We first create a vertical slab by drawing two vertical lines through one point of L(P ) and R(P ) each. All k ′ points outside this slab are obviously outliers, which leads to k − k ′ outliers that are still permitted inside the slab. We now choose two horizontal lines through points in T (P ) and B(P ) that lie inside the slab, such that the rectangle that is formed by all four lines admits exactly k outliers. It is easy to see that whenever the top line is moved downwards, also the bottom line must move downwards, as we need to maintain the correct number of outliers throughout. Inside each of the O(k 2 ) vertical slabs, there are at most k horizontal line pairs we need to examine, hence we can find the smallest rectangle covering n − k points in O(k 3 ) time when the sorted lists of E(P ) are given. This preprocessing takes O(n + k log k) time. Note that this approach leads to the same running time we would get by simply bootstrapping any other existing rectangle covering algorithms [1,14] to the set E(P ), which has independently been done in [3]. Note further that for the case of squares, it is possible to reduce the number of vertical slabs that need to be examined to O(k) only, which would lead to a total running time of O(n + k 2 ). The (p, k)-Rectangle Covering problem for p = 2, 3 can be solved with the same recursive approach as the according (p, k)-Square Covering problem, and we get the main theorem of this section:

Square and Rectangle Covering with Outliers

139

Theorem 5. Given a set P of n points in the plane, we can solve the (1, k)Rectangle Covering problem in O(n + k 3 ) time, the (2, k)-Rectangle Covering problem in O(n log n + k 4 log k) time, and the (3, k)-Rectangle Covering problem in O(n log n+k 5 log2 k) time. In all cases we use O(n) space.

4

Concluding Remarks

In this paper we have extended the well examined axis-aligned box covering problem to allow for k outliers. The base case of our algorithms uses the randomized technique of Chan [5], and thus our algorithms are randomized as well. Chan [5] mentions a deterministic version of his algorithm, which runs in O(n log2 n) time. Our algorithms,however, can be transformed into deterministic ones which adds an O(log k) factor to the second term of the running times. Our algorithms can be generalized to higher dimensions where the partitioning line becomes a hyperplane. However, there is a simple example showing that the (3, k)-Box Covering problem has no partitioning hyperplane for d > 2, hence our algorithm can only be used for p = 1, 2 in higher dimensions. Our idea does not directly extend to the case p ≥ 4, as Observation 1 does not hold for the general case. Although no splitting line may exist, we can show that there always exists a quadrant containing a single box. This property again makes it possible to use recursion to solve any (p, k)-Box Covering problem. Unfortunately, we could not find any monotonicity property that would lead to an efficient search on the O(n2 ) possible splitting quadrants. A natural extension of our algorithm is to make it work for arbitrarily oriented boxes or to allow the boxes to overlap. Both appears to be difficult, as we make use of the set of (k + 1)-extreme points, which is hard to maintain under rotations; also we cannot restrict our attention to only these points when considering overlapping boxes. Acknowledgements. We thank Otfried Cheong, Joachim Gudmundsson, Stefan Langerman, and Marc Pouget for fruitful discussions on early versions of this paper, and Jean Cardinal for indicating useful references.

References 1. Aggarwal, A., Imai, H., Katoh, N., Suri, S.: Finding k points with minimum diameter and related problems. J. Algorithms 12, 38–56 (1991) 2. Ahn, H.-K., Bae, S.W.: Covering a point set by two disjoint rectangles. In: Hong, S.-H., Nagamochi, H., Fukunaga, T. (eds.) ISAAC 2008. LNCS, vol. 5369, pp. 728–739. Springer, Heidelberg (2008) 3. Atanassov, R., Bose, P., Couture, M., Maheshwari, A., Morin, P., Paquette, M., Smid, M., Wuhrer, S.: Algorithms for optimal outlier removal. J. Discrete Alg. (to appear) 4. Bespamyatnikh, S., Segal, M.: Covering a set of points by two axis–parallel boxes. Inform. Proc. Lett, 95–100 (2000)

140

H.-K. Ahn et al.

5. Chan, T.M.: Geometric applications of a randomized optimization technique. Discrete Comput. Geom. 22(4), 547–567 (1999) 6. Chazelle, B.: An algorithm for segment-dragging and its implementation. Algorithmica 3, 205–221 (1988) 7. Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 2nd edn. MIT Press, Cambridge (2001) 8. Das, S., Goswamib, P.P., Nandy, S.C.: Smallest k-point enclosing rectangle and square of arbitrary orientation. Inform. Proc. Lett. 94(6), 259–266 (2005) 9. Jaromczyk, J.W., Kowaluk, M.: Orientation independent covering of point sets in R2 with pairs of rectangles or optimal squares. In: Abstracts 12th European Workshop Comput. Geom., pp. 77–84. Universit¨ at M¨ unster (1996) 10. Katz, M.J., Kedem, K., Segal, M.: Discrete rectilinear 2-center problems. Comput. Geom. Theory Appl. 15, 203–214 (2000) 11. Matouˇsek, J., Welzl, E., Sharir, M.: A subexponential bound for linear programming and related problems. Algorithmica 16, 365–384 (1996) 12. Saha, C., Das, S.: Covering a set of points in a plane using two parallel rectangles. In: ICCTA 2007: Proceedings of the International Conference on Computing: Theory and Applications, pp. 214–218 (2007) 13. Segal, M.: Lower bounds for covering problems. Journal of Mathematical Modelling and Algorithms 1, 17–29 (2002) 14. Segal, M., Kedem, K.: Enclosing k points in the smallest axis parallel rectangle. Inform. Process. Lett. 65, 95–99 (1998) 15. Sharir, M., Welzl, E.: Rectilinear and polygonal p-piercing and p-center problems. In: Proc. 12th Annu. ACM Sympos. Comput. Geom, pp. 122–132 (1996)

Processing an Offline Insertion-Query Sequence with Applications⋆ Danny Z. Chen and Haitao Wang Department of Computer Science and Engineering University of Notre Dame, Notre Dame, IN 46556, USA {dchen,hwang6}@nd.edu

Abstract. In this paper, we present techniques and algorithms for processing an offline sequence of insertion and query operations and for related problems. Most problems we consider are solved optimally in linear time by our algorithms, which are based on a new geometric modeling and interesting techniques. We also discuss some applications to which our algorithms and techniques can be applied to yield efficient solutions.

1

Introduction

Processing a sequence of update-query operations is a fundamental problem both in theory and in applications. In this paper, we focus on the problem version of processing an offline sequence of insertion and query operations or deletion and query operations (i.e., the sequence contains only one type of update operations, either insertion or deletion, but not both). We develop efficient algorithms for this problem and other related problems. Most problems we consider are solved optimally in linear time. Some applications of our techniques are also presented. 1.1

Statements of Problems

Let S = {a1 , a2 , . . . , an } be a set of sorted numbers, with a1 ≤ a2 ≤ · · · ≤ an , that are contained in an interval [L, R] (possibly unbounded), i.e., each ai ∈ [L, R]. Since S is given sorted, we assume that each ai knows its index i in S. For ease of presentation, let a0 = L and an+1 = R. The min-gap (resp., max-gap) of S is defined as min1≤i≤n+1 {ai − ai−1 } (resp., max1≤i≤n+1 {ai − ai−1 }). The dynamic min-gap problem, denoted by Min-G-Op, is defined as follows. Let S0 be some initial set such that {L, R} ⊆ S0 ⊆ (S ∪ {L, R}). For a sequence of update operations op1 , op2 , . . . , opn , suppose opj produces a set Sj from Sj−1 by inserting into or deleting from Sj−1 a number ai ∈ S. Then Min-G-Op reports the min-gap value in every Sj . In this paper, the operations op1 , op2 , . . . , opn are either all insertions or all deletions. Further, we assume that each number ai ∈ S is involved in the operation sequence precisely one time (e.g., each ai is inserted exactly once). Thus, for an insertions-only (resp., deletions-only) sequence, S0 = {L, R} (resp., S0 = S ∪ {L, R}). ⋆

This research was supported in part by NSF under Grant CCF-0515203.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 141–152, 2009. c Springer-Verlag Berlin Heidelberg 2009 

142

D.Z. Chen and H. Wang

Depending on whether the operations are insertions only or deletions only and min-gap or max-gap, we have four problem versions: Min-G-Ins, Max-G-Ins, Min-G-Del, and Max-G-Del (all defined similarly). In addition to the update operations, we also allow the offline sequence to contain queries. For a set S ′ of numbers and a value x (x may or may not be in S ′ ), we define the predecessor (resp., successor) of x in S ′ as the largest (resp., smallest) number in S ′ that is no bigger (resp., no smaller) than x, denoted by pre(S ′ , x) (resp., suc(S ′ , x)). For example, for S ′ = {1, 5, 8, 9}, then pre(S ′ , 7) = 5, suc(S ′ , 7) = 8, and pre(S ′ , 8) = suc(S ′ , 8) = 8. Suppose the offline operation sequence is a mix of m = O(n) query operations q1 , q2 , . . . , qm and n update operations opj . For a query qi with a query value x, let Sj be the set produced by all update operations preceding qi in the sequence (Sj contains {L, R}). Then query qi reports the predecessor and successor of x in Sj , i.e., pre(Sj , x) and suc(Sj , x). Like the values ai ∈ S, we also assume that all query values are in [L, R] and are given offline in sorted order. If the update operations are insertions-only (resp., deletions-only), we refer to the problem as Ins-Query (resp., Del-Query). 1.2

Related Work and Our Contributions

The computation of the max-gap in an arbitrary set (i.e., not sorted) of n numbers has a lower bound of Ω(n log n) time [5,14,15]. The general (online) dynamic min-gap or max-gap problem, with arbitrary update and query operations, is well-studied (e.g., see [8]), and can be easily solved in O(n log n) time using a balanced binary search tree, where n is the number of operations in the sequence. If the values involved are all from a fixed universal set U with |U | = m, then the general (online) dynamic min-gap or max-gap problem can be solved in O(n log log m) time using the integer data structures [17,18]. For the specific versions of the problem that we consider in this paper, that is, the operation sequence is offline, the operations are insertions only or deletions only, and all values (i.e., both the update and query values) involved are already given in sorted order (or are integers in a range of size O(n)), we are not aware of any previous work. Of course, in all these versions, one can easily transform the values involved into a fixed universal set S with n = |S|; then by applying the integer data structures [17,18], these problems can be solved in O(n log log n) time for any offline sequence of O(n) operations. It should be pointed out that these problem versions, although quite special, find many applications nevertheless, some of which will be discussed in this paper. A somewhat related problem is the offline MIN problem considered in [4]. Suppose an offline sequence of insertion and extract-min operations is given, such that each insertion puts an integer i into a set S (initially, S = ∅) for some i ∈ {1, 2, . . . , n}, and each extract-min finds the minimum value in S and removes it from S; further, every integer in {1, 2, . . . , n} is used by at most one insertion operation. The goal is to report the sequence of integers obtained by all the extract-min operations. By reducing it to performing a sequence of unionfind operations [16], this problem can be solved in O(nα(n)) time [4], where α(n)

Processing an Offline Insertion-Query Sequence with Applications

143

is the inverse Ackerman’s function. However, as discussed in the following, the techniques and algorithms for our problems in this paper are quite different and are probably more general, and may find different applications. In this paper, by using an interesting geometric model, we solve Min-G-Ins in O(n) time. With the same geometric model, the Max-G-Ins, Min-G-Del, and Max-G-Del problems can all be solved in O(n) time. By extending the geometric model and using the special linear time union-find data structure in [11], the problem Ins-Query is solved in O(n) time. So is Del-Query. Our techniques and algorithms can also be applied to solve other problems, such as the ray shooting problem. The ray shooting problem has been studied extensively [1,2,3,6,9,13]. We consider a special case, called horizontal ray shooting. Suppose n vertical line segments and O(n) points are given in the plane, such that the vertical segments are sorted by the x-coordinate, and their end points are sorted by the y-coordinate; also, the points are sorted in two lists by the xcoordinate and y-coordinate, respectively. For each point, we shoot a horizontal ray to its left. The objective is to report the first segment hit by the ray from each point. Note that this horizontal ray shooting problem has its own applications. For example, consider the following case of the planar point location problem [10]. Given in the plane a rectilinear subdivision such that the x-coordinates and y-coordinates of its vertices are all integers in a range of size O(n), and a set of O(n) query points whose x-coordinates and y-coordinates are also integers in the same range of size O(n), the goal is to find, for each query point, the face of the subdivision that contains the query point. It is easy to see that this planar point location problem can be reduced to the horizontal ray shooting problem. A sweeping algorithm with the integer data structure can solve this problem in O(n log log n) time. However, by using our geometric model and an interval tree data structure [10], we solve the problem in O(n log k) time, where k is the number of cliques used in the minimum clique partition of the corresponding interval graph for the input vertical segments [7]. Thus, this is a better solution than O(n log log n) time one when log k = o(log log n). Theoretically, our techniques and algorithms exploit a connection between this horizontal ray shooting problem and the minimum clique partition of a corresponding interval graph, which might be interesting in its own right. In the shortest covering arc problem, given a circle and an offline sequence of point insertions, each of which inserts a point on the circle, the goal is to find a shortest arc covering all the inserted points on the circle after each insertion. With a transformation, the shortest covering arc problem can be solved in linear time by modifying our algorithm for the Max-G-Ins problem. Clearly, for the cases of the problems in which the values involved are all integers in a range of size O(n), our algorithms also run in the same time bounds. In such cases, the values involved need not be given sorted, since one can sort them in O(n) time by using bucket sort [8]. The rest of the paper is organized as follows. The problems Min-G-Ins, MaxG-Ins, Min-G-Del, and Max-G-Del are studied in Section 2. The

144

D.Z. Chen and H. Wang

algorithms for the problems Ins-Query and Del-Query are given in Section 3. The applications are discussed in Section 4.

2

Algorithms for Non-query Problem Versions

In this section, we study the Min-G-Ins problem and its three variations MaxG-Ins, Min-G-Del, and Max-G-Del. All these problems can be solved in O(n log log n) time by using the integer data structures [17,18]. Here, we present more efficient linear time algorithms for all these problems. In the following, we first give the geometric modeling and the algorithm for Min-G-Ins, and then solve the other three problems with the same approach. 2.1

Geometric Modeling and Algorithm for Min-G-Ins

In the following, we first give the algorithm Algo-Min-G-Ins for the problem Min-G-Ins, and then show its correctness. Let δj denote the min-gap value of Sj after the j-th insertion in the insertion sequence. Our task is to compute δj for each 1 ≤ j ≤ n. Suppose we have two functions f and g such that ai is inserted by the f (i)-th insertion and the j-th insertion is performed on ag(j) . Since the insertion sequence is given offline, we can compute in advance the two functions f and g in O(n) time. The algorithm Algo-Min-G-Ins works as follows. (1) Let f (0) = f (n + 1) = 0. For each ai with 0 ≤ i ≤ n + 1, create a point pi = (ai , f (i)) in the plane with ai as the x-coordinate and f (i) as the y-coordinate. Denote the point set thus obtained by P (in Fig. 1(a), the two points p0 and pn+1 are not shown). (2) For each pi ∈ P , create a vertical line segment si by connecting pi to the horizontal line y = n + 1, and let bi be the length of the segment si , i.e., bi = n + 1 − f (i) (see Fig. 1(a)). (3) Note that b0 = bn+1 = n+1, which is larger than any other bi with 1 ≤ i ≤ n. In the sequence b0 , b1 , . . . , bn+1 , for each bi with 1 ≤ i ≤ n, compute li = max{t | t < i and bt > bi }. For example, in Fig. 1(a), l5 = 3 and l2 = 1. Note that for each pi with 1 ≤ i ≤ n, if we shoot a horizontal ray from pi to its left, then the segment defined by the point pli is the first one hit by this ray. Likewise, compute ri = min{t | t > i and bt > bi }. The details of computing li and ri will be given later. (4) For each i with 1 ≤ i ≤ n, compute ci = min{ai −ali , ari −ai }. (5) Let δ1 = cg(1) . Scan the sequence cg(1) , cg(2) , . . . , cg(n) , and for each 2 ≤ j ≤ n, compute δj = min{δj−1 , cg(j) }. The correctness of the algorithm is established by the following lemma. For simplicity, in the remaining part of the paper, for any two points pi = (xi , yi ) and pj = (xj , yj ), we say that pi is below or lower than (resp., above or higher than) pj if yi < yj (resp., yi > yj ); similarly, we say pi is to the left (resp., right) of pj if xi < xj (resp., xi > xj ). Lemma 1. The algorithm Algo-Min-G-Ins solves the Min-G-Ins problem correctly. Proof. We prove the lemma by induction. We use δj′ to denote the real min-gap in Sj (i.e., in the resulting set after the j-th insertion) and δj to denote the

Processing an Offline Insertion-Query Sequence with Applications

y

y=n+1 y

y=n+m+1 (x2, 6)

(a4, 6) (a5, 5)

(a2, 4) (a1, 2)

(x1, 4)

(a6, 3) (a3, 1) (a)

x

145

(a1, 2)

L’

(a3, 5) (a4, 3) (a2, 1)

x

(b)

Fig. 1. (a) Illustrating the geometric modeling for Algo-Min-G-Ins: S = {a1 , a2 , a3 , a4 , a5 , a6 } and the insertion sequence is a3 , a1 , a6 , a2 , a5 , a4 . (b) Illustrating the geometric modeling for Algo-Ins-Query: S = {a1 , a2 , a3 , a4 } and X = {x1 , x2 }; the mixed operation sequence is a2 , a1 , a4 , x1 , a3 , x2 . The horizontal line L′ is the sweeping line going downwards.

min-gap in Sj obtained by Algo-Min-G-Ins (i.e., in Step (5)). The objective is to show δj = δj′ for each 1 ≤ j ≤ n. Initially, when j = 1, it must be δ1′ = min{ag(1) − L, R − ag(1) } since S1 has only one number, ag(1) . In AlgoMin-G-Ins, according to the geometric modeling, the point pg(1) is the lowest point in P \ {p0 , pn+1 }, or in other words, bg(1) > bi for any 1 ≤ i ≤ n and i = g(1). Since b0 = bn+1 = n + 1 > bi for any 1 ≤ i ≤ n, we have lg(1) = 0 and rg(1) = n + 1. Thus δ1 = cg(1) = min{ag(1) − L, R − ag(1) } = δ1′ . ′ Assume that δj−1 = δj−1 holds for all j > 1. In the j-th insertion, the number ag(j) is inserted into Sj−1 , resulting in Sj . The insertion of ag(j) breaks the gap ar −al in Sj−1 into two new smaller gaps in Sj : ag(j) −al and ar −ag(j) , where al = ′ pre(Sj−1 , ag(j) ) and ar = suc(Sj−1 , ag(j) ). Thus we have δj′ = min{δj−1 , ag(j) − al , ar −ag(j) }. In Algo-Min-G-Ins, we have δj = min{δj−1 , cg(j) }, where cg(j) = ′ = δj−1 , min{ag(j) − alg(j) , arg(j) − ag(j) }. Due to the induction hypothesis of δj−1 ′ to prove δj = δj , it suffices to show l = lg(j) and r = rg(j) . Note that in the geometric modeling of Algo-Min-G-Ins, ai is inserted earlier than ag(j) (i.e., ai is in Sj−1 ) if and only if pi is lower than pg(j) (e.g., see Fig. 1(a)). In other words, ai is in Sj−1 if and only if bi is larger than bg(j) . Since al = pre(Sj−1 , ag(j) ), bl is the rightmost number larger than bg(j) in the sub-sequence b0 , . . . , bg(j)−1 . Thus we have l = lg(j) . Similarly, we can prove r = rg(j) . The lemma then follows. ⊓ ⊔ We now analyze the running time of Algo-Min-G-Ins. Steps (1) and (2) can be performed easily in O(n) time. For Step (3), an efficient procedure for computing all li ’s is as follows. We scan the sequence of bi ’s from b0 to bn , using a stack S to keep track of some of the bi ’s as needed. Initially, S contains b0 . During the scanning, suppose bi is encountered, i = 1, 2, . . . , n. If bi is larger than the value on the top of S, then pop this value out of S; this popping process continues until the top value bz of S is larger than bi (this always happens at some bz since b0 > bi for all i = 1, 2, . . . , n). Then let li = z and push bi onto S. Note that at any time during the scanning, all numbers in S must be in increasing order from the top to the bottom. t is easy to see that the scanning procedure takes linear time. Similarly, all ri ’s can be obtained by a reverse order of scanning. Steps (4) and (5) also take O(n) time.

146

D.Z. Chen and H. Wang

Theorem 1. The Min-G-Ins problem is solvable in O(n) time. 2.2

Algorithms for Min-G-Del, Max-G-Ins, and Max-G-Del

To solve the Min-G-Del problem, we reduce it to Min-G-Ins in O(n) time, as follows. Let S = {a1 , . . . , an }, with a1 ≤ · · · ≤ an , in an interval [L, R] such that each ai knows its index in S; let S0 = S ∪ {L, R} initially for Min-GDel. Suppose the j-th deletion is performed on ag(j) . Denote by δj the mingap value of Sj after the j-th deletion. Our task is to compute δj for each 1 ≤ j ≤ n. We create a problem instance of Min-G-Ins as follows. Let Sˆ = S. Each operation opj inserts the number ag(n+1−j) to Sˆj−1 , resulting in a new set Sˆj , with Sˆ0 = {L, R} initially. Denote by δˆj the min-gap of Sˆj after the j-th insertion. We claim Sj = Sˆn−j . Note that Sj = {L, R} ∪ S \ ∪jt=1 {ag(t) } n−j {ag(n+1−t) } ∪ Sˆ0 . Since S \ ∪jt=1 {ag(t) } = ∪nt=j+1 {ag(t) } = and Sˆn−j = ∪t=1 n−j ∪t=1 {ag(n+1−t) }, we have Sj = Sˆn−j . This implies δj = δˆn−j . Therefore, after we solve the problem instance of Min-G-Ins, the original problem Min-G-Del can be solved immediately. Thus, Min-G-Del is solvable in linear time. For the Max-G-Ins problem, denote by δj the max-gap value of Sj after the j-th insertion. Our task is to compute δj for each 1 ≤ j ≤ n. Again, suppose ai is inserted by the f (i)-th insertion and the j-th insertion is performed on ag(j) . The algorithm works as follows. Its first three steps are the same as in Algo-Min-G-Ins, followed by three different steps below. Step (4): For each 1 ≤ i ≤ n, compute ci = ari − ali . Step (5): Compute δn = maxni=0 (ai+1 − ai ). Step (6): Scan cg(n) , cg(n−1) , . . . , cg(1) , and for each j = n, n − 1, . . . , 2, compute δj−1 = max{δj , cg(j) }. The running time of the above algorithm is linear. Similar to the min-gap case, we can also reduce Max-G-Del to Max-G-Ins in linear time, and consequently solve the Max-G-Del problem in linear time.

3

Handling Queries

In this section, we tackle the problems on offline sequences with queries, i.e., Ins-Query and Del-Query. Again, by applying the integer data structures [17,18], both these problems can be solved in O(n log log n) time. We present more efficient linear time solutions for them. In the following, we first give the geometric modeling and the algorithm for Ins-Query. Suppose we are given (1) a set S = {a1 , . . . , an } of n insertion values, with a1 ≤ · · · ≤ an , in an interval [L, R], (2) a set X = {x1 , . . . , xm } of m query values, with x1 ≤ · · · ≤ xm , in [L, R], and (3) an offline sequence of n + m (m = O(n)) operations op ˆ 1 , op ˆ 2 , . . . , op ˆ n+m , such that each op ˆ j is either an insertion or a query and there are totally n insertions. For each operation op ˆ j , let Si be the set produced by all insertions preceding op ˆ j in the operation sequence. If op ˆ j is an insertion, then it inserts a value in S \ Si into Si , resulting in a new set Si+1 , ˆ j is a query with a value x ∈ X, then we report with S0 = {L, R} initially. If op αl (x) = pre(Si , x) and αr (x) = suc(Si , x). Note that S ∩ X may or may not be an empty set.

Processing an Offline Insertion-Query Sequence with Applications

147

Comparing to the Min-G-Ins problem, we have a query set X in Ins-Query. We first show that the geometric model for Min-G-Ins does not immediately work for Ins-Query. Suppose we apply exactly the same geometric model for Min-G-Ins to Ins-Query, i.e., we also create a vertical line segment for each value in X. We call a segment corresponding to a value in S (resp., X) a data (resp., query) segment. Consider a query with a value x performed on a set Si for finding the value pre(Si , x). It is not difficult to see that if we shoot a horizontal ray from the corresponding query point pˆ(x) to its left, then pre(Si , x) is the x-coordinate of the first data segment hit by this ray. However, the first segment (among all data and query segments) hit by the ray can be a query segment, implying that the algorithm for Min-G-Ins does not work for InsQuery. Thus, we cannot create query segments in the geometric modeling, since that makes the linear time ray shooting procedure in Algo-Min-G-Ins (i.e., Step (3)) fail. Hence, the key lies at the ray shooting for Ins-Query. Actually, to solve Ins-Query, we need to generalize the geometric model for Min-G-Ins. In the following algorithm, for simplicity, we first assume S ∩ X = ∅. We will remove this restriction later. The algorithm Algo-Ins-Query works as follows. (1) For each operation op ˆj with 1 ≤ j ≤ n + m, if it is an insertion to insert an ai ∈ S, we create a data point pi = (ai , j) with ai as the x-coordinate and j as the y-coordinate; otherwise, it is a query with a query value xi ∈ X, and we create a query point pˆi = (xi , j). Let a0 = L and an+1 = R. We also create two points p0 = (a0 , 0) and pn+1 = (an+1 , 0). Figure 1(b) shows an example in which p0 and pn+1 are not shown. Let P = {p0 , p1 , . . . , pn+1 } and Pˆ = {p1 , . . . , pm }. (2) For each data point pi ∈ P , create a vertical line segment si by connecting pi to the horizontal line y = n + m + 1 and let bi be the length of si (see Figure 1(b)). Denote by LS the set of all n + 2 such vertical segments. (No vertical segments are created for query points.) (3) In the sequence b0 , b1 , . . . , bn+1 , for each bi with 1 ≤ i ≤ n, compute li = max{t | t < i and bt > bi }; likewise, compute ri = min{t | t > i and bt > bi }. (4) This is the ray shooting step (to the left): For each query point pˆi ∈ Pˆ , shoot a horizontal ray hi to its left and find in LS the first segment hit by hi ; we call this segment the hit segment of pˆi and xi . To solve the ray shooting sub-problem in Algo-Ins-Query, our strategy is to use a horizontal line to sweep the plane from top to bottom in which each point in P ∪ Pˆ is an event and the sweeping invariant is a sorted segment subset LS ′ consisting of all segments in LS intersected by the sweeping line. Initially, the sweeping starts at the horizontal line y = n + m + 1, and thus LS ′ = LS. At each event, if it is a data point pi ∈ P , then we remove the segment si from LS ′ since si will no longer intersect the sweeping line in the future; if it is a query point, then we report its hit segment. The sweeping is finished once all query points have been swept. Note that we can easily sort all points in P ∪ Pˆ by decreasing y-coordinate in linear time. The key issue here is that a data structure is needed for maintaining the segment set LS ′ such that both the deletion of a segment and the search of the hit segment for each query point can be handled efficiently. Note that since p0 and pn+1 are the two lowest points in P ∪ Pˆ , their segments

148

D.Z. Chen and H. Wang

s0 and sn+1 remain throughout the sweeping process (and thus s0 and sn+1 are always in LS ′ ). To derive such a data structure, we observe that maintaining the segment set LS ′ is equivalent to maintaining a set of subintervals of [L, R], which can be done in an efficient fashion, as follows. First, build an interval [ai , ai+1 ] for each 0 ≤ i ≤ n, and let ai (resp., ai+1 ) be the left end (resp., right end) of the interval. Let I be the set of these n + 1 intervals. Note that no two distinct intervals in I overlap in their interior and the union of the intervals in I is exactly [a0 , an+1 ] = [L, R]. Since S ∩ X = ∅, for any xi ∈ X, xi ∈ S. We say that xi belongs to an interval [at , at+1 ] ∈ I if at < xi < at+1 . For each xi ∈ X, compute the unique interval I(xi ) in I to which xi belongs. This can be done easily in O(n) time since both S and X are given sorted. We say that two intervals in I are adjacent if the left end of one interval is the right end of the other. For example, [ai−1 , ai ] and [ai , ai+1 ] are adjacent. Note that two adjacent intervals [ai−1 , ai ] and [ai , ai+1 ] can be concatenated into a new larger interval [ai−1 , ai+1 ]. During the sweeping process, an (active) interval set I ′ is maintained that contains the intervals between any two consecutive vertical segments in LS ′ . Initially, I ′ = I. During the sweeping, I ′ will be dynamically updated as adjacent intervals in I ′ are concatenated. Since initially LS ′ = LS, there is a one-to-one mapping between the intervals in I ′ = I and the segments in LS ′ \ {sn+1 }, that is, for each si ∈ LS ′ \ {sn+1 }, there is one and only one interval in I ′ whose left end is ai (i.e., the x-coordinate of si ), and vice versa. We will show below that during the sweeping, for each update of LS ′ , we update I ′ accordingly such that the above mapping always holds. Thus, by maintaining the interval set I ′ , we can maintain LS ′ accordingly (since sn+1 is always in LS ′ , we can ignore it). We maintain the interval set I ′ by a data structure which will be elaborated later. At each event point, if it is a data point pi ∈ P , then we concatenate the interval whose right end is ai with the interval whose left end is ai in I ′ (by updating the data structure for storing I ′ accordingly). It is easy to see that such a concatenation operation in I ′ is equivalent to removing the segment si from LS ′ , and after the interval concatenation, the one-to-one mapping between the new I ′ and the new LS ′ \{sn+1 } still holds. For example, in Figure 1(b), if L′ is the sweeping line at the moment, then the interval set I ′ is {[a0 , a1 ], [a1 , a2 ], [a2 , a4 ], [a4 , a5 ]} and LS ′ \ {sn+1 } is {s0 , s1 , s2 , s4 }; right after L′ sweeping through the next data point (a4 , 3), the two intervals [a2 , a4 ] and [a4 , a5 ] are concatenated into [a2 , a5 ], the new I ′ becomes {[a0 , a1 ], [a1 , a2 ], [a2 , a5 ]}, and the new LS ′ \ {sn+1 } is {s0 , s1 , s2 }. Note that in I ′ , the interval with a right end ai is [ali , ai ] and the interval with a left end ai is [ai , ari ], where both li and ri are obtained in Step (3). If the event point is a query point pˆi ∈ Pˆ , then we find in the current I ′ the interval I(xi ) containing xi , by consulting the data structure storing I ′ . How this is done will be discussed later. Let al be the left end of the interval I(xi ). Then the segment sl is the hit segment of pˆi and we set αl (xi ) = al . For example, in Figure 1(b), when L′ visits the query point (x1 , 4), the interval in I ′ containing x1 is [a1 , a2 ]; hence s1 is the hit segment of x1 and we set αl (x1 ) = a1 .

Processing an Offline Insertion-Query Sequence with Applications

149

As for Step (4) of Algo-Ins-Query, we can handle the sub-problem of horizontal ray shooting to the right: For each query point pˆi ∈ Pˆ , shoot a horizontal ray to its right and find in LS the first segment hit by this ray. Clearly, this sub-problem can be solved in a symmetric way as for Step (4). For each pˆi ∈ Pˆ , let sr be the first segment hit by the ray from pˆi . Then we set αr (xi ) = ar , where ar is the x-coordinate of sr . The only remaining part of Algo-Ins-Query that needs further discussion is the data structure for maintaining the active interval set I ′ in the plane sweeping process. An obvious solution is to use a balanced binary search tree for maintaining I ′ , but that would take O(n log n) time for the plane sweeping. Instead, we resort to the union-find data structure [8]. Initially, there are n + 1 intervals in I. For each xi ∈ X, we know the unique interval I(xi ) in I that contains xi . Thus, we let each interval [ai , ai+1 ] ∈ I form a subset of the elements in X such that all elements of X contained in [ai , ai+1 ] are in this subset. Clearly, the subsets thus defined by the intervals in I together form a partition of X. Further, we let the “name” of each subset (corresponding to an interval in I ′ ) involved in the sweeping process be the left end of that interval (e.g., the name of [ai , ai+1 ] is ai ). Then in the sweeping process, when two intervals are concatenated into one, we perform a “union” operation on their corresponding two subsets. When encountering a query point pˆi , to determine the interval I(xi ) in the current interval set I ′ that contains xi , we apply a “find” operation on I ′ with the value xi , which returns the name of the interval I(xi ) (i.e., its left end, which is exactly what our ray shooting from pˆi seeks). Since the union operations are performed only on the subsets of two adjacent intervals in the current I ′ , each interval in I ′ is a union of consecutive intervals in I. Therefore, the special linear time union-find data structure in [11] can be used for our problem, which takes O(1) amortized time for any union or find operation. The correctness of the algorithm Algo-Ins-Query is established by the lemma below. Lemma 2. The algorithm Algo-Ins-Query solves the Ins-Query problem correctly. Proof. The proof is similar to that of Lemma 1, and we only sketch it here. For a query value xi ∈ X, suppose the query is on the set Sj and sl is the vertical segment obtained in Step (4) for the query point pˆi (whose x-coordinate is xi ). To prove the lemma, it suffices to show that al = pre(Sj , xi ). Since the query xi is on Sj , it is performed after the j-th insertion and before the (j + 1)-th insertion. Thus, a value az is in Sj if and only if its point pz is below the point pˆi . Let at = pre(Sj , xi ). By the geometric modeling, st is the first vertical segment in LS hit by the horizontal ray hi shot from pˆi to its left. We claim that t = l. We prove this by contradiction. If l > t, since the point pl is to the left of pˆi and st is the first segment hit by the ray hi , pl must be higher than pˆi . Thus according to the sweeping algorithm, when pˆi is being visited, the interval whose left end is al would have already been concatenated with its left adjacent interval, implying that sl cannot be returned as the answer for hi , a contradiction. If l < t, then since st is the first segment hit by the ray hi , when pˆi is being visited, the interval with the left end at must be in the current interval

150

D.Z. Chen and H. Wang

set I ′ . Further, since pˆi is to the right of st and pl is to the left of st , xi cannot be contained in the interval with the left end al in the current I ′ , which also incurs a contradiction. Thus the claim follows and we have al = pre(Sj , xi ). We now analyze the running time of Algo-Ins-Query. Clearly, Steps (1), (2), and (3) take linear time. For Step (4), as discussed above, using the special linear time union-find data structure [11], each union or find operation takes O(1) amortized time in our algorithm. Since the sweeping process performs totally n union operations (for the n data points) and m = O(n) find operations (for the m query points), Step (4) can be carried out in O(n) time. To remove the assumption S ∩ X = ∅, we do the following. Suppose xj = ai for some xj ∈ X and ai ∈ S. If a query with the value xj is performed after the insertion of ai , then we can simply report αl (xj ) = αr (xj ) = ai because the set Sz on which the query is performed contains ai . Otherwise, we set I(xj ) to be the interval [ai , ai+1 ] and follow the same sweeping procedure in Step (4). Since both S and X are given in sorted order, with the above modifications, the running time of the algorithm is still linear. We then have the following result. Theorem 2. The Ins-Query problem is solvable in linear time. For the Del-Query problem, similar to the reduction from Min-G-Ins to MinG-Del, it is easy to reduce Del-Query to Ins-Query in linear time. Consequently, the Del-Query problem can be solved in O(n) time.

4

Applications

We discuss two applications to which either our algorithms can be applied directly or some of our techniques can be utilized to derive efficient solutions. A special case ray shooting problem, which we call horizontal ray shooting, is defined as follows. Given (1) a set S of n vertical line segments in the plane that are sorted by the x-coordinate and whose end points are also sorted in another list by the y-coordinate, and (2) a set P of O(n) points in the plane sorted in two lists, one by the x-coordinate and the other by the y-coordinate, we shoot a horizontal ray hi from each point pi ∈ P to its left, and the goal is for each pi , to report the first segment s(pi ) in S hit by the ray hi . By applying our techniques in Section 3 and using other ideas, we have an algorithm which is better than the trivial solution using integer data structure. We sketch our algorithm in the following and the details can be found in the full paper. A clique of the vertical segments in S is defined to be a subset of segments that can be intersected by one horizontal line. We first partition all segments of S into the minimum number of cliques using the linear time algorithm in [7]. Let k denote this minimum number of cliques for S. For each clique Ci , 1 ≤ i ≤ k, suppose li is a horizontal line intersecting all segments in Ci . Then li cuts each segment of Ci into two parts, one above li and the other below li . Denote by Cia (resp., Cib ) the set of the parts of the segments in Ci above (resp., below) li . For Cia , we solve a sub-problem: For each pi ∈ P , find the first segment in

Processing an Offline Insertion-Query Sequence with Applications

151

Cia hit by the horizontal ray shot from the point pi to its left (that is, in this sub-problem, the segments in (S − Ci ) ∪ Cib are all ignored). This sub-problem can be solved in O(n) time by using the ray shooting procedure of the algorithm Algo-Ins-Query in Section 3. Similarly, we can solve the sub-problem on Cib , as well as the sub-problems on other k − 1 cliques. It takes totally O(kn) time to solve these 2k sub-problems. Finally, for each point pi ∈ P , its hit segment s(pi ) is chosen to be the segment closest to pi among the (at most) 2k segments obtained for pi from the 2k sub-problems. In this way, it takes in total O(kn) time to compute the segments s(pi ) for all points pi ∈ P . We can further improve the above algorithm, by using the idea of the interval tree data structure [10], as follows. We first build a complete binary search tree T on all the horizontal lines li (1 ≤ i ≤ k) according to a sorted order of their y-coordinates, such that each node v in T stores exactly one horizontal line l(v) = li for some i ∈ {1, 2, . . . , k}. Since there are k cliques for S, T has k nodes and the height of T is log k. Then in O(n log k) time, we can rearrange the segments of S in these k cliques into k new cliques such that T and the k new cliques together form an interval tree. According to the properties of the interval tree, every point pi ∈ P can be associated with O(log k) cliques in T so that when shooting a horizontal ray hi from any point pi ∈ P , the segment s(pi ) first hit by hi is contained in the O(log k) associated cliques of pi in T and thus the ray shooting of pi needs to be performed only on each of its associated cliques. This can be easily done in O(n log k) time. Consequently, the problem can be solved in totally O(n log k) time. Theorem 3. The horizontal ray shooting problem can be solved in O(n log k) time, where k is the number of cliques for the minimum clique partition of the input segment set S. When log k = o(log log n), our above algorithm is faster than the O(n log log n) time plane sweeping algorithm using the integer data structure [17,18]. Another application is the shortest arc covering problem, which is defined as follows. Given a set P of n points on a circle C whose circular sorted order is already given, and an offline sequence of insertions each of which inserts a point of P onto C, report a shortest circular arc on C that covers all the inserted points of P after every insertion operation. A shortest covering arc can be viewed, for example, as a simple cluster of the inserted points on C. To solve this problem, observe that finding a shortest circular arc on C covering a set S of points is equivalent to finding a longest circular arc on C that does not cover any point in the set S. Thus, the problem can be easily reduced to the Max-G-Ins problem in Section 2 in linear time. The details can be found in the full paper. Theorem 4. The shortest arc covering problem is solvable in linear time.

152

D.Z. Chen and H. Wang

References 1. Agarwal, P.K.: Ray shooting and other applications of spanning trees with low stabbing number. In: Proc. of the 5th Annual Symposium on Computational Geometry, pp. 315–325 (1989) 2. Agarwal, P.K., Matouˇsek, J.: Ray shooting and parametric search. SIAM Journal on Computing 22(4), 794–806 (1993) 3. Agarwal, P.K., Sharir, M.: Applications of a new partitioning scheme. In: Proc. of the 2nd Workshop on Algorithms and Data Structures, pp. 379–392 (1991) 4. Aho, A.V., Hopcroft, J.E., Ullman, J.D.: The Design and Analysis of Computer Algorithms, ch. 4, pp. 139–141. Addison-Wesley, Massachusetts (1974) 5. Arkin, E.M., Hurtado, F., Mitchell, J.S.B., Seara, C., Skiena, S.S.: Some lower bounds on geometric separability problems. International Journal of Computational Geometry and Applications 16(1), 1–26 (2006) 6. Chazelle, B., Guibas, L.: Visibility and intersection problems in plane geometry. Discrete Comput. Geom. 4, 551–589 (1989) 7. Chen, M., Li, J., Li, J., Li, W., Wang, L.: Some approximation algorithms for the clique partition problem in weighted interval graphs. Theoretical Computer Science 381, 124–133 (2007) 8. Cormen, T., Leiserson, C., Rivest, R., Stein, C.: Introduction to Algorithms, 2nd edn. MIT Press, Cambridge (2001) 9. de Berg, M., Halperin, D., Overmars, M., Snoeyink, J., van Kreveld, M.: Efficient ray shooting and hidden surface removal. In: Proc. of the 7th Annual Symposium on Computational Geometry, pp. 21–30 (1991) 10. de Berg, M., van Kreveld, M., Overmars, M., Schwarzkopf, O.: Computational Geometry – Algorithms and Applications, 1st edn. Springer, Berlin (1997) 11. Gabow, H.N., Tarjan, R.E.: A linear-time algorithm for a special case of disjoint set union. Journal of Computer and System Sciences 30, 209–221 (1985) 12. Golumbic, M.C.: Algorithmic Graph Theory and Perfect Graphs. Academic Press, New York (1980) 13. Guibas, L., Hershberger, J., Leven, D., Sharir, M., Tarjan, R.E.: Linear time algorithms for visibility and shortest path problems inside simple polygons. In: Proc. of the 2nd Annual Symposium on Computational Geometry, pp. 1–13 (1986) 14. Lee, D.T., Wu, Y.F.: Geometric complexity of some location problems. Algorithmica 1, 193–211 (1986) 15. Ramanan, P.: Obtaining lower bounds using artificial components. Information Processing Letters 24(4), 243–246 (1987) 16. Tarjan, R.E.: Efficiency of a good but not linear set union algorithm. Journal of the ACM 22(2), 215–225 (1975) 17. van Emde Boas, P.: Preserving order in a forest in less than logarithmic time and linear space. Information Processing Letters 6(3), 80–82 (1977) 18. van Emde Boas, P., Kaas, R., Zijlstra, E.: Design and implementation of an efficient priority queue. Math. Systems Theory 10, 99–127 (1977)

Bounds on the Geometric Mean of Arc Lengths for Bounded-Degree Planar Graphs Mohammad Khairul Hasan, Sung-Eui Yoon, and Kyung-Yong Chwa Division of Computer Science Korea Advanced Institute of Science and Technology (KAIST), Republic of Korea [email protected], [email protected], [email protected]

Abstract. Data access time becomes the main bottleneck in applications dealing with large-scale graphs. Cache-oblivious layouts, constructed to minimize the geometric mean of arc lengths of graphs, have been adapted to reduce data access time during random walks on graphs. In this paper, we present a constant factor approximation algorithm for the Minimum Geometric Mean Layout (MGML) problem for bounded-degree planar graphs. We also derive an upper bound for any layout of the MGML problem. To the best of our knowledge, these are the first results for the MGML problem with bounded-degree planar graphs.

1 Introduction Large-scale graphs are extensively used in variety of applications including data mining, national security, computer graphics, and social network analysis. Advances in data-capturing and modeling technologies have supported the use of large-scale graphs. Massive polygonal models–which are typically bounded degree planar graphs–are easily constructed using various techniques developed in computer-aided design (CAD), scientific simulation, and e-Heritage [1]. Social network analysis is a critical component to understanding various social behaviors, urban planning, and the spread of infectious diseases [2]. With hundreds of millions of nodes, complexity becomes a major challenge in analyzing large-scale graphs. To process large-scale graphs in a timely manner, efficient processing algorithms have utilized the high computational power of CPUs and Graphics Processing Units (GPUs). Over the last few decades, the widening gap between processing speed and data access speed has been a major computing trend. For nearly two decades, the CPU performance has increased at an annual rate of 60%, meanwhile the disk access time has been decreased by an annual rate of 7%-10% [3]. In order to avoid high-latency data accesses, system architectures increasingly utilize caches and memory hierarchies. Memory hierarchies have two main characteristics. First, lower level memory have higher storage capacities and longer data access times. Second, whenever a cache miss occurs, data is transferred in a block containing data between different memory levels. Typically, nodes and arcs of a graph are stored linearly in the memory space. There exists an exponential number of choices for storing nodes and arcs in the one dimensional memory space. An ordering of nodes or arcs within the X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 153–162, 2009. c Springer-Verlag Berlin Heidelberg 2009 

154

M.K. Hasan, S.-E. Yoon, and K.-Y. Chwa

one dimensional memory space is a data layout. Given a block-based caching architecture with slower data access times for lower memory levels, it is critical to store data that are likely to be accessed together very close in the data layout. The geometric mean of arc lengths for a graph has been shown to have a high linear correlation with the number of cache misses occurred while accessing the graph in the data layout [4]. Therefore the geometric mean of arc lengths is a cache-coherent metric. Efficient layout construction algorithms that reduce the geometric mean of input graphs have been used to improve cache performance. The constructed cache-coherent layouts have been demonstrated to show significant performance improvement over other tested layouts. However, it has not been proven that the constructed layouts are optimal in terms of geometric mean. In this paper we investigate an optimal algorithm that minimizes the value of the geometric mean of arc lengths for a class of bounded-degree planar graphs. Problem statement and main results: We start by defining a Minimum Geometric Mean Layout (MGML) problem for a graph. Given a graph, G = (N , A ), where n = |N | and m = |A |, a layout, ϕ : N → [n] = {1, ..., n}, is a one-to-one mapping of nodes to position indices. The geometric mean, GMean, of arc lengths for a layout ϕ of graph G is: GMean =



=2

1

m



(u,v)∈A

1 m

|ϕ (u) − ϕ (v)|

= 2log((∏(u,v)∈A |ϕ (u)−ϕ (v)|)

1 m)

∑(u,v)∈A log(|ϕ (u)−ϕ (v)|)

ϕ ∗ : N → [n] is defined as an optimal layout in terms of the minimum geometric mean of arc lengths. The geometric mean with the optimal layout, GMeanOPT , is similarly defined by replacing ϕ with ϕ ∗ . Throughout this paper we will assume that the “log” function is of base 2. In this paper we propose a layout construction algorithm which, for a bounded degree planar graph, gives a layout with a geometric mean that is at most a constant factor worse than the geometric mean of the optimal layout. To the best of our knowledge, this is the first result in this area. We also show that the geometric mean of arc lengths for an arbitrary layout is O(n), where n is the number of nodes in the graph. We discuss works related to our problem in Sec. 2 followed by a background on computing cache-coherent layouts of graphs in Sec. 3. Our theoretical results are explained in Sec. 4 and we conclude with related open problems in Sec. 5.

2 Related Work In this section, we briefly introduce works related to our graph layout problem. 2.1 Graph Layout Optimization For a graph layout, we can formulate a cost function which indicates how good the layout is. Layout problems with common cost functions have attracted much researcher

Bounds on the Geometric Mean of Arc Lengths

155

attention in recent years. In most cases the problems are NP-complete [5,6,7] for general graphs. The most popular cost functions include arithmetic mean of arc lengths (also known as Minimum Linear Arrangement (MLA) problem), bandwidth, etc. Arithmetic Mean: Minimizing the arithmetic mean or MLA, is NP-complete [5], thus, researchers are interested in approximation algorithms. The first approximation algorithm for MLA was derived by Hansen [8] with a√factor of O(log n)2 . Currently the best known algorithm for MLA [9] has a factor of O( log n log log n). MLA has polynomial algorithms when the input graph is a tree [10] and linear algorithms when the input graph is a rectangular grid [11]. Bandwidth: Another interesting problem related to graph layout is the Bandwidth, where the objective is to minimize the maximum arc length. This problem is NP-Hard for general graphs [6], for trees with maximum degree 3 [12], and for grid and unit disk graphs [13]. This problem has polynomial algorithms for a variety of graph families. More details can be found in a recent survey of graph layout problems [14]. Geometric Mean: The geometric mean of arc lengths for a graph has recently been proposed to measure the cache-coherence of a graph layout in a cache-oblivious case [4]. Geometric mean is strongly correlated to the number of cache misses observed during the random access of the meshes and graphs in various applications. It is assumed that the block sizes encountered at runtime are power-of-two bytes. Then, the expected number of cache misses with those power-of-two bytes cache blocks is computed. More background information on the derivation of geometric mean will be presented in Sec. 3. 2.2 Space-Filling Curves Space-filling curves [15] have been widely used in applications to improve cache utilization. Space-filling curves assist in computing cache-friendly layouts for volumetric grids or height fields. The layouts yield considerable performance improvements in image processing [16] and terrain or volume visualization [17,18]. A standard method of constructing a layout for graph using a space-filling curve is to embed the graph in a geometrically uniform structure that contains the space-filling curve. To embed the graph in such a uniform structure (e.g., grid) geometrically, each node of the graph must contain geometric information. Gotsman and Lindenbaum investigated the spatial locality of space-filling curves [19]. Motivated by searching and sorting applications, Wierum [20] proposed a logarithmic measure resembling the geometric mean of the graph for analyzing space-filling curve layouts of regular grids. Although space-filling curves are considered a good heuristic for designing cachecoherent layouts, their applications are limited to regular geometric data structures like grids, images, or height fields. This is mainly due to the nature of the procedure of embedding onto uniform structures of space-filling curves. A multi-level layout construction method minimizing the geometric mean [1] can be considered as a generalization method of classic space-filling curves to arbitrary graphs.

3 Background on Cache-Coherent Layouts In this section we give background information on computing cache-coherent layouts.

156

M.K. Hasan, S.-E. Yoon, and K.-Y. Chwa

3.1 Block-Based I/O Model Caching schemes are widely used to bridge the widening gap between data processing speed and data access speed. The two main characteristics of modern memory hierarchies are, 1) varying data storage size and data access time between memory levels and 2) the block-based data fetching. Those characteristics are well captured in the two-level I/O-model defined by Aggarwal and Vitter [21]. This model assumes a fast memory called “cache,” consisting of M blocks, and a slower infinite memory. Each cache block is B; therefore the total cache size is M × B. Data is transferred between the different levels in blocks of consecutive elements. 3.2 Cache-Oblivious Layout Computation There have been research efforts to design cache-coherent layouts that reduce the number of cache misses during accessing these graphs and meshes in various applications [4,22,1,23]. Those approaches cast the problem of computing a cache-coherent layout of a graph to an optimization problem of minimizing a cost metric, which measures the expected number of cache misses for the layout during random walks on a graph. Those methods also utilize an input graph representing the anticipated runtime access pattern. Each node of the graph represents a data element and a direct arc (i, j) between two nodes indicates an anticipated access pattern; a node j may be accessed sequentially after a node i. 3.3 Geometric Mean Cache-coherent layouts can be classified into cache-aware and cache-oblivious layouts. Cache-aware layout are constructed by optimizing the expected number of cache misses given a particular cache block size. On the other hand, cache-oblivious layouts are constructed without optimizing at a particular cache block size. Instead, cache-oblivious layouts are constructed by considering all the possible block sizes that may be encountered at runtime. Cache-oblivious layouts can yield significant benefits on architectures that employ various cache block sizes. For the cache-aware layouts, it has been derived that the number of straddling arcs of an input graph in a layout determines the number of observed cache misses during random access at runtime [4]. The expected number of cache misses for a cache-oblivious layout is computed by considering power-of-two bytes block sizes. The result can be derived from that of the cache-aware case. In cache-oblivious layouts, the expected number of cache misses is reduced to the geometric mean of arc lengths of the graph. More importantly, the geometric mean has been demonstrated to have a strong correlation to the numbers of observed cache misses at runtime for various layouts. 3.4 Multi-level Construction Method In order to construct cache-oblivious layouts that optimize the cache-oblivious metric (i.e., the geometric mean) multi-level construction methods have been introduced [4,1]. The idea is to partition an input graph into a small number of subsets while minimizing the number of straddling arcs among partitioned sets.

Bounds on the Geometric Mean of Arc Lengths

157

After partitioning into subsets, orders of partitioned sets are computed while minimizing the geometric mean. This process is recursively performed on each partitioned set until each set has one node. As we partition each set and compute an ordering among the partitioned sets, the global ordering of nodes for the graph is progressively refined. Note that the overall process of multi-level construction methods is similar to that of space-filling curves like Hilbert-curve [15]. This method runs quite fast and produces high-quality cache-oblivious layouts. However, there have been no theoretical approaches investigating the optimality of the resulting layouts.

4 Theoretical Results In this section, we present a constant factor approximation algorithm for the Minimum Geometric Mean Layout (MGML) problem for bounded-degree planar graphs. We also demonstrate that the geometric mean of arc lengths for an arbitrary layout of a planar graph is O(n), where n is the number of nodes of the graph. More formally, our algorithm and its analysis are based on the assumption that the input graph is a n node planar graph whose maximum degree is bounded by a constant k. Graphs satisfying the above assumptions are widely used in the field of computer graphics and are known as meshes. For the sake of clarity, we assume that the input graph is connected and the number of nodes in the input graph is a power of two. We can assume this without loss of generality because dummy nodes and arcs can be added as appropriate to make the total number of nodes a power of two and to make the graph connected. After applying our algorithm on the modified graph we can get the layout of the original graph simply by taking the relative ordering of real nodes from the generated layout without increasing the geometric mean of arc lengths for the original graph. Throughout this paper we use the following notations. G = (N , A ) is our input graph with n = |N | and m = |A |, where n is a power of 2 and m = θ (n). For arbitrary graph G = (N, A) and X ⊆ N, G[X] is the subgraph of G induced by X. Also for a graph G = (N, A) and for any two node sets P ⊆ N and Q ⊆ N, Crossing(P, Q) is the set of arcs Ax ⊆ A each of which has one node in P and another node in Q. For any graph G, N(G) and A(G) are the set of nodes and the set of arcs of the graph respectively. 4.1 Algorithm We use a divide and conquer approach to find a layout ϕ given a graph. We use two algorithms, Partition and MakeLayout. Algorithm Partition takes a planar graph with a maximum degree bounded by a constant k as an input. Using the procedure described in [24] Partition algorithm computes a partition (P, Q) of  nodes of the input graph such that |P| = |Q| and Crossing(P, Q) is bounded by c × k × (|P| + |Q|), where c is a constant. Theorem 1 and Corollary 1 ensure that such a partition can be generated. Theorem 1 ([24]). Let√ G be a planar graph with a maximum degree k. Then there exists a set of arcs of size ≤ 2 2kn such that by removing this arc set one can partition G into two subgraphs each having at most ⌈ 32 × |N(G)|⌉ nodes. Furthermore such an arc set can be found in linear time.

158

M.K. Hasan, S.-E. Yoon, and K.-Y. Chwa

Corollary 1 ([24]). For any G with a maximum degree k there exists an √ √ planar √ graph arc set R with size ≤ (6 2 + 4 3) kn whose removal divides the nodes of G into two sets of P and Q such that |P| ≤ ⌈|N(G)|/2⌉, |Q| ≤ ⌈|N(G)|/2⌉, and the arc set connecting P and Q belongs to R. Corollary 1 is based on both Theorem 1 and the divide-and-conquer partitioning method described in [25]. Assuming that n is a power of two, a n-node planar graph G with maximum degree bounded can √ be partitioned into two subgraphs with equal √ by k √ nodes by removing at most (6 2 + 4 3) kn arcs in O(n log n) time. The MakeLayout algorithm takes an input graph and two indices indicating the beginning and ending positions of the layout. Generating the layout for the entire input graph involves an initial call to MakeLayout(G , 1, n): other calls are made recursively. The algorithm first starts by checking if the input graph contains only one node. If so, it constructs a layout consisting of that node. Otherwise it splits the graph into two parts using the Partition algorithm. We recurse this process until a graph consisting of only one node is reached. Algorithm Partition (G) 01 Input: A bounded degree planar graph G 02 Output: A partition (P, Q) of N(G) 03 Begin 04 Find a partition (P, Q) of N(G) such that: 05 1. |P| = |Q|  06 2. |Crossing(P, Q)| ≤ c × (k × |N(G)|) 07 return (P, Q) 08 End. Algorithm MakeLayout (G, i, j) 01 Input: A bounded degree planar graph G 02 Initial and end positions, i and j, of any layout 03 Output: A layout of G 04 Begin 05 If |N(G)| = 1 then 06 Let u be the only node of G 07 Set ϕ (u) = i 08 Else, 09 Let (P, Q) be the partition of N(G) found using Partition(G) 10 MakeLayout(G[P], i, i + ( j−i+1 2 ) − 1) j−i+1 11 MakeLayout(G[Q], i + ( 2 ), j) 12 End. 4.2 Analysis First, we will show that the geometric mean of arc lengths for a layout generated by the MakeLayout algorithm is O(1). Because the number, n, of nodes in the input graph is a power of two, it is easy to see that the overall recursion tree of the MakeLayout algorithm is a complete binary tree

Bounds on the Geometric Mean of Arc Lengths

159

with n leaves and exactly log n levels. Additionally, level l of this tree contains exactly 2l nodes, i.e., 2l calls to MakeLayout. Each non-leaf node of the binary tree splits a graph into two subgraphs with equal nodes by removing crossing arcs between those two subgraphs. Let Al be the set of arcs removed by all nodes of level l of the recursion tree and Costl = ∑(u,v)∈Al log(|ϕ (u) − ϕ (v)|). The following two lemmas give an upper bound for Costl on each level l. Lemma 1. For each call of the algorithm MakeLayout(G, i, j), j − i is equal to |N(G)| − 1. Proof. We will prove this lemma by induction on the level of recursion. At level 0 the algorithm is called with G as G = (N , A ), with i and j as 1 and n respectively. Since |N | = n the lemma is true for the level 0 call. Suppose the lemma is true for any call at a level p. Consider a level p execution of the algorithm MakeLayout(G, i, j). If |N(G)| > 1, this execution will make two level p+1 executions MakeLayout(G[P], i, i+( j−i+1 2 )−1) and MakeLayout(G[Q], i+ ), j) in line 10 and 11 in the algorithm MakeLayout respectively. Let G0 = ( j−i+1 2 j−i+1 G[P], i0 = i, j0 = i + ( 2 ) − 1 and G1 = G[Q], i1 = i + ( j−i+1 2 ), (|N(G)|−1)+1 − 1 = − 1 = |N(G)|/2 − 1 = |P| − 1 = |N(G j1 = j. Then j0 − i0 = j−i+1 0 )| 2 2 j−i+1 j−i−1 j−i+1 − 1. Similarly, j1 − i1 = j − i − 2 = 2 = 2 − 1 = |N(G1 )| − 1. Since every level p + 1 execution has been generated from a level p execution with a graph having more than one node, the lemma follows. ⊓ ⊔ √ √ Lemma 2. For each level l, Costl ≤ c × kn × ( 2)l × log 2nl , where n and k are the number of nodes and maximum degree of G respectively and c is a constant.

Proof. If l = log n (i.e., the leaf level of the recursion) then Costl = 0 and also log 2nl = 0. Therefore, the lemma is trivially true. Let us assume that 0 ≤ l ≤ log n − 1. Consider an execution of MakeLayout(G, i, j) at a level l. Since l ≤ log n − 1, |N(G)| > 1. Algorithm MakeLayout uses algorithm Partition to split the graph G into G[P] and G[Q] by removing arc set Crossing(P, Q). Consider an arc a = (u, v) ∈ Crossing(P, Q) such that u ∈ P and v ∈ Q. It is easy to see that at the end of the algorithm ϕ (u) ≥ i and ϕ (v) ≤ j. Therefore, log(|ϕ (u) − ϕ (v)|) ≤ log( j − i) = log(|N(G)| − 1) = log( 2nl − 1) < log 2nl ; the first equality follows from Lemma 1 and the last equality follows from the fact that in each recursive call each child graph has exactly half of the nodes of the parent graph. Since there are exactly 2l nodes at the level l of the recursion tree, Costl < 2l × |Crossing(P, Q)| × log 2nl . The lemma follows from the fact that line 6 of the Parti tion algorithm ensures that |Crossing(P, Q)| ≤ c × k × |N(G)|) and |N(G)| = 2nl . ⊓ ⊔ log n

Lemma 3. ∑l=0 Costl ≤

√ c× 2k √ ( 2−1)2

×n

Proof. The proof can be found in the appendix.

⊓ ⊔

Lemma 4. The algorithm MakeLayout generates a layout of graph G = (N , A ) with a geometric mean of arc lengths = O(1).

160

M.K. Hasan, S.-E. Yoon, and K.-Y. Chwa

Proof. The value of the geometric mean, GMean =



1

m



(u,v)∈A

|ϕ (u) − ϕ (v)|

1

= 2log((∏(u,v)∈A |ϕ (u)−ϕ (v)|) 1

1 m)

log n

= 2 m ∑(u,v)∈A log(|ϕ (u)−ϕ (v)|) = 2 m ∑l=0 Costl √ 2k) 1 (c× √ m ( 2−1)2 ×n

≤2 = O(1)

By Lemma 3

The last equality follows from the fact that m = θ (n).

⊓ ⊔

Lemma 5. The geometric mean of arc lengths for the optimal layout of a graph G = (N , A ) is Ω (1) Proof. Since the optimal layout ϕ ∗ : N → {1, ..., n} is a bijective function, for any arc (u, v) ∈ A , |ϕ ∗ (u) − ϕ ∗(v)| ≥ 1. Thus, 1 1   GMeanOPT = ∏(u,v)∈A |ϕ ∗ (u) − ϕ ∗(v)| m ≥ ∏(u,v)∈A 1 m = 1 ⊓ ⊔ Using Lemma 4 and Lemma 5 we get the following result. Theorem 2. The MakesLayout algorithm generates a layout for a graph G in O(n log2 n) time such that the geometric mean of arc lengths of the graph is at most constant times the geometric mean of arc lengths of the optimal layout. 4.3 Upper Bound of a Layout Consider any arbitrary layout ψ of a graph G = (N , A ). Let (u, v) ∈ A be an arbitrary arc of G . Then 1 ≤ ψ (u) ≤ n, where n = |N |. So, log(|ψ (u) − ψ (v)|) < log n. Then the geometric mean of arc lengths for this layout is:

GMeanANY =



k + 2.) Therefore, the decision problem MODVVCRP is NP-Complete.

4

Conclusion

It is clear to see that the algorithm on rectangular duals presented by He [6] is closely related to st-orientation. Therefore, we conclude our paper with the following conjecture: Conjecture 1: Given an irreducible triangulation G and a positive integer k, the decision problem on whether G admits a rectangular dual with one of its dimensions ≤ k is NP-Complete.

References 1. Fraysseix, H.D., de Mendez, P.O., Pach, J.: Representation of planar graphs by segments. Intuitive Geometry 63, 109–117 (1991) 2. Fraysseix, H.D., de Mendez, P.O., Pach, J.: A Left-First Search Algorithm for Planar Graphs. Discrete & Computational Geometry 13, 459–468 (1995) ´ Transversal structures on triangulations, with application to straight-line 3. Fusy, E.: drawing. In: Healy, P., Nikolov, N.S. (eds.) GD 2005. LNCS, vol. 3843, pp. 177–188. Springer, Heidelberg (2006) ´ Straight-line drawing of quadrangulations. In: Kaufmann, M., Wagner, 4. Fusy, E.: D. (eds.) GD 2006. LNCS, vol. 4372, pp. 234–239. Springer, Heidelberg (2007) ´ Transversal structures on triangulations: combinatorial study and straight 5. Fusy, E.: line drawing, Ecole Polytechnique (2006) 6. He, X.: On finding the rectangular duals of planar triangular graphs. SIAM Journal on Computing 22, 1218–1226 (1993) 7. Ko´zmi´ nski, K., Kinnen, E.: Rectangular dual of planar graphs. Networks 15, 145– 157 (1985) 8. Zhang, H., He, X.: Canonical ordering trees and their applications in graph drawing. Discrete Comput. Geom. 33, 321–344 (2005) 9. Sadasivam, S., Zhang, H.: On representation of planar graphs by segments. In: Fleischer, R., Xu, J. (eds.) AAIM 2008. LNCS, vol. 5034, pp. 304–315. Springer, Heidelberg (2008) 10. Sadasivam, S., Zhang, H.: NP-completeness of st-orientations of plane graphs. In: COCOON (submitted, 2009)

On Modulo Linked Graphs⋆ Yuan Chen, Yao Mao, and Qunjiao Zhang College of Science, Wuhan University of Science and Engineering, Wuhan 430073, P R China [email protected]

Abstract. A graph G is k-linked if G has at least 2k vertices, and for every sequence x1 , x2 , . . . , xk , y1 , y2 , . . . , yk of distinct vertices, G contains k pairwise vertex-disjoint paths P1 , P2 , . . . , Pk such that Pi joins xi and yi for i = 1, 2, . . . , k. We say that G is modulo (m1 , m2 , . . . , mk )-linked if G is k-linked and, in addition, for any k-tuple (d1 , d2 , . . . , dk ) of natural numbers, the paths P1 , P2 , . . . , Pk can be chosen such that Pi has length di modulo mi for i = 1, 2, . . . , k. Thomassen [15] showed that if each mi is odd and G has sufficiently high connectivity then G is modulo  (m1 , m2 , . . . , mk )-linked. In this paper, we will prove that when G is (92 ki=1 mi − 44k)-connected, where mi is a prime or mi = 1, either G is modulo (2m1 , 2m2 , . . . , 2mk )-linked or G has a vertex set X of order at most 4k − 3 such that G − X is bipartite.

1

Introduction

We use Diestel [2] for terminology and notation , and consider simple graphs only. A graph is said to be k-linked if it has at least 2k vertices and for every sequence x1 , x2 , . . . , xk , y1 , y2 , . . . , yk of distinct vertices there exist k pairwise vertex disjoint paths P1 , P2 , . . . , Pk such that Pi joins xi and yi for i = 1, 2, . . . , k. Clearly every k-linked graph is k-connected. However, the converse is not true. Jung [4] and Larman and Mani [9], independently, proved the existence of a function f (k) such that every f (k)-connected graph is k-linked. Bollob´ as and Thomason [1] showed that every 22k-connected graph is k-linked, which was the first result that the linear connectivity guarantees a graph to be k-linked. Kawarabayashi, Kostochka and Yu [7] proved that every 12k-connected graph is k-linked, and later, Thomas and Wollan [13] proved that every 10k-connected graph is k-linked. Actually, they gave the following stronger statement. Theorem 1. ([13]) If G is 2k-connected and has at least 5k|V (G)| edges, then G is k-linked. Theorem 2. ([10]) Every 2k-connected graph with girth large enough is k-linked. For all k ≥ 2, this statement is not true for 2k − 1 instead of 2k. ⋆

Supported by Educational Commission of Hubei Province of China(Q20091706).

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 173–180, 2009. c Springer-Verlag Berlin Heidelberg 2009 

174

Y. Chen, Y. Mao, and Q. Zhang

Theorem 3. ([6]) Every 2k-connected graph with girth at least 7 is k-linked for k ≥ 21 and k ≤ 2. In this paper, we are interested in modulo k-linked graphs. Thomassen [14] first proved that if each mi is odd and G has sufficiently high connectivity then G is k-linked modulo (m1 , m2 , . . . , mk ). 27k In [15], Thomassen also proved that for any integer k, a 23 -connected graph is parity-k-linked (i.e. k-linked modulo (2, 2, . . . , 2)) if the deletion of any set of less than 4k − 3 vertices leaves a non-bipartite graph. As showed in [15], the bound “4k − 3” is best possible. However, the condition on the connectivity is far from best possible. Kawarabayashi and Reed [8] get the following statement. Theorem 4. ([8]) Suppose G is 50k-connected. Then either G is parity-k-linked or G has a vertex set X of order at most 4k − 3 such that G − X is bipartite. The main purpose of this article is to show that linear connectivity can guarantee a graph to be modulo (m1 , m2 , . . . , mk )-linked in some cases. k Theorem 5. Suppose G is (92 i=1 mi − 44k)-connected, where mi is a prime or mi = 1. Then either G is modulo (2m1 , 2m2 , . . . , 2mk )-linked or G has a vertex set X of order at most 4k − 3 such that G − X is bipartite.

2

Proof of Theorem 5

For a graph G an odd cycle cover is a set of vertices C ⊆ V (G) such that G − C is bipartite. We first show a simple form of Theorem 5. Theorem 6. Suppose G is (92m − 44)k-connected,where m is a prime or m=1. Then either G is k-linked modulo (2m, . . . , 2m) or G has a vertex set X of order at most 4k − 3 such that G − X is bipartite. Proof. We may assume that G has a minimum odd cycle cover of order at least 4k −2.Let X be 2k specified vertices {x1 , x2 , . . . , xk , y1 , y2 , . . . , yk } that we would like to find k disjoint paths {L1 , L2 , . . . , Lk } such that Li joins xi and yi ,and for any k-tuple (d1 , d2 , . . . , dk ) of natural numbers, the paths {L1 , L2 , . . . , Lk } can be chosen such that Li has length di modulo 2m for i = 1, 2, . . . , k. Case 1. The minimum odd cycle cover of G − X is of order at least 4k − 1. Let G′ = G − X. Then G′ is (92m − 46)k-connected. Since G′ is (92m − 46)k as observed by Erd˝ os, if we choose a spanning bipartite subgraph H of G′ with maximum number of edges, the minimum degree of H is at least (46m − 23)k and hence H has at least (23m − 23/2)k|V (H)| edges. (1) H has a (4m − 2)k-linked bipartite subgraph K. (1.1) Let G be a triangle-free graph and k an integer such that (a) |V (G)| ≥ 46k and (b) |E(G)| ≥ 23k|V (G)| − 230k 2

On Modulo Linked Graphs

175

Then G contains a 10k-connected subgraph H with at least 20k|V (H)| edges. Suppose that (1.1) is not true. Let G be a graph with n vertices and m edges, and let k be an integer such that (a) and (b) are satisfied. Suppose, moreover,that (c) G contains no 10k-connected subgraph H with at least 20k|V (H)| (d) n is minimal subject to (a),(b),(c). Claim 1.|V (G)| > 80k Clearly, if G is a graph on n vertices with at least 23kn − 230k 2 edges, then 23kn − 230k 2 ≤ n2 /4. Note that by Turan’s theorem, a triangle-free graph with √ 2 2 < 12k or 299k /4 edges. Hence, either n ≤ 46k − 2 n vertices has at most n √ 2 n ≥ 46k + 2 299k > 80k. Hence the result holds. Claim 2. The minimum degree of G is more than 23k Suppose that G has a vertex v with degree at most 23k, and let G′ be the graph obtained from G by deleting v. By (c), G′ does not contain a 10k-connected subgraph H with at least 20kV (H) edges. Claim (1) implies that |V (G)| = n − 1 ≥ 46k. Finally, |E(G′ )| ≥ m − 23k ≥ 23|V (G′ )| − 230k 2. Since |V (G′ )| < n, this contradicts (d) and the claim follows. Claim 3. m ≥ 20kn Suppose m < 20kn, Then 23kn − 230k 2 < 20kn. n < 77k, a contradiction to claim 1. By Claim 3 and (c), G is not 10k-connected. This implies  that G has a separation (A1 , A2 ) such that A1 \A2 = ∅ = A2 \A1 and |A1 A2 | ≤ 10k − 1. By claim 2, |Ai | ≥ 23k + 1. Let Gi be a subgraph of G with vertex set Ai such that G = G1 ∪ G2 and E(G1 ∩ G2 ) = ∅. Suppose that |E(Gi )| < 23k|V (Gi )| − 230k 2 for i = 1, 2. Then 23kn − 230k 2 ≤ m = |E(G1 )| + |E(G2 )| < 23k(n + |A1 ∩ A2 |) − 460k 2 ≤ 23kn − 230k 2 a contradiction. Hence, we may assume that |E(G1 )| ≥ 23k|V (G1 )| − 230k 2 . Since n > |V (G1 )| > 80k by the proof of Claim 1, |E(G1 )| ≥ 20k|V (G1 )| and G1 does not contain a 10k-connected subgraph H with at least 20k|V (H)| edges, this contradicts (d) and (1.1) is proved. Combine (1.1) with Theorem 1,(1) holds. Let K be a (4m − 2)k-linked bipartite subgraph. We say that P is a parity breaking path for K if P is internally disjoint from K and K together with P has an odd cycle. This parity breaking path may be just a single edge.We shall use the following recent result in [16]. (2) For any set S of vertices of a graph G, either 1. there are k disjoint odd S paths, i.e. k disjoint paths each of which has an odd number of edges and both its endpoints in S, or 2. there is a vertex set X of order at most 2k − 2 such that G − X contains no such paths. One of the partite set of KG′ has at least (10m − 5)k vertices. (3)There are at least 2k disjoint parity breaking paths for K. Take one partite set S of KG′ with at least (10m − 5)k vertices. We shall apply (2) to G′ and S. If there are at least 2k vertex-disjoint odd S paths in G′ ,

176

Y. Chen, Y. Mao, and Q. Zhang

we can clearly find 2k vertex-disjoint parity breaking paths for K since KG′ is a bipartite subgraph. Otherwise, there is a vertex set R of order at most 4k − 2 such that G′ − R has no such paths. Since |R| ≤ 4k − 2 and G′ is (92m − 46)kconnected, it follows that G′ − R is 2-connected.If there is an odd cycle C in G′ − R, then we can take two disjoint paths from C to S ,and this would give an odd S path, a contradiction. This implies that G′ − R is bipartite. But then there is a vertex set R of order at most 4k − 2 such that G′ − R is bipartite. A contradiction. We shall construct desired k  disjoint paths by using K and 2k parity breaking 2k paths P1 , P2 , . . . , P2k . Let P = l=1 E(Pl ),Pi joins si and si ′ for i = 1, 2, . . . , 2k. Since G is (92m−44)k-connected, there are 2k disjoint paths W={W1 , . . . , W2k } 2k joining X with K such that l=1 (E(Wl ) − P ) is as small as possible. We assume that Wi joins xi with K for i = 1, 2, . . . , k and Wi+k joins yi and K for i = 1, 2, . . . , k. Let xi ′ be the other endvertex of the path Wi . Similarly,let yi ′ be the other endvertex of the path Wi+k . Note that both xi ′ and yi ′ are in K. If at least two paths of W intersect a path Pj , then let W and W ′ be the paths that intersect Pj as close as possible (on Pj ) to one endvertex of Pj and the other endvertex of Pj , respectively. Our choice implies that both W and W ′ follow the path Pj and end at the endvertices of Pj . Suppose that precisely one path, say W ∈ W, intersects a path Pj . Then our choice implies that W follows the path Pj and ends at one of the endvertices. Let us observe that W can control the parity since Pj is a parity breaking path. Then we can choose (m − 1)k independent edges ai1 bi1 , . . . , ai(m−1) bi(m−1) for 2k i = 1, . . . , k in K ∗ = K − W − l=1 V (Pl ). Such a choice is possible, since K is (10m − 5)k-connected. Next we choose different vertices ui1 , vi1 , wi1 , zi1 , . . . , ui(m−1) , vi(m−1) , wi(m−1) , zi(m−1) in K ∗ −{a11 , b11 , . . . , a1(m−1) , b1(m−1) , . . . , ak1 , bk1 , . . . , ak(m−1) , bk(m−1) } such that the vertex aij is adjacent to wij , zij and bij is adjacent to uij , vij for i = 1, 2, . . . , k and j = 1, 2, . . . , m − 1. This is possible since the every vertex in K has degree at least (10m − 5)k. Let W ′ be the set of paths in W such that all the paths have exactly one intersection with a parity breaking path. If Wi , Wi+k ∈ W ′ for any i = 1, 2, . . . , k. Then there are at least k parity breaking paths with no intersection with W. For i = 1, 2, . . . , k and j = 1, 2, . . . , m−1, we take (4m − 2)k internally vertex disjoint paths Si , Si ′ , Pij , Qij , Rij , Wij in K such that for each i, j – – – – – – –

Si joins xi ′ and si , Si ′ joins bi(m−1) and si ′ , Pij joins zij and uij , Qij joins wij and uij , Rij joins wij and vij , Wi1 joins yi ′ and ai1 , Wij joins bi(j−1) and aij j = 2, . . . , m − 1.

By (1), K is a (4m − 2)k-linked bipartite graph, hence we can find desired (4m − 2)k internally disjoint paths.

On Modulo Linked Graphs

177

For each i, we would like to find a (xi , yi )-path of length di modulo 2m. First, we shall find a (xi , yi )-path with length of the same parity as di . K is (4m − 2)klinked, so there is a path Ri from bi(m−1) to si in K which is internally disjoint − → from {Si , Pij , Qij , Rij , Wij }. Since Pi is a parity breaking path, bi(m−1) Ri si and − →′ ′ ← − bi(m−1) Si si Pi si are of length of the different parities. We set −−−−−→ −−→ −−→ − →′ ← − ← − ← − Qi = yi Wi+k yi ′ Wi1 ai1 bi1 Wi2 . . . Wi(m−1) ai(m−1) bi(m−1) Si si ′ Pi si Si xi ′ Wi xi and −−→ −−→ −−−−−→ − → ← − ← − Qi ′ = yi Wi+k yi ′ Wi1 ai1 bi1 Wi2 . . . Wi(m−1) ai(m−1) bi(m−1) Ri si Si xi ′ Wi xi for i = 1, 2, . . . , k. It is easy to see that one of the Qi and Qi ′ , say Qi ,has length of the same parity as di . Suppose that di − l(Qi ) ≡ 2t modulo 2m. Now for each i, we construct the m − 1 disjoint cycles Ci1 , Ci2 , . . . , Ci(m−1) as follows. For i = 1, 2, . . . , k and j = 1, 2, . . . , m − 1, if one of Pij ,Qij and Rij , say −→ Pij , has length l(Pij ) ≡ 2m − 1 modulo 2m , we set Cij := aij zij Pij uij bij aij , −→ ←− −→ Otherwise, set Cij := aij zij Pij uij Qij wij Rij vij bij aij . We have for each i = 1, 2, . . . , k and j = 1, 2, . . . , m − 1 −→ ←− |V (aij Cij bij | − |V (aij Cij bij | ≡ 2mij modulo 2m mi1 , . . . , mi(m−1) are some nonzero congruence classes modulo m. By Theorem 8, There exist ε1 , ε2 , . . . , εm−1 ∈ {0, 1}, such that m−1  j=1

εj (2mij ) ≡ 2t modulo 2m

For each j with εj = 1, let Qi ∗ be the path obtained from Qi by replacing ←− −→ aij Cij bij with aij Cij bij . Then Qi ∗ is an (xi , yi )-path of length di modulo 2m. So we can find desired k disjoint paths. If at least one of Wi , Wi+k for some i, say Wi , is in W ′ , since we can control the parity of Wi , we can easily find a path connecting xi and yi through Wi+k , ai1 bi1 , . . . , ai(m−1) bi(m−1) and Wi which has length of the same parity as di . The same proof as above, we can find desired k disjoint paths. sqi xqi

xiq ′

yqi

yiq ′

siq ′

ai1 q q zi1 q wi1

bi1 q

ai2 q

q ui1

q zi2 q vi1

q wi2

Fig. 1.

a bi2 q . . . . .i(m−1) . q q ui2

bi(m−1) q

q q zi(m−1)ui(m−1) q q q vi(m−1) vi2 wi(m−1)

178

Y. Chen, Y. Mao, and Q. Zhang

Case 2. The minimum odd cycle cover of G − X is of order at most 4k − 2. Let U be the minimum odd cycle cover of G−X such that 2k − 1 ≤ |U | ≤ 4k − 2, We shall prove that G has k desired disjoint paths. Since the essentially same proof works for the case that G has an odd cycle cover U ′ of order exactly 4k − 2 such that U ′ contains all the vertices in X, we only sketch the proof of this case. Let A, B be a partite set of G − X − U , Clearly |A|, |B| ≥ (92m − 50)k and any vertex in U has at least (92m − 50)k neighbours to G − X − U , since G − X is (92m − 46)k-connected.We can partition U in two sets V and W such that every vertex of V has at least (46m − 25)k neighbours in A and every vertex of W has at least (46m − 25)k neighbours in B. For some 0 ≤ l ≤ k − 1,we can choose 2k − 1 vertices in U such that there are 2l vertices {u1 , . . . , u2l } in V and the other 2k − 2l − 1 vertices {u2l+1 , . . . , u2k−1 } in W . We may assume that UA ={u1, . . . , u2l } and UB ={u2l+1 , . . . , u2k−1 }. We claim that there are a matching MA in the graph G[UA ∪ B] that covers all of UA and a matching MB in G[UB ∪ A] that covers all of UB . Otherwise, there is no matching in G[UA ∪ B], say, that covers all of UA . Using a small extension of Tutte’s matching theorem,this implies the existence of a set Z of vertices such that the graph G[UA ∪ B] − Z has at least |Z| + 2 odd components that are contained in UA . Let the set Z ′ contain exactly one vertex from each of these components. Then the graph H = G − X − ((U − Z ′ ) ∪ Z) is bipartite with bipartition ((A ∩ V (H)), ((B ∪ Z ′ ) ∩ V (H))). Hence the set (U − Z ′ ) ∪ Z is an odd cycle cover of order |U | − |Z ′ | + |Z| < |U | which contradicts the choice of U . Hence there are a matching MA in the graph G[UA ∪ B] that covers all of UA and a matching MB in G[UB ∪ A] that covers all of UB . Now we shall find desired k disjoint paths in G as follows. First, we choose different vertices a1 , . . . , a2l ∈ A and b2l+1 , . . . , b2k−1 ∈ B such that for 1 ≤ i ≤ 2l the vertex ai is a neighbour of ui , for 2l + 1 ≤ i ≤ 2k − 1 the vertex bi is a neighbour of ui and none of these vertices is incident with an edge in MA ∪ MB . Such a choice is possible, since the vertices in UA and UB have at least (46m − 25)k neighbours in A and B, respectively. We say that P is a parity breaking path if G − X − U together with P has an odd cycle. For every vertex ui in UA that is matched to a vertex b in B, we can find a parity breaking path b, ui , ai . For every vertex ui in UA that is matched to a vertex uj in UA , we can find a parity breaking path ui ,uj and their two neighbours ai and aj in A. Similarly, we can construct parity breaking paths for UB . Now we have at least k parity breaking paths P={P1 , . . . , Pk }. The endvertices of Pi are si and ti for i = 1, . . . , k. Take a matching from X to G − X − U − P. This is possible since every vertex of X has minimum degree at least (92m − 44)k. xi , yi are matched to xi ′ , yi ′ for i = 1, . . . , k. X ′ = {x1 ′ , . . . , xk ′ , y1 ′ , . . . , yk ′ }.

On Modulo Linked Graphs

179

Then we choose (m − 1)k independent edges ai1 bi1 , . . . , ai(m−1) bi(m−1) for i = 1, . . . , k in G∗ = G − X − U − P − X ′ . Such a choice is possible, since G∗ is (92m − 54)k-connected. Next, we choose different vertices ui1 , vi1 , wi1 , zi1 , . . . , ui(m−1) , vi(m−1) , wi(m−1) , zi(m−1) in G∗ −{a11 , b11 , . . . , a1(m−1) , b1(m−1) , . . . , ak1 , bk1 , . . . , ak(m−1) , bk(m−1) } such that the vertex aij is adjacent to wij , zij and bij is adjacent to uij , vij for i = 1, 2, . . . , k and j = 1, 2, . . . , m − 1. This is possible since every vertex in G∗ has degree at least (92m − 54)k. Then, we can take (4m − 1)k internally vertex disjoint paths Si , , Ti , Si ′ , Pij , Qij , Rij , Wij for i = 1, 2, . . . , k and j = 1, 2, . . . , m − 1 in G − X − U such that for each i, j – – – – – – – –

Si joins xi ′ and si , Ti joins bi(m−1) and ti , Si ′ joins bi(m−1) and si , Pij joins zij and uij , Qij joins wij and uij , Rij joins wij and vij , Wi1 joins yi ′ and ai1 , Wij joins bi(j−1) and aij j = 2, . . . , m − 1.

By the result in [13], G − X − U is (8m − 4)k-linked, and hence we can find desired (4m − 1)k desired internally disjoint paths. For each i, since Pi is a parity breaking path ,we can easily find a path connecting xi and yi through ai1 bi1 , . . . , ai(m−1) bi(m−1) which has length of the same parity as di . The same proof as in Case 1, we can find desired k disjoint paths. Let us briefly remark the case that G has an odd cycle cover U ′ of order exactly 4k − 2 such that U ′ contains all the vertices in X. If there are at least k disjoint parity breaking paths in G − X, then we are done. Otherwise, |U ′ − X| = 2k − 2 and there are exactly k − 1 parity breaking paths in G − X. It is easy to see that for some i, the pair (xi , yi ) has a matching xi x, yi y such that a path from x to y passing through k − 1 independent edges in G − X − U together with xi x, yi y gives the same parity as di , Since G − X − U is still (9m − 5)k-linked, there are at least k − 1 parity disjoint breaking paths and the pair (xi , yi ) does not require to use any parity breaking path, the same proof as above, we can find desired k disjoint paths.This completes the proof. Since the proof of Theorem 5 is just a repetition of Theorem 6, we leave it to the reader.

Acknowledgement The authors are grateful to the referees for their valuable comments, corrections and suggestions.

180

Y. Chen, Y. Mao, and Q. Zhang

References 1. Bollob´ as, B., Thomason [1]: Highly linked graphs. Combinatorica 16, 313–320 (1996) 2. Diestel, R.: Graph Theory, 2nd edn. Springer, Heidelberg (2000) 3. Erd¨ os, P., Heilbronn, H.: On the addition of residue classes mod p. Acta Arith 9, 149–159 (1964) 4. Jung, H.A.: Verallgemeinerung des n-fahen zusammenhangs f¨ ur Graphen. Math. Ann. 187, 95–103 (1970) 5. Kawarabayashi, K.: K-linked graph with girth condition. J. Graph Theory 45, 48–50 (2004) 6. Kawarabayashi, K.: Note on k-linked high girth graphs (preprint) 7. Kawarabayashi, K., Kostochka, A., Yu, G.: On sufficient degree conditions for a graph to be k-linked. In: Combin. Probab. Comput. (to appear) 8. Kawarabayashi, K., Reed, B.: Highly parity linked graphs. In: Combinatorica (to appear) 9. Larman, D.G., Mani, P.: On the existence of certain configurations within graphs and the 1-skeletons of polytopes. Proc. London Math. Soc. 20, 144–160 (1974) 10. Mader, W.: Topological subgraphs in graphs of large girth. Combinatorica 18, 405– 412 (1998) 11. Mann, H.B.: An addition theorem for the elementary abelian group. J. Combin. Theory 5, 53–58 (1968) 12. Olson, J.E.: Addition Theorems: The Addition Theorem of Group Theory and Nember Theory. Interscience, New York (1965) 13. Thomas, R., Wollan, P.: An improved linear edge bound for graph linkages. European J. Combinatorics 26, 309–324 (2005) 14. Thomassen, C.: Graph decomposition with applications to subdivisions and path systems modulo k. J. Graph Theory 7, 261–274 (1983) 15. Thomassen, C.: The Erd¨ os-P´ osa property for odd cycles in graphs with large connectivity. Combinatorica 21, 321–333 (2001) 16. Geelen, J., Gerards, B., Goddyn, L., Reed, B., Seymour, P., Vetta, A.: On the oddminor variant of Hadwiger’s conjecture. J. Combin. Thpery Ser.B 99(1), 20–29 (2009)

PATHWIDTH is NP-Hard for Weighted Trees Rodica Mihai1 and Ioan Todinca2 1

Department of Informatics, University of Bergen, N-5020 Bergen, Norway [email protected] 2 LIFO, Universit´e d’Orl´eans, 45067 Orl´eans Cedex 2, France [email protected]

Abstract. The pathwidth of a graph G is the minimum clique number of H minus one, over all interval supergraphs H of G. We prove in this paper that the PATHWIDTH problem is NP-hard for particular subclasses of chordal graphs, and we deduce that the problem remains hard for weighted trees. We also discuss subclasses of chordal graphs for which the problem is polynomial.

1 Introduction Graph searching problems, already introduced as a problem in speology in the 60’s [6], have become popular in computer science with the papers of Parsons [24,23] and of Petrov [27] and have been widely studied since the late 70’s. In graph searching we are given a contaminated graph (all edges are contaminated) and we aim to clean it using a minimum number of searchers. There are several variants of the problem, let us consider here the node searching introduced by Kirousis and Papadimitriou [15]. A search step consists in one of the following operations: (1) place a searcher on a vertex, (2) remove a searcher from a vertex. A contaminated edge becomes clear if both its endpoints contain a searcher. A clear edge is recontaminated at some step if there exists a path from this edge and a contaminated edge, and no internal vertex of this path contains a searcher. The node search number of a graph is the minimum number of searchers required to clean the whole graph, using a sequence of search steps. By the results of LaPaugh [18] and Bienstock and Seymour [2], the node search game is monotone: there always exists a cleaning strategy, using a minimum number of searchers, such that a clear edge will never be recontaminated during the search process. The vertex separation number of a graph is defined as follows. A layout of a graph G is a total ordering (v1 , v2 , . . . , vn ) on its vertex set. The separation number of a given layout is the maximum, over all positions i, 1 ≤ i ≤ n, of the number of vertices in {v1 , . . . , vi } having neighbours in {vi+1 , . . . , vn }. (Informally, one can think that at step i, the part of the graph induced by the first i vertices has been cleaned, the rest is contaminated, and we need to guard all clean vertices having contaminated neighbours in order to avoid recontamination.) The vertex separation number of a graph G is the minimum separation number over all possible layouts of G. Pathwidth has been introduced in the first article of Robertson and Seymour’s Graph Minor series [28]. The pathwidth of an arbitrary graph G is the minimum clique number of H minus one, over all interval supergraphs H of G, on the same vertex set. X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 181–195, 2009. c Springer-Verlag Berlin Heidelberg 2009 

182

R. Mihai and I. Todinca

Actually, the three graph parameters mentioned above are almost the same. For any graph G, its pathwidth pwd(G) is exactly the vertex separation number, and is also equal to the node search number minus one, [14]. From now on we consider the PATH WIDTH problem, i.e. the problem of computing the pathwidth of the input graph. The PATHWIDTH problem is NP-hard, even for co-bipartite graphs [32] and chordal graphs [12]. On the positive side, it is fixed parameter tractable: Bodlaender and Kloks [3] proposed an algorithm that, given an arbitrary graph G and a parameter k, the algorithm decides if pwd(G) ≤ k in a running time which is linear in n (the number of vertices of the graph) but, of course, exponential in k. By [3], PATHWIDTH is polynomially tractable for all classes of graphs of bounded treewidth. For trees and forests there exist several algorithms solving the problem in O(n log n) time [19,9]; recently, Skodinis [29] and Peng et al. [25] gave a linear time algorithm. Even the unicyclic graphs, obtained from a tree by adding one edge, require more complicated algorithms in order to obtain an O(n log n) time bound [8]. Chou et al. [7] extended the techniques used on trees and obtain a polynomial algorithm solving the problem on block graphs, i.e. graphs in which each 2-connected component induces a clique. There exist some other geometric graph classes for which the PATHWIDTH problem is polynomial, for example permutation graphs [4]. Based on this result, Peng and Yang [26] solved the problem for biconvex bipartite graphs. Suchan and Todinca [30] gave an O(n2 ) computing the pathwidth of circular-arc graphs; circular arc-graphs are intersection graphs of a family of arcs of a cycle (see next section for more details on intersection graphs). The technique used in [30] exploits the geometric structure of circular arc graphs and the fact that such a graph can be naturally cut using some sets of scanlines (chords of the cycle). A similar approach has been used before for computing the treewidth of circular-arc graphs [31] and the treewidth of circle graphs [16]. Circle graphs are intersection graphs of a set of chords of a cycle, i.e. each vertex of the graph corresponds to a chord and two vertices are adjacent if the corresponding chords intersect. The class of circle graphs contains the class of distance-hereditary graphs and in particular all the trees [11]. The problem of computing pathwidth for distance heredetary (and thus circle graphs) was proved to be NP-hard [17]. Our results. We prove in this paper that PATHWIDTH remains NP-hard even when restricted to weighted trees with polynomial weights. The weighted version of pathwidth is defined in the next section; roughly speaking, in terms of search or vertex separation, when we guard a vertex v of weight w(v), we need w(v) guards instead of one. Equivalently, the pathwidth of a weighted tree can be seen as the pathwidth of the unweighed graph obtained by replacing each vertex v of the tree with a clique module of size w(v). Since the latter graphs are distance-hereditary, this also implies the NP-hardness of pathwidth for distance-hereditary and circle graphs. We also show that MODIFIED CUTWIDTH is NP-hard to compute for edge-weighted trees. Note that Monien and Sudborough [21] proved that CUTWIDTH is NP-hard for edge-weighted trees, and our reductions are inspired by their techniques. Eventually, we discuss some classes of graphs for which the PATHWIDTH problem remains polynomial.

PATHWIDTH is NP-Hard for Weighted Trees

183

2 Preliminaries 2.1 Basic Definitions We work with simple and undirected graphs G = (V, E), with vertex set V (G) = V and edge set E(G) = E, and we let n = |V |, m = |E|. The set of neighbors of a vertex x is denoted by N (x) = {y | xy ∈ E}. A vertex set C is a clique if every two vertices in C are adjacent, and a maximal clique if no superset of C is a clique. We denote by ω(G) the maximum clique size of the graph. A set of vertices M of G forms a module if, for any vertex x ∈ V \ M , either x is adjacent to all vertices of M or to none of them. The subgraph of G induced by a vertex set A ⊆ V is denoted by G[A]. A path is a sequence v1 , v2 , ..., vp of distinct vertices of G, where vi vi+1 ∈ E for 1 ≤ i < p, in which case we say that this is a path between v1 and vp . A path v1 , v2 , ..., vp is called a cycle if v1 vp ∈ E. A chord of a cycle (path) is an edge connecting two nonconsecutive vertices of the cycle (path). A vertex set S ⊂ V is a separator if G[V \ S] is disconnected. Given two vertices u and v, S is a u, v-separator if u and v belong to different connected components of G[V \ S], and S is then said to separate u and v. A u, v-separator S is minimal if no proper subset of S separates u and v. In general, S is a minimal separator of G if there exist two vertices u and v in G such that S is a minimal u, v-separator. A graph is chordal if every cycle of length at least 4 has a chord. Given a family F of sets, the intersection graph of the family is defined as follows. The vertices of the graph are in one-to-one correspondence with the sets of F , and two vertices are adjacent if and only if the corresponding sets intersect. Every graph is the intersection graphs of some family F , but by restricting these families we obtain interesting graph classes. An interval graph is the intersection graph of a family of intervals of the real line. A graph is circle graph if it is the intersection graph of chords in a circle. Definition 1. A path decomposition of an arbitrary graph G = (V, E) is a path P = (X , A), where the nodes X are subsets of V (also called bags), such that the following three conditions are satisfied. 1. Each vertex v ∈ V appears in some bag. 2. For every edge {v, w} ∈ E there is a bag containing both v and w. 3. For every vertex v ∈ V , the bags containing v induce a connected subpath of P. The width of the path decomposition P = (X , A) is max{|X| − 1 | X ∈ X } (the size of the largest bag, minus one). The pathwidth of G, denoted pwd(G), is the minimum width over all path decompositions of the graphs. We extend the definition of pathwidth to weighted graphs G = (V, E, w : V → N), where the weights are assigned to the vertices. The weight of a path decomposition P = (X , A) is max{w(X) − 1 | X ∈ X }, where w(X) is the weight of the bag, i.e. the sum of the weights of its nodes. The (weighted) pathwidth is again the minimum weight over all path decompositions of the graph. Observation 1. The weighted pathwidth of a graph G = (V, E, w) equals the (unweighted) pathwidth of the graph H, obtained from G by replacing each vertex v by a

184

R. Mihai and I. Todinca

clique module Mv of size w(v). That is, we replace each vertex v by set of vertices Mv , of size w(v) and inducing a clique in H, and two vertices v ′ ∈ Mv and u′ ∈ Mu are adjacent in H if and only if v and u are adjacent in G. Path decompositions are strongly related to interval graphs. Given a graph G, a clique path of G is a path decomposition whose set of bags is exactly the set of maximal cliques of G. It is well known that a graph G is an interval graph if and only of it has a clique path. Similarly, a clique tree of a graph G is a tree whose nodes correspond to the maximal cliques of G, and such that for any vertex of the graph, the nodes containing this vertex form a connected subtree of the clique tree. Clique trees characterize chordal graphs: Lemma 1 (see, e.g., [10]). A graph G is an interval graph if and only of it has a clique path. A graph G is chordal if and only if it has a clique tree. Clearly, clique paths are particular cases of clique trees, in particular interval graphs are also chordal. An interval completion of an arbitrary graph G = (V, E) is an interval supergraph H = (V, F ) of G, with the same vertex set and E ⊆ F . Moreover, if no strict subgraph H ′ of H is an interval completion of G, we say that H is a minimal interval completion of G. By the previous lemma, the pathwidth of an (unweighted) interval graph is its clique size minus one, and the pathwidth of an arbitrary unweighted graph is the maximum, over all interval completions H of G, of ω(H)−1. Moreover, when searching for interval completions realizing this minimum we can clearly restrict to minimal interval completions. 2.2 Foldings Given a path decomposition P of G, let PathFill(G, P) be the graph obtained by adding edges to G so that each bag of P becomes a clique. It is straight forward to verify that PathFill(G, P) is an interval supergraph of G, for every path decomposition P. Moreover P is a path decomposition of PathFill(G, P), and if we remove the bags which are not maximal by inclusion we obtain a clique path. Definition 2. Let X = {X1 , ..., Xk } be a set of subsets of V such that Xi , 1 ≤ i ≤ k, is a clique in G = (V, E). If, for every edge vi vj ∈ E, there is some Xp such that {vi , vj } ⊆ Xp , then X is called an edge clique cover of G. Definition 3 ([13,30]). Let X be an edge clique cover of an arbitrary graph G and let Q = (Q1 , ..., Qk ) be a permutation of X . We say that (G, Q) is a folding of G by Q. To any folding of G by an ordered edge clique cover Q we can naturally associate, by Algorithm FillFolding of Figure 1, an interval supergraph H = FillFolding(G, Q) of G. The algorithm also constructs a clique path decomposition of H. Lemma 2 ([30]). Given a folding (G, Q) of G, the graph H = FillFolding(G, Q) is an interval completion of G.

PATHWIDTH is NP-Hard for Weighted Trees

185

Algorithm. FillFolding Input: Graph G = (V, E) and Q = (Q1 , ..., Qk ), a sequence of subsets of V forming an edge-clique cover; Output: A supergraph H of G; P = Q; for each vertex v of G do s = min{i | x ∈ Qi }; t = max{i | x ∈ Qi }; for j = s + 1 to t − 1 do Pj = Pj ∪ {v}; end-for H = PathFill(G, P); Fig. 1. The FillFolding algorithm

We also say that the graph H = FillFolding(G, Q) is defined by the folding (G, Q). It is not hard to prove (see [30]) that every minimal interval completion of G is defined by some folding. Theorem 1 ([30]). Let H be a minimal interval completion of a graph G with an edge clique cover X . Then there exists a folding (G, QH ), where QH is a permutation of X , such that H = FillFolding(G, QH ). In particular, there exists a folding Q such that the pathwidth of FillFolding(G, Q) is exactly the pathwidth of G. For any chordal graph G, the set K of its maximal cliques form an edge-clique cover the graph, thus we will construct foldings of G by choosing permutations of K. The next two lemmas give a better understanding of such a folding. Lemma 3 (see, e.g., [10]). Let G be a chordal graph and fix a clique tree of G. A vertex subset S of G is a minimal separator if and only if there exist two maximal cliques K and K ′ of G, adjacent in the clique tree, such that S = K ∩ K ′ . Lemma 4. Let G be a chordal graph, K be the set of its maximal cliques and let Q be a permutation of K. Let T be a clique tree of G. Consider the path decomposition P produced by the algorithm FillFolding(G, Q) (see Figure 1). Each bag B of P is the union the clique Q ∈ Q which corresponds to the bag B at the initialization step and of the minimal separators of type Q′ ∩ Q′′ , where Q′ , Q′′ are the pairs of cliques adjacent in the clique tree, but separated by Q in Q. We say that the clique Q and the separators have been merged by the folding. Proof. Clearly if Q separates Q′ and Q′′ in the permutation Q, by construction of FillFolding(G, Q), we add to bag B every vertex in Q′ ∩ Q′′ . Conversely, let B be the bag corresponding to Q ∈ Q in FillFolding(G, Q) and let x be a vertex of B \ Q. We have to prove there exist two maximal cliques of G, adjacent in the clique tree, containing x and separated by Q in the permutation Q. By definition of a clique tree, the nodes of T containing x induce a connected subtree Tx . Let Ql , Qr be maximal cliques containing x, situated to the left and to the right of Q in Q (they

186

R. Mihai and I. Todinca

exist by the fact that x has been added to bag B). Thus Ql and Qr are nodes of Tx , and on the unique path from Ql to Qr in Tx there exists an edge Q′ Q′′ such that Q′ is to the left and Q′′ is to the right of Q in the permutation Q. ⊓ ⊔

3 Octopus Graphs 3.1 Octopus Graphs and 0,1-Linear Equations An octopus tree is a tree formed by several disjoint paths, plus a node, called the head of the octopus, adjacent to one endpoint of each path. An emphoctopus graph is a chordal graph having a clique-tree which is an octopus tree, and such that any vertex of the graph appears in at most two maximal cliques. The last condition implies, by Lemma 3, that the minimal separators of an octopus graph are pairwise disjoint. Consider the following problem, called the solvability problem for linear integer equations: – Input: A rectangular matrix A and a column vector b, both of nonnegative integers. – Output: Does there exist a 0-1 column vector x satisfying Ax = b? We will use a restricted version of this problem, that we call the BALANCED SYSTEM OF 0,1- LINEAR EQUATIONS , satisfying the following conditions: 1. for all rows i of matrix A, the sum of the elements in the row is exactly 2bi , 2. for all rows i, all values in row i are larger than all values in row i + 1 . Note that when matrix A has only one row we obtain the 2-partition problem. Monien and Sudborough prove in [21] that: Theorem 2 ([21]). Solving balanced 0,1-linear equation systems is strongly NP-hard, i.e. the problem is hard even when the integers in the matrices A and b are polynomially bounded by the size of A. Monien and Sudborough use a version of this problem for a reduction to C UTWIDTH of edge-weighted trees, which shows that the latter is NP-hard. Our reductions are also from BALANCED SYSTEM OF 0,1- LINEAR EQUATIONS, inspired by their reduction. Nevertheless, it is not clear that one could directly find a reduction from C UTWIDTH of edge-weighted trees to PATHWIDTH of (node) weighted trees or circle graphs or other problems we consider in this paper. 3.2 NP-Hardness of PATHWIDTH for Octopus Graphs This subsection is devoted to the proof of the following theorem: Theorem 3. PATHWIDTH is NP-hard for octopus graphs. More technically, we prove by the following Proposition that the BALANCED SYSTEM OF 0,1- LINEAR EQUATIONS problem is polynomially reducible to PATHWIDTH of octopus graphs.

PATHWIDTH is NP-Hard for Weighted Trees

187

Proposition 1. Given an instance (A, x) of BALANCED SYSTEM OF 0,1- LINEAR EQUA TIONS , we construct an octopus graph G(A, b) as follows: – G(A, b) has a clique tree formed by a head and n legs with m nodes each, where n is the number of columns and m is the number of rows of A. – Let KH be the clique of G(A, b) corresponding to the head of the octopus, and for j, 1 ≤ j ≤ n and each i, 1 ≤ i ≤ m let Ki,j denote the clique corresponding to the node of the jth leg, situated at distance i from the head. • the head clique KH is of size b1 + k, where k is an arbitrary number larger than b1 ; • for each i, j, Ki,j is of size Ai,j + b1 − bi + k; • for each i, j, the minimal separator Si,j = Ki−1,j ∩ Ki,j is of size Ai,j ; here K0,j denotes the head clique KH .

Fig. 2. Matrices

Fig. 3. Octopus graph corresponding to the matrices from Figure 2

We have pwd(G(A, b)) ≤ b1 + k − 1 if and only if the system Ax = b has a 0,1solution. Proof. For simplicity, the graph G(A, b) will be simply denoted by G. Recall that the minimal separators of G are pairwise disjoint and each vertex of the graph appears in at most two maximal cliques. We point out that, by our choice of k ≥ b1 , and by the fact that b1 ≥ bi for all i > 1, the graph G is well constructed. We first show that, if the system Ax = b has a 0,1-solution then pwd(G) ≤ b1 +k−1 (actually it is easy to notice that the inequality can be replaced with an equality, due the fact that G has a clique of size b1 + k). Suppose the system has a solution x∗ . We

188

R. Mihai and I. Todinca

provide a folding of G by putting all legs j of the octopus such that x∗j = 0 to the left, and all those with x∗j = 1 to the right of the head clique KH . Moreover, the folding is such that, on each side of the the head clique KH , starting from KH , we first put the maximal cliques at distance 1 from the head in the clique tree, then those at distance 2 and so on, like in a breadth-first search of the clique tree starting from the head. More formally, let L = {j, 1 ≤ j ≤ n | x∗j = 0} and R = {j, 1 ≤ j ≤ n | x∗j = 1}. We construct a folding Q as follows. The head clique KH is in the middle position of the folding. We put to the right of KH the cliques Ki,j , for all j ∈ R and all i, 1 ≤ i ≤ m. The ordering is such that for any i1 ≤ i2 , and any j1 , j2 , Ki1 ,j1 appears before Ki2 ,j2 in Q. We may assume that, for a fixed i, the cliques Ki,j , j ∈ R appear by increasing j. The cliques appearing before KH in the permutation are ordered symmetrically w.r.t. KH . Let H = FillFolding(G, Q) and P the path decomposition corresponding to the folding, it remains to prove that P has no bag with more than b1 + k vertices. Since each leg of the octopus is either completely to the left or completely to the right of the clique KH , this clique does not separate, in the permutation Q, any couple of cliques adjacent in the clique tree. Therefore, by Lemma 4, the bag corresponding to KH in P has no other vertices than KH . Consider now a bag of P, corresponding to a clique Ki,j . We assume w.l.o.g. that j ∈ R, the case j ∈ L is similar by symmetry of the folding. This bag, denoted by Bi,j , contains Ki,j and the vertices of all the separators corresponding to edges of the clique tree, such that Ki,j separates the endpoints of the edge in the permutation Q (see Lemma 4). These separators are of two types: Si,j ′ with j ′ ∈ R, j ′ > j and Si+1,j ′′ with j ′′ ∈ R, j ′′ < j. Their sizes are respectively Ai,j ′ ′′ and Ai+1,j ′′ , and by definition of balanced systems Ai+1,j ′′ ≤ A i,j . Since |Ki,j | = Ai,j + b1 − bi + k, the size of the bag Bi,j is at most b1 − bi + k + j∈R Ai,j Note that, for any fixed i the equality is attained by the bag Bi,j0 which is closest to KH in the permutation. By definition of set R, the sum is exactly bi and the conclusion follows. Now conversely, assume that pwd(G) ≤ b1 + k − 1, we show that the system Ax = b has a 0,1-solution. Let Q be a permutation of the maximal cliques of G such that FillFolding(G, Q) is of pahwidth at most b1 + k − 1; such a folding exists by Theorem 1. Claim. For any leg j of the octopus tree, all cliques Ki,j , 1 ≤ i ≤ m of the leg are on the same side of the head clique KH in the permutation Q. Proof. (of the claim) Indeed if KH separates in the permutation Q two cliques of a same leg j, then it necessarily separates two consecutive cliques Ki,j and Ki+1,j , for some i, 1 ≤ i < m. It follows by Lemma 4 that, when constructing FillFolding(G, Q), the bag of the resulting path decomposition, corresponding to the clique KH , contains both KH and the minimal separator Si,j = Ki,j ∩ Ki+1,j . Since KH and Si,j are disjoint by construction of G, this bag would have strictly more than |KH | = b1 + k vertices, contradicting the assumption that the pathwidth of FillFolding(G, Q) is at ⊓ ⊔ most b1 + k − 1. This completes the proof of the claim. Let L be the set of indices j, 1 ≤ j ≤ n such that the cliques of leg j appear before KH in Q, and symmetrically let R be the set of indices corresponding to legs appearing after KH .

PATHWIDTH is NP-Hard for Weighted Trees

189

Claim. For all i, 1 ≤ i ≤ m, we have   Ai,j = bi . Ai,j = j∈L

j∈R

 Proof. (of the claim) Take an arbitrary value of i, 1 ≤ i ≤ m. We prove that j∈R Ai,j ≤ bi . Among all cliques Ki,j , j ∈ R let j0 be the index j corresponding to the one which is closest to KH in the ordering Q. Therefore, for any j ∈ R \ {j0 }, there are two cliques Ki′ −1,j and Ki′ ,j , with i′ ≤ i, separated by Ki,j0 in the permutation Q (here again we use the convention K0,j = KH ). In FillFolding(G, Q), the separator Si′ ,j Ai,j new vertices in the corresponding is merged to the clique Ki,j0 , adding Ai′ ,j ≥ bag. Thus this bag will have at least |Ki,j0 | + j∈R\{j0 } Ai,j vertices, so its size is at  least b1 − bi + k + j∈R Ai,j . Since the pathwidth of FillFolding(G, Q) is at most b1 + k − 1, each bag produced by the folding is of size atmost b1 + k, in particular we must have j∈R Ai,j ≤ bi . By symmetry, we also have j∈R Ai,j ≤ bi , and since the sum of all elements in row i is 2bi the conclusion follows. ⊓ ⊔ By the last claim, the 0,1-column vector x∗ such that, for all j, 1 ≤ j ≤ n, x∗j = 0 if j ∈ L and x∗j = 1 if j ∈ L is a solution of the system Ax = b, which completes the proof of this Proposition. ⊓ ⊔ Clearly the graph G(A, b) can be constructed in polynomial time, thus the BALANCED SYSTEM OF 0,1- LINEAR EQUATIONS problem is polynomially reducible to PATH WIDTH of octopus graphs. By Theorem 2, we conclude that PATHWIDTH is NP-hard even when restricted to octopus graphs, which proofs Theorem 3.

Fig. 4. Folding for the octopus graph from Figure 3

4 Weighted Trees We prove in this section that PATHWIDTH is hard for weighted trees. Let us consider now the case of weighted trees. We adapt the idea of Proposition 1 by transforming a system of 0,1-linear equation into a pathwidth problem for weighted trees. Proposition 2. Given an instance (A, x) of BALANCED SYSTEM OF 0,1- LINEAR EQUATIONS , we construct an weighted octopus tree T (A, b) as follows: – T (A, b) is formed by a head, n legs with 2m nodes each, where n is the number of columns and m is the number of rows of A, plus an node adjacent only to the head. – Let N be the head node of the tree. The nodes of leg j are denoted S1,j , C1,j , S2,j , C2,j , . . . , Sm,j , Cm,j and appear in this order; S1,j is the one adjacent to the head. (The S-nodes play the same role as the minimal separators for octopus graphs.)

190

R. Mihai and I. Todinca

• • • •

the head N is of weight k, where k is an arbitrary number larger than 2b1 ; the node N ′ adjacent only to N is of weight b1 ; for each i, j, the node Ci,j is of weight b1 − bi + k; for each i, j, the node Si,j is of weight Ai,j .

We have pwd(T (A, b)) ≤ b1 +k −1 if and only if the system Ax = b has a 0,1-solution. Proof. Let H(A, b) the graph obtained by replacing, in T (A, b), each node by a clique module such that the number of vertices of the clique is exactly the weight of the node like in Observation 1. We have pwd(T (A, b)) = pwd(H(A, b)). Note that H(A, b) is chordal. The maximal cliques of H(A, b) correspond now to edges of T (A, b), i.e. the maximal cliques are exactly the unions of two clique modules corresponding to adjacent nodes of T . Let us use the same notations for the clique modules of H(A, b) as for the corresponding vertices of T (A, b). Although H(A, b) is not exactly an octopus graph, because the vertices of N appear in several maximal cliques, its structure is quite similar. In particular it has a clique tree such that the corresponding tree, denoted T˜, is an octopus. The head of the octopus tree is the clique N ∪N ′ . Each leg of T˜ corresponds to one of the n long paths of T (A, b). The cliques of leg j are, starting from the head, the cliques corresponding to the 2m edges of the jth path from N to the leaf Sn,j : N ∪ S1,j , S1,j ∪ C1,j , C1,j ∪ S2,j , S2,j ∪ C2,j , . . . , Sn,j ∪ Cn,j . Assume that pwd(H(A, b)) ≤ b1 + k − 1, we prove that the system Ax = b has a 0,1-solution. For this purpose we use the octopus chordal graph G(A, b) constructed in Proposition 1, and it is sufficient to show that pwd(G(A, b)) ≤ pwd(H(A, b)). Recall that a graph G1 is a minor of a graph G2 if G1 can be obtained from G2 by a series of edge deletions, vertex deletions and edge contractions (contracting an edge uv consists in replacing this edge by a single vertex, whose neighborhood is the union of the neighborhoods of u and of v). It is well-known that, if G1 is a minor of G2 , then the pathwidth of G1 is at most the pathwidth of G2 [28]. Claim. G(A, b) is a minor H(A, b). ′ be a subProof. (of the claim) In H(A, b), for each j, 1 ≤ j ≤ m, let Si−1,j set of Ci−1,j , of size Ai,j . Here C0,j denotes N , and we ensure that the sets , S0,2 , . . . , S0,j are pairwise disjoint, which is possible by our choice of k ≥ 2b1 = S 0,1 n ′ j=1 A1,j . Choose a matching between Si,j and Si−1,j , for each pair i, j, and contract each edge of the matching ; the set of vertices obtained by these contractions is denoted Ui,j . We claim that the new graph is exactly G(A, b). Note that the edges of all these matchings are pairwise disjoint. In the octopus clique tree T˜ of H(A, b), let us consider the jth leg C0,j ∪S1,j , S1,j ∪C1,j , C1,j ∪S2,j , S2,j ∪C2,j , . . . , Sn,j ∪Cn,j . The cliques of type Ci−1,j ∪ Si,j are smaller than the cliques Ci,j ∪ Si,j . In particular, after applying our contractions, in the new graph the leg has been transformed into the following sequence of maximal cliques N, U1,j ∪ C1,j , U2,j ∪ C2,j , . . . , Un,j ∪ Cn,j (N is not a maximal clique of the new graph but only of its restriction to the leg). It is sufficient to notice that the size of the clique Ui,j ∪ Ci,j is Ai,j + b1 − bi + k, and intersection of two consecutive cliques corresponds to sets Ui,j , of size Ai,j . The new graph is indeed G(A, b). ⊓ ⊔

Conversely, assume that the system Ax = b has a 0,1-solution x∗ , we give a folding of H(A, b) producing a path decomposition of width b1 + k − 1. Like in the proof of

PATHWIDTH is NP-Hard for Weighted Trees

191

Proposition 1, let R (resp. L) be the set of indices i, 1 ≤ j ≤ n such that x∗j = 1 (resp. x∗j = 0). We only discuss the folding to the right of the clique N ∪ N ′ , the left-hand side being symmetrical. To the right of N ∪ N ′ we put the cliques N ∪ S1,j for each j ∈ R. Then, for each i, 1 ≤ i ≤ m in increasing order, for each j ∈ R we append at the end the cliques Si,j ∪ Ci,j and Ci,j ∪ Si+1,j It remains to prove that the width of the corresponding folding is at most b1 + k − 1. The bags corresponding to cliques of type N ∪ S1,j wil be merged with all other separators S1,j ′ , j ′ ∈ R \ {j}, so they become of size b1 + k. Among the other bags, those that give the width of the folding are the bags corresponding to cliques of type Si,j ∪ Ci,j . Indeed the bags corresponding to Ci,j ∪ Si+1,j are merged in the folding with the same separators as the bag of Si,j ∪ Ci,j , and |Ci,j ∪ Si+1,j | ≤ |Si,j ∪ Ci,j |, thus after the folding the former bags remain smaller than the latter. To each bag of these bags Bi,j corresponding to Si,j ∪ Ci,j , we add all other separators Si′ ,j ′ with j ′ ∈ R \ {j} and i′ being either  i or i + 1. Thus, after the folding, the size of each of these bags is at most ⊓ ⊔ |Ci,j | + j ′ ∈R |Si,j |, which is precisely k + b1 .

Fig. 5. Weighted tree corresponding to the matrices from Figure 2

The construction of the octopus tree T (A, b) of Proposition 2 is clearly polynomial in the size of matrix A. By Theorem 2 we deduce: Theorem 4. The PATHWIDTH of weighted trees is NP-hard, even when the weights are polynomially bounded by the size of the tree.

192

R. Mihai and I. Todinca

As a byproduct, this also implies a result already proved in [17], namely that PATH WIDTH remains NP-hard for distance-hereditary graphs and circle graphs. A graph is distance-hereditary if and only if it can be obtained starting from a unique vertex and repeatedly adding a new pendant vertex (with only one new neighbour), or vertices which are true twins or false twins of already existing vertices [5]. Recall that two vertices x and y are false twins (true twins) if N (x) = N (y) (N (x) ∪ {x} = N (y) ∪ {y}. In particular all trees are distance-hereditary, and by adding true twins we obtain that the graphs obtained from weighted trees by replacing each vertex with a clique module are also distance-hereditary. Therefore Theorem 4 implies the NP-hardness of PATHWIDTH when restricted to distance hereditary graphs. Eventually, note that circle graphs contain all distance-hereditary graphs [17,5]. We can also prove that the MODIFIED CUTWIDTH problem is NP-hard on edgeweighted trees. The MODIFIED CUTWIDTH is a layout problem related to PATHWIDTH and CUTWIDTH. The proof of this result, omitted here due to space restrictions, is quite similar to the proofs of Theorems 3 and 4, see [20].

5

PATHWIDTH of Octopus Graphs: Polynomial Cases

Pathwidth can be computed in polynomial time for chordal graphs having all minimal separators of size one, which are exactly the block graphs [7]. Already for chordal graphs with all minimal separators of size two it becomes NP-hard to compute pathwidth [12]. We proved that is NP-hard to compute pathwidth for octopus graphs, which also have a very simple structure since each vertex appears in at most two maximal cliques. We will show how to compute pathwidth in polynomial time for a subclass of octopus graphs, namely octopus graphs with all separators of each leg of the same size. Let G be an octopus graph with, for each leg j, all separators of the same size sj . Let G1 be the graph obtained from G by removing from each leg all cliques except the maximum one. The clique tree of G1 is a star and all separators are disjoint, the graph G1 is a so-called primitive starlike graph. We can compute the pathwidth of G1 using the algorithm for primitive starlike graphs of Gustedt [12]. Lemma 5. There exists an ordering Q where the cliques of each leg appear consecutively such that the pathwidth of FillFolding(G, Q) is exactly the pathwidth of G. Proof. Let Q be an ordering for G such that the pathwidth of FillFolding(G, Q) is exactly the pathwidth of G. Let Kl,j be a clique of maximum size of the leg j. Let Q′ be the folding obtained by (1) removing all other cliques of leg j and then (2) replacing them contiguously to Kl,j , in the order of the leg (K1,j being the closest to the head). We claim that the new folding is also optimal. All cliques of leg j are merged with exactly the same separators as Kl,j , thus the size of their bags is upper bounded by the size of the bag corresponding to Kl,j . Let K be a clique which is not on the leg j. If K was merged before with one or more minimal separators of leg j, in the new folding it will be merged with at most one of these separators, so the corresponding bag does not increase. If K was not merged with a minimal separator of leg j, then in the new folding the bag of K remains unchanged. Therefore we do not modify the pathwidth of FillFolding(G, Q′ ).

PATHWIDTH is NP-Hard for Weighted Trees

193

Theorem 5. The pathwidth of an octopus graph with, for each leg, all separators of the same size can be computed in polynomial time. Proof. Let G such an octopus graph. First we construct the graph G1 by deleting from each leg of G all the cliques which are not maximum cliques. Let k be the maximum difference between the size of the head and the peripheral cliques. It follows that the graph G1 is a primitive starlike graph [12]. Using the polynomial time algorithm of Gustedt we compute the pathwidth of G1 . In order to construct an ordering Q for G such that the pathwidth of FillFolding(G, Q) is exactly the pathwidth of G, we place next to each peripheral clique Ki,j of G1 all the cliques from leg j, respecting the ordering of the leg. Clearly, when we have octopus graphs with a constant number of cliques the problem becomes polynomial, because the number of possible foldings is constant, too. It would be interesting to know if the PATHWIDTH problem on octopus graphs becomes polynomial when we restrict to octopuses with legs of constant size, or to octopuses with constant number of legs. In the latter case, using dynamic programming techniques, one can decide if the pathwidth is at most the size of the head of the octopus, minus one. More generally, if we know that there exists an optimal folding such that each leg is either completely to the left or completely to the right of the octopus, then we can also show using some results of [30] that the bags of a same leg should appear in the order of the leg. Then one can compute an optimal folding by dynamic programming, and the running time is of type O(P oly(n) · nl ), where l is the number of legs of the octopus.

6 Conclusion We have proved that the PATHWIDTH problem is NP-hard for weighted trees, even when restricted to polynomial weights, and also for the class of octopus graphs, which is a very restricted subset of chordal graphs. We have also shown that the M ODIFIED C UTWIDTH problem is NP-hard for weighted trees. Thus, despite the recent polynomial algorithms computing pathwidth for block graphs [7], biconvex bipartite graphs [26] or circular-arc graphs [30], the techniques for pathwidth computation do not seem extendable to large classes of graphs. A natural question is to search for good approximation algorithms for pathwidth. For chordal graphs and more generally graphs without long induced cycles, Nisse [22] proposed approximation algorithms whose approximation ratios do not depend of the size of the graph, but only on the pathwidth and the size of the longest induced cycle. It remains an open problem whether pathwidth can be approximated within a constant factor, even for the class of chordal graphs or the class of weighted trees. Another interesting question is the C ONNECTED SEARCH NUMBER on weighted trees. In the graph searching game, we say that a search strategy is connected if, at each step of the game, the clear area induces a connected subgraph [1]. The connected search number is the minimum number of searchers required to clean a graph using a connected strategy. This number can be computed in polynomial time for trees [1]. In the weighted version, we need w(v) searchers to guard a vertex v of weight w(v). The algorithm computing the connected search for unweighted trees cannot be straightforwardly

194

R. Mihai and I. Todinca

extended to the weighted case. We should also point out that our NP-hardness proof for PATHWIDTH (and thus node search number) of weighted trees is strongly based on the fact that, in our class of octopus trees, the optimal search strategy is not connected, thus the proof cannot be immediately adapted to the connected search number problem.

References 1. Barri`ere, L., Flocchini, P., Fraigniaud, P., Santoro, N.: Capture of an intruder by mobile agents. In: Proceedings 14th ACM Symposium on Parallel Algorithms and Architectures (SPAA), pp. 200–209. ACM, New York (2002) 2. Bienstock, D., Seymour, P.: Monotonicity in graph searching. J. Algorithms 12(2), 239–245 (1991) 3. Bodlaender, H.L., Kloks, T.: Efficient and constructive algorithms for the pathwidth and treewidth of graphs. J. Algorithms 21(2), 358–402 (1996) 4. Bodlaender, H.L., Kloks, T., Kratsch, D.: Treewidth and pathwidth of permutation graphs. SIAM J. on Discrete Math. 8, 606–616 (1995) 5. Brandst¨adt, A., Le, V.B., Spinrad, J.P.: Graph classes: a survey. Society for Industrial and Applied Mathematics, Philadelphia (1999) 6. Breisch, R.: An intuitive approach to speleotopology. Southwestern Cavers VI(5), 72–78 (1967) 7. Chou, H.-H., Ko, M.-T., Ho, C.-W., Chen, G.-H.: Node-searching problem on block graphs. Discrete Appl. Math. 156(1), 55–75 (2008) 8. Ellis, J., Markov, M.: Computing the vertex separation of unicyclic graphs 192, 123–161 (2004) 9. Ellis, J.A., Sudborough, I.H., Turner, J.: The vertex separation and search number of a graph 113, 50–79 (1994) 10. Golumbic, M.C.: Algorithmic Graph Theory and Perfect Graphs. Academic Press, New York (1980) 11. Gravano, A., Dur´an, G.: The intersection between some subclasses of circular-arc and circle graphs. Congressus Numerantium 159, 183–192 (2002) 12. Gustedt, J.: On the pathwidth of chordal graphs. Discrete Applied Mathematics 45(3), 233– 248 (2003) 13. Heggernes, P., Suchan, K., Todinca, I., Villanger, Y.: Characterizing minimal interval completions. In: Thomas, W., Weil, P. (eds.) STACS 2007. LNCS, vol. 4393, pp. 236–247. Springer, Heidelberg (2007) 14. Kinnersley, N.G.: The vertex separation number of a graph equals its path-width. Inf. Process. Lett. 42(6), 345–350 (1992) 15. Kirousis, M., Papadimitriou, C.H.: Searching and pebbling. Theor. Comput. Sci. 47(2), 205– 218 (1986) 16. Kloks, T.: Treewidth of circle graphs. Intern. J. Found. Comput. Sci. 7, 111–120 (1996) 17. Kloks, T., Bodlaender, H.L., M¨uller, H., Kratsch, D.: Computing treewidth and minimum fill-in: all you need are the minimal separators. In: Lengauer, T. (ed.) ESA 1993. LNCS, vol. 726, pp. 260–271. Springer, Heidelberg (1993) 18. LaPaugh, A.S.: Recontamination does not help to search a graph. Journal of the ACM 40, 224–245 (1993) 19. Megiddo, N., Hakimi, S.L., Garey, M.R., Johnson, D.S., Papadimitriou, C.H.: The complexity of searching a graph. Journal of the ACM 35, 18–44 (1988) 20. Mihai, R., Todinca, I.: Pathwidth is NP-hard for weighted trees. Research Report RR-200903, LIFO – Universit´e d’Orl´eans (2009)

PATHWIDTH is NP-Hard for Weighted Trees

195

21. Monien, B., Sudborough, I.: Min cut is np-complete for edge weighted treees. Theoretical Computer Science 58, 209–229 (1988) 22. Nisse, N.: Connected graph searching in chordal graphs. Discrete Appl. Math. (in press) 23. Parsons, T.: The search number of a connected graph. In: Proceedings of the 9th Southeastern Conference on Combinatorics, Graph Theory, and Computing 24. Parsons, T.: Pursuit-evasion in a graph. In: Theory and Applications of Graphs. Springer, Heidelberg (1976) 25. Peng, S.-L., Ho, C.-W., Hsu, T.-S., Ko, M.-T., Tang, C.Y.: Edge and node searching problems on trees. Theoretical Computer Science 240, 429–446 (2000) 26. Peng, S.-L., Yang, Y.-C.: On the treewidth and pathwidth of biconvex bipartite graphs. In: Cai, J.-Y., Cooper, S.B., Zhu, H. (eds.) TAMC 2007. LNCS, vol. 4484, pp. 244–255. Springer, Heidelberg (2007) 27. Petrov, N.N.: A problem of pursuit in the absence of information on the pursued. Differentsial nye Uravneniya 18, 1345–1352 (1982) 28. Robertson, N., Seymour, P.: Graph minors. I. Excluding a forest. Journal of Combinatorial Theory Series B 35, 39–61 (1983) 29. Skodinis, K.: Construction of linear tree-layouts which are optimal with respect to vertex separation in linear time 47, 40–59 (2003) 30. Suchan, K., Todinca, I.: Pathwidth of circular-arc graphs. In: Brandst¨adt, A., Kratsch, D., M¨uller, H. (eds.) WG 2007. LNCS, vol. 4769, pp. 258–269. Springer, Heidelberg (2007) 31. Sundaram, R., Sher Singh, K., Pandu Rangan, C.: Treewidth of circular-arc graphs. SIAM J. Discrete Math. 7, 647–655 (1994) 32. Yannakakis, M.: Computing the minimum fill-in is NP-complete. SIAM Journal on Algebraic and Discrete Methods 2, 77–79 (1981)

A Max-Margin Learning Algorithm with Additional Features Xinwang Liu1, Jianping Yin1, En Zhu1, Yubin Zhan1, Miaomiao Li2, and Changwang Zhang1 1

School of Computer Science, National University of Defense Technology, Changsha 410073, Hunan, China [email protected] 2 College of Information Engineering and Automation, Kunming University of Science and Technology, Kunming 650216, Yunnan, China [email protected] Abstract. This paper investigates the problem of learning classifiers from samples which have additional features and some of these additional features are absent due to noise or corruption of measurement. The common approach for handling missing features in discriminative models is to complete their unknown values with some methods firstly, and then use a standard classification procedure on the completed data. In this paper, an incremental Max-Margin Learning Algorithm is proposed to tackle with data which have additional features and some of these features are missing. We show how to use a maxmargin learning framework to classify the incomplete data directly without any completing of the missing features. Based on the geometric interpretation of the margin, we formulate an objective function which aims to maximize the margin of each sample in its own relevant subspace. In this formulation, we make use of the structural parameters trained from existing features and optimize the structural parameters trained from additional features only. A two-step iterative procedure for solving the objective function is proposed. By avoiding the preprocessing phase in which the data is completed, our algorithm could offer considerable computational saving. Moreover, by using structural parameters trained from existing features and training the additional absent features only, our algorithm can save much training time. We demonstrate our results on a large number of standard benchmarks from UCI and the results show that our algorithm can achieve better or comparable classification accuracy. Keywords: max margin framework, incremental missing features learning.

1 Introduction The task of learning classifiers with samples which have additional features and some of these features are absent due to measurement noise or corruption has been widely used in real world applications. For example, in fingerprint recognition, new samples may contain many additional features which can characterize fingerprints from other aspects. Another example is in Intrusion Detection field where many additional features are contained in new samples as the diverse means of attack. However, the set of X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 196–206, 2009. © Springer-Verlag Berlin Heidelberg 2009

A Max-Margin Learning Algorithm with Additional Features

197

additional features may vary among samples in real world tasks, i.e. some of additional features are missing. Common methods for classification with absent features assume that the features exist but their values are unknown. The approach usually taken is a two-step procedure known as imputation. First the values of missing features are filled during a preprocessing phase, and then a standard classification procedure is applied to the completed data [1-2]. Imputation makes sense when the features are known to exist, while their values are absent due to noise, especially the values of the features are missing at random (when the missing pattern is conditionally independent of the unobserved features given in the observations), or missing completely at random (when it is independent of both observed and unobserved measurements). In the common practice of imputation application, absent features in continuous are often filled with zero, with the average of all of the samples, or using the k nearest neighbors (kNN) of each sample to find a filled value of its missing features. Another imputation method builds probabilistic generative models of the features using maximum likelihood or algorithms such as expectation maximization (EM) to find the most probable completion [3]. Such model-based methods allow the designer to introduce prior knowledge about the distribution of features, and are extremely useful when such knowledge can be explicitly modeled [4]. These methods have been shown to work very well for missing at random (MAR) data settings, because they assume that the missing features are generated by the same model that generates the observed features. However, model-based approaches can be computationally expensive and time consuming, and require significant prior knowledge about the domain. What’s more, they may produce meaningless completions for non-existing features, which will likely decrease classification performance. Motivated by reference [5], we propose a Max-Margin Learning Algorithm to tackle with data which have additional features and some of these features are missing. In this algorithm, incomplete data can be classified directly without any completing the missing features using a max-margin learning framework. We formulate an objective function, based on the geometric interpretation of the margin, which aims to maximize the margin of each sample in its own relevant subspace. In this formulation, we make use of the structural parameters trained from existing features and only optimize the structural parameters trained from additional features. A two-step iterative procedure is proposed for solving the objective function. This paper is organized as follows. In the next section we will present Max-Margin formulation for incremental missing features. Section 3 will give the Max-Margin Learning Algorithm with incremental absent features. In section 4 we present the experiments comparing our approach to existing ones. We conclude with a discussion in Section 5.

2 Max-Margin Formulations for Incremental Missing Features Given

a

training

set

of

l samples

l

{( x , y )} i

i

i =1

with

input

data

xi ∈ \ n and yi ∈ {+1, −1} , we can train these samples with a Support Vector

198

X. Liu et al.

∑α y x , l

Machine (SVM) and get the structural parameters w and b , where w =

i

i i

i =1

and α i (1 ≤ i ≤ l ) is Lagrange multiplier corresponding to each constraint. As the tasks of detection, recognition and decision get further, new samples in classification may contain additional features and some of these additional features are absent due to measurement noise or corruption. Traditional methods to deal with this classification task are to discard the original samples containing n features and retrain a classifier with the new samples. Apparently, this treatment is time-consuming and it discards the information learned from the original samples. Motivated by reference [5], we propose an incremental Max-Margin Learning Algorithm to tackle with data which have additional features and some of these features are missing. We formulate an objective function, based on the geometric interpretation of the margin, which aims to maximize the margin of each sample in its own relevant subspace. In this formulation, we make use of the structural parameters trained from existing features and only optimize the structural parameters trained from additional features. We formulate the proposed problem as follows. Considering a training set of

l ′ samples ⎡⎣ xEi , x Ai ⎤⎦ , yi

{(

l′

)}

i =1

, where xEi

∈ \ n and xAi represent existing and addi-

th

tional features of the i sample, respectively. Let Ai denote the set of indices of additional features of xA and each i

xAi (1 ≤ i ≤ l ′ ) is characterized by a subset of features

from a full set A of size d . Each x Ai (1 ≤ i ≤ l ′ ) can therefore be viewed as embedded in the relevant subspace \

Ai

⊆ \ d . Each sample ⎡⎣ xEi , xAi ⎤⎦ also has a binary class

label yi ∈ {+1, −1} . Importantly, since samples share features, the classifier we learn should have parameters that are consistent across samples, even if those samples do not lie in the same subspace. We address the problem of finding an optimal classifier in the max-margin framework. In the classical SVM method of reference [10], we learn the structural parameter of a linear classifier w by maximizing the margin, defined as ρ

= min i yi ( wxi + b ) w .

Motivated by the ideal of incremental learning, we consider to learning the structural parameters from existing and additional features. Let wE and wA denote the structural parameters trained from already existing features and additional absent features, respectively. Consequently, the structural parameters trained from

{( ⎡⎣ x

⎤ Ei , x Ai ⎦ , yi

l′

)}

i =1

can be denoted as w =

[ wE , wA ] . Consider now learning

such a classifier in the presence of samples which have additional features and some of these features are absent. In this case, we can make use of the structural parameters trained from already existing features and train the additional features in the maxmargin framework only.

A Max-Margin Learning Algorithm with Additional Features

199

To address this problem we treat the margin of each sample in its own relevant subth

space. We define the sample margin ρ i ( wA ) for the i sample as

((

ρi ( wA ) = yi wE , w(Ai )

T

) (x

Ei

)

, x Ai + b

)

( w , w( ) )

(i )

Where wA is a vector obtained by taking the entries of



namely those for which the additional features (i )

is wA

=

i A

E

(1)

wA that are relevant for xAi ,

xAi has valid features. Its norm

wk2 . We now consider our new geometric margin to be the

k :k∈ Ai

ρ ( wA ) = min i ρi ( wA ) and get a new optimiza-

minimum over all sample margins,

tion problem for the additional missing-features case

T ⎛ ⎞ i yi ⎡ wE , w(A ) xEi , x Ai + b ⎤ ⎟ ⎜ ⎢⎣ ⎥⎦ max ⎜ min i ⎟ wA wE , w(Ai ) ⎜⎜ ⎟⎟ ⎝ ⎠

(

)(

)

(

(2)

)

For this optimization problem, since different margin terms are normalized by

( w , w( ) ) in Equation (2), the denominator can no longer be taken

different norms out

of

E

the

(i ) terms yi ⎡ wE , wA

⎣⎢

(

i A

minimization. T

) (x

Ei

In

, x Ai + b ⎤ ⎦⎥

addition,

( w , w( ) )

)

E

i A

each

of

is non-convex in

the

wA , which

makes it difficult to solve in a direct way. Section 3 will discuss how the geometric margin of Equation (2) can be optimized.

3 Max-Margin Algorithm with Incremental Additional Features Motivated by reference [5], we proposed a two-step iterative algorithm for solving Equation (2). Firstly, we introduce a scaling coefficient

(

si = wE , w(Ai )

)

( wE , wA )

and rewrite Equation (2) as

T ⎛ ⎞ yi ⎡ wE , w(Ai ) xEi , x Ai + b ⎤ ⎟ ⎜ ⎢⎣ ⎥⎦ max ⎜ min i ⎟= wA wE , w(Ai ) ⎜⎜ ⎟⎟ ⎝ ⎠

(

)(

)

(

)

⎛ ⎛ ⎡ ⎞⎞ (i ) T xEi , x Ai + b ⎤ ⎟ ⎟ ⎜ ⎜ yi ⎢⎣ wE , wA ⎥⎦ 1 max ⎜ min i ⎜ ⎟ ⎟ , si = wA si ⎜⎜ ( wE , wA ) ⎜⎜ ⎟⎟ ⎟⎟ ⎝ ⎠⎠ ⎝

(

)(

)

(

wE , w(Ai )

)

( wE , wA )

(3)

200

X. Liu et al.

Secondly, the following invariance is used: for every solution

([ w

E

, wA ] , b ) ,

there exists a solution that achieves the same target function value and with a margin that equals 1. This allows us to rewrite Equation (3) as a constrained optimization problem over si and wA as follows. max wA

1

( wE , wA )

T ⎛ ⎡ ⎞ (i ) xEi , x Ai + b ⎤ ⎟ ⎜ yi ⎢⎣ wE , wA ⎥⎦ ⎜ ⎟ ≥ 1,1 ≤ i ≤ l ′ si ⎜⎜ ⎟⎟ s.t. ⎝ ⎠

(

)(

si =

)

(4)

( w , w( ) ) ,1 ≤ i ≤ l′ E

i A

( wE , wA )

( wE , wA )

Equation (4) is equivalent to the problem of minimizing

2

with the

same constraints. After introducing the slack variables ξi , Equation (4) therefore translates into min wm , s

l′ 2 1 ( wE , wA ) + C ∑ ξi 2 i =1

⎛ ⎡ ⎞ (i ) T xEi , xAi + b ⎤ ⎟ ⎜ yi ⎢⎣ wE , wA ⎥⎦ ⎜ ⎟ ≥ 1 − ξi ,1 ≤ i ≤ l ′ si ⎜⎜ ⎟⎟ s.t. ⎝ ⎠

(

)(

si =

)

(5)

( w , w( ) ) ,1 ≤ i ≤ l′ E

i A

( wE , wA )

Equation (5) is not a quadratic problem. However, Equation (5) is a standard quadratic optimization problem over wA with constraints after si (1 ≤ i ≤ l ′ ) is given, and then new si (1 ≤ i ≤ l ′ ) is calculated using the resulting wA . To solve the quadratic program, we derive the dual problem for given si (1 ≤ i ≤ l ′ ) .

∑α

⎡ ⎛ yi ⎞ ⎤ 1 l′ l′ ⎛ y ⎞ 1 − ⎜ ⎟ wE xEi ⎥ − ∑∑ α i ⎜ i ⎟ x Ai , x Aj ⎢ α ∈\ i =1 ⎣ ⎝ si ⎠ ⎦ 2 i =1 j =1 ⎝ si ⎠ 0 ≤ α i ≤ C , i = 1," , l ′ l′

maxl′

s.t.

∑α ⎜ s l′

i

i =1

i

⎛ yi ⎞ ⎟ = 0, i = 1," , l ′ ⎝ i⎠

⎛ yj ⎜⎜ ⎝ sj

⎞ ⎟⎟ α j ⎠

(6)

A Max-Margin Learning Algorithm with Additional Features

201

Where the inner product i,i is taken only over features that are valid for both x Ai and x A j . Table 1 provides a pseudo code for the two-step optimization algorithm. Table 1. Pseudo code for the two-step iterative optimization algorithm

Iterative Optimization Algorithm (1) Initialization: Initialize si = 1, i = 1," , n 0

(2) Iteration (t )

a)

Solve Equation (6) for the current s and get the optimal wA

b)

Using si =

c)

If

( w , w( ) ) E

i A

( wE , wA )

to update s

(t )

(s ) t −1

(w ) t A

w(At ) − wA(t −1) ≤ ε1 or s ( t ) − s ( t −1) ≤ ε 2 , stop. Else go to a).

4 Experiment Results In this section, we compare the performance of our algorithm with that of zeroimputation (the values of absent features are filled with zero) and mean-imputation (the values of absent features are filled with the average of all of the samples) on 14 benchmark data sets which come from UCI Repository. Detailed information of these data sets is summarized in Table 2. Table 2. The information of data sets used in experiments Data set

#samples

#features

bupa glass ionospere iris monks musk pima promoter tic-tac-toc voting wdbc wine spambase waveform

345 146 351 100 124 475 768 106 958 435 569 130 4601 3345

6 9 34 4 6 166 8 57 9 16 30 13 57 40

#existing features 3 5 24 2 3 100 4 45 5 9 18 7 42 24

#additional features 3 4 10 2 3 66 4 12 4 7 12 6 15 16

#training samples 230 98 234 66 83 317 512 71 639 290 379 87 3068 2330

#test samples 115 48 117 34 41 158 256 35 319 145 190 43 1533 1115

202

X. Liu et al.

In Table 2, for Glass and Waveform data set, we only take two-class samples. In experiments, the linear kernel function is adopted. For each data set T with m samples and n features, a m × n random matrix M is generated in each experiment. For a given

missing

threshold

θ ( 0 < θ < 1)

,

Tij

is

set

to

NaN

if

M ij < θ (1 ≤ i ≤ m,1 ≤ j ≤ n ) .To overcome the influence of the random matrix to classification prediction, we get the statistical results by repeating each experiment 30 times. The performance of this algorithm is measured by means of prediction accuracy. The reported results are got by 3-fold cross validation. In zero-filling algorithm and mean-filling algorithm, the absent features are completed with zero and the mean of observed features, respectively. Then, a standard SVM classification algorithm is applied to the completed data. Table 3. Prediction accuracy of three algorithms Data set bupa glass ionospere iris monks musk pima promoter tic-tac-toc voting wdbc wine spambase waveform

our algorithm 57.5731±1.2633 66.1458±3.7539 82.1510±5.8258 99.0625±1.2170 54.7500±5.8559 58.5970±5.0868 74.0850±3.3262 62.9902±13.8341 53.5168±8.4123 95.5057±1.9797 91.4638±2.1704 91.5476±2.1318 84.4412±1.1707 94.1420±0.7427

zero-filling 56.8713±0.7272 61.0069±6.6696 81.2536±2.5666 97.9167±2.3152 54.1667±5.8926 54.1772±1.0077 75.4314±1.8304 60.9804±12.7562 41.8553±8.1801 95.8276±1.3666 91.1640±2.8884 90.7937±4.5905 85.0283±1.7815 94.0996±0.5444

mean-filling 60.5702±0.9386 59.8611±6.3791 80.9687±2.3525 98.8542±1.6205 55.3750±5.2510 54.7046±1.0988 75.1373±2.7241 60.4412±14.6031 41.9916±7.8059 95.5977±1.3504 92.4515±3.2891 89.6032±6.3846 85.1348±1.7421 94.1077±0.5481

The prediction accuracy of our algorithm, zero-filling algorithm and mean-filling algorithm is summarized in Tables 3, where the missing threshold θ = 0.6 . Each result is denoted as mean accuracy±stand error. Best method for each data set is marked with bold face. Form table 3, we see that in most cases our algorithm can outperform the other two algorithms in prediction accuracy and in other cases our algorithm can achieve comparable predication accuracy with the other two algorithms. In order to investigate the influence of missing ratio on the proposed algorithm and the other two algorithms, the value of missing ratio is varied from zero to one with increment 0.1. We plot curves of the prediction accuracy as the missing ratio varies with different additional features in Figure1, Figure2, Figure3 and Figure4, respectively. From Figure1, Figure2, Figure3 and Figure4, one can see that our algorithm shows higher prediction accuracy than that of the other two algorithms with the increment of missing ratio. We also can see that our algorithm demonstrates better performance as the number of additional features increases, which indicates that the performance of our algorithm is more robust than that of the other two algorithms.

A Max-Margin Learning Algorithm with Additional Features

203

Number of New Addition Featuresequals 5 on Waveform 92.45 MMLAIAF ZERO MEAN

Accuracy of Classification

92.4

92.35

92.3

92.25

92.2

0

0.1

0.2

0.3

0.4 0.5 Missing Ratio

0.6

0.7

0.8

0.9

Fig. 1. The accuracy with different missing ratio(#(additional feature)=5) Number of New Addition Featuresequals 10 on Waveform 92.3

MMLAIAF ZERO MEAN

Accuracy of Classification

92.25

92.2

92.15

92.1

92.05

92

0

0.1

0.2

0.3

0.4 0.5 Missing Ratio

0.6

0.7

0.8

0.9

Fig. 2. The accuracy with different missing ratio(#(additional feature)=10)

Another fact, which should be emphasized, is that our algorithm can reduce training time by making use of the structural parameters trained from existing features and only training the additional features in a max-margin framework. Moreover, by avoiding completing the data in the pre-processing phase, our algorithm could offer considerable computational saving.

204

X. Liu et al.

Number of New Addition Featuresequals 15 on Waveform 92.3 92.25

Accuracy of Classification

92.2 92.15 92.1 92.05 92 91.95 91.9 MMLAIAF ZERO MEAN

91.85

0

0.1

0.2

0.3

0.4 0.5 Missing Ratio

0.6

0.7

0.8

0.9

Fig. 3. The accuracy with different missing ratio(#(additional feature)=15) Number of New Addition Featuresequals 20 on Waveform 92.3

Accuracy of Classification

92.2

92.1

92

91.9

91.8

91.7

MMLAIAF ZERO MEAN 0

0.1

0.2

0.3

0.4 0.5 Missing Ratio

0.6

0.7

0.8

0.9

Fig. 4. The accuracy with different missing ratio(#(additional feature)=20)

5 Conclusions and Feature Work We propose an algorithm to learn classifiers from samples which have additional features and some of these additional features are absent due to measurement noise or corruption using a max-margin learning framework. We formulate an objective function, based on the geometric interpretation of the margin, which aims to maximize the margin of each sample in its own relevant subspace. In this formulation, we make use

A Max-Margin Learning Algorithm with Additional Features

205

of the structural parameters trained from existing features and only optimize the structural parameters trained from additional features. A two-step iterative procedure for solving the objective function is proposed. We conduct experiments to evaluate the performance of the proposed algorithm, zero-filling algorithm and mean-filling algorithm on a large number of UCI data sets. In general, our algorithm can achieve better prediction accuracy and reduce the training time. Our future work is to select a suitable kernel function for absent features and extend our algorithm to tackle with the problem that there are some features are absent in existing features.

Acknowledgement This work is supported by the National Natural Science Foundation of China (No.60603015), the Foundation for the Author of National Excellent Doctoral Dissertation (Grant No. 2007B4), the Scientific Research Fund of Hunan Provincial Education (the Foundation for the Author of Hunan Provincial Excellent Doctoral Dissertation ), and Scientific Research Fund of Hunan Provincial Education Department (07C718). We thank the reviewers for their constructive and insightful comments on the first submitted version of this paper.

References [1] Little, R.J.A., Rubin, D.B.: Statistical Analysis with Missing Data. Wiley, New York (1987) [2] Roth, P.: Missing data: A conceptual review for applied psychologists. Personnel Psychology 47(3), 537–560 (1994) [3] Ghahramani, Z., Jordan, M.I.: Supervised learning from incomplete data via an EM approach. In: Cowan, J.D., Tesauro, G., Alspector, J. (eds.) Advances in Neural Information Processing Systems, vol. 6, pp. 120–127. Morgan Kaufmann Publishers, Inc., San Francisco (1994) [4] Kapoor, A.: Learning Discriminative Models with Incomplete Data. PhD thesis, MIT Media Lab (Feburary 2006) [5] Chechik, G., Heitz, G., Elidan, G., Abbeel, P., Koller, D.: Max-margin Classification of Data with Absent Features. Journal of Machine Learning Research 9, 1–21 (2008) [6] Ong, C.S., Smola, A.J., Williamson, R.C.: Learning the Kernel with Hyperkernels. Journal of Machine Learning Research 6, 1043–1071 (2005) [7] Crammer, K., Keshet, J., Singer, Y.: Kernel design using boosting. In: Advances in Neural Information Processing Systems, vol. 15, pp. 537–544 (2002) [8] Ong, C.S., Smola, A.J.: Machine learning using hyperkernels. In: Proceedings of the International Conference on Machine Learning, pp. 568–575 (2003) [9] Liu, X., Zhang, G., Zhan, Y., Zhu, E.: An Incremental Feature Learning Algorithm Based on Least Square Support Vector Machine. In: Preparata, F.P., Wu, X., Yin, J. (eds.) FAW 2008. LNCS, vol. 5059, pp. 330–338. Springer, Heidelberg (2008) [10] Kazushi, I., Takemasa, Y.: Incremental support vector machines and their geometrical analyses. Neuro-computing, 2528–2533 (2007)

206

X. Liu et al.

[11] Wang, L., Yang, C., Feng, J.: On learning with dissimilarity functions. In: Proceedings of the 24th international conference on machine learning, pp. 991–998 (2007) [12] Dick, U., Haider, P., Scheffer, T.: Learning from Incomplete Data with Infinite Imputations. In: Proceedings of the 25th international conference on machine learning, pp. 232– 239 (2008) [13] Williams, D., Carin, L.: Analytical kernel ma-trix completion with incomplete multi-view data. In: Proceedings of the ICML Workshop on Learning With Multiple Views (2005) [14] Williams, D., Liao, X., Xue, Y., Carin, L.: Incomplete-data classification using logistic regression. In: Proceedings of the 22nd International Conference on Machine learning (2005)

DDoS Attack Detection Algorithm Using IP Address Features Jieren Cheng1,2, Jianping Yin1, Yun Liu1, Zhiping Cai1, and Min Li1 1

School of Computer, National University of Defense Technology, Changsha 410073, China 2 Department of mathematics, Xiangnan University, Chenzhou 423000, China [email protected]

Abstract. Distributed denial of service (DDoS) attack is one of the major threats to the current Internet. After analyzing the characteristics of DDoS attacks and the existing Algorithms to detect DDoS attacks, this paper proposes a novel detecting algorithm for DDoS attacks based on IP address features value (IAFV). IAFV is designed to reflect the essential DDoS attacks characteristics, such as the abrupt traffic change, flow dissymmetry, distributed source IP addresses and concentrated target IP addresses. IAFV time series can be used to characterize the essential change features of network flows. Furthermore, a trained support vector machine (SVM) classifier is applied to identify the DDoS attacks. The experimental results on the MIT data set show that our algorithm can detect DDoS attacks accurately and reduce the false alarm rate drastically. Keywords: network security; distributed denial of service attack; IP address features value; support vector machine.

1 Introduction DDoS (Distributed Denial of Service) attack is one of the main threats that the Internet is facing. The defense of DDoS attacks has become a hot research topic. The DDoS attack makes use of many different sources to send a lot of useless packets to the target in a short time, which will consume the target’s resource and make the target’s service unavailable. Among all the network attacks, the DDoS attack is easier to carry out, more harmful, hard to be traced, and difficult to prevent, so its threat is more serious. The detection of attacks is an important aspect of defense of DDoS attack, and the detection results can affect the overall performance of attack defense. Recently, the DDoS attacks are tending to use true source IP address to perform an attack [1], so it has become more difficult to distinguish between the normal network flow and the attack flow, which makes an early and accurate detection more difficult. In this paper, we review the existing methods of DDoS attacks, and propose a novel detecting algorithm called IAFV based on the knowledge that the DDoS attack flows have some features like the abrupt traffic change, flow dissymmetry, distributed source IP addresses and concentrated target IP addresses. Experiment results argues X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 207–215, 2009. © Springer-Verlag Berlin Heidelberg 2009

208

J. Cheng et al.

that our method can identify the abnormal phenomenon caused by DDoS attacks in the network flow and distinguish between a normal flow and an abnormal flow containing DDoS attacks efficiently.

2 Related Work In this paper, the existing primary methods for DDoS attack detection are classified into three categories as follows: base on abrupt traffic change, base on flow dissymmetry and base on distributed source IP addresses. The statistic characters of the abnormal traffic containing attack flow are different from the normal traffic. Cheng [2] proposed an attack detection method based on detecting periodicity of TCP flow by spectrum analysis. Manikopoulos [3] presented a method to calculate some statistical characters of normal flow and test flow respectively, then calculate their similarities by the calculated characters, and finally identify test flow by neural network classifier with the calculated similarities. Lakhina [4] proposed a method to detect the burst traffic of abnormal flow by calculating the traffic offset between the test flow and normal flow. Kulkarni [5] presume that the multiple sources send out lots of similar DDoS packets using the same tool and produce highly correlative flows, but the normal flows usually contain different type of packets arising randomly and won’t produce high correlative flow, then proposed an attack detection method using Kolmogorov complexity algorithm. Reference [6] and [7] presume that mostly attacks packets are TCP packets, detect attack by establishing network flow model using statistic characters of TCP packets, UDP packets and ICMP packets. However, attacker can organize different sources and simulate normal flow to send out attack flow to hide the statistic characters of attack flow by different time, different types of flow, different size of packets and different sending rate. Furthermore, the traffic offset can not distinguish DDoS attack flow from normal network congestion flow. Therefore, detecting DDoS attack flow effectively can not only depending on the abrupt traffic change. Gil and Poletto [8] presented a MULTOPS method to detect attack by monitoring the packets’ rate of up and down flow. Reference [9] and [10] proposed detecting SYN flooding based on the fact that the number of SYN packets and the number of FIN/RST packets has the same ratio under normal conditions. Abdelsayed [11] proposed a TOPS detect method based on the unbalance grade of network traffic. Actually, sometimes the rate of inflow and outflow of normal flow is not in balance, such as audio/video flow. What is more, attacker may use random cheating source IP address, or send out the same amount of SYN packets and FIN/RST packets, or simulate normal flow to send out attack packets by many attack sources without losing the power of attack. Anukool [12] proposed an active detection method based on distributed entropy of flow feature, the method uses an entropy to quantify the distributing characters by IP addresses including source IP address, source port, destination IP address and destination port, and can reflect the distributed feature of attack flow well. Peng [13] proposed a detection attack method by monitoring changes of the amount of source IP address, the method is based on the fact that a great number of new source IP address are produced while DDoS attack occurs, but the amount of source IP address

DDoS Attack Detection Algorithm Using IP Address Features

209

is normally steady. However, this type of detection methods is insensitive to the attack which has the characters of small amount of source IP address and big enough attack flow. To sum up the above arguments, DDoS attack detection schemes which are based on extracting an attack feature can not detect attack effectively. Although using many statistic characters to establish detection model may increase the detection rate and reduce false alarm rate, the progress of extracting varied characters is very complex and results in a marked increase in computional cost in [14]. Therefore, the paper focuses on proposing a DDoS attack features generation algorithm to reflect the essential DDoS attack characteristics and an effective method to detect attack.

3 Definition of IP Address Feature Value and Algorithm The attack flows of DDoS have some features like the abrupt traffic change, flow dissymmetry, distributed source IP addresses and concentrated target IP addresses, etc. In this paper, we propose the concept of IAFV (IP Address Feature Value) to reflect the four features of DDoS attack flow. Definition 1 (IP Address Feature Value). The network flow F in the certain time span T is given in the form of . For the ith packet p, ti is the time, Si is the source IP address and Di is the destination IP address. Classify all the packets by source IP and destination IP, which mean all packets in a certain class share the same source IP address and destination IP address. A class which is consisted of packets with a source IP Ai and a destination IP Aj is noted as SD(Ai, Aj). Carry out the following rules to the above mentioned classes: If there are two different destination IP address Aj, Ak, which makes class SD(Ai, Aj) and class SD(Ai, Ak) both nonempty, then remove all the class with a source IP address of Ai. If there is only one class SD(Ai, Aj) containing the packets with a destination IP address Aj, then remove all the classes with a destination IP address Aj. Assume that the remaining classes are SDS1, SDS2,…, SDSl, classify these classes by destination IP address, that is all the packets with the same destination IP address will be in the same class. The class made up of packets of the same destination IP address Aj is noted as SDD(Aj), these classes are SDD1, SDD2,…, SDDm, the IAFV(IP Address Features Value) is defined as: 1 m IAFVF = (∑ SIP( SDDi ) − m) (1) m i =1 in which SIP(SDDi) is the number of different source IP addresses in the class SDDi. In order to analyze the state features of the network flow F more efficiently and exclude the disturbance of a normal flow, the definition of IAFV classify the packets of F by source IP address and destination IP address. A DDoS attack is usually composed of several attack sources rather than a single one with the true source IP address, so the class with packets from the same source IP address Ai to different destinations belongs to a normal flow, thus the classes with a source IP address Ai can

210

J. Cheng et al.

be removed. After that, if there is a destination address Ak makes Ai and Aj in SD(Ai, Ak) and SD(Aj, Ak) the same, then the destination IP address Ak is not visited by multiple sources, which implies a normal flow, thus the class with packets going to the destination Ak can be removed. The above mentioned two steps can reflect the asymmetry of a DDoS attack flow as well as a decrease in the disturbance of the normal flow. DDoS attack is a kind of attack that sends useless packets to the attack target from many different sources in the hope of exhausting the resources of the target. This act can produce lots of new source IP addresses in a short time, which will lead to an abnormal increase of SIP(SDDi) for some classes of F, that is, the number of different sources to different destination will increase abnormally, causes the flow to be in a quite different state in a short time. The definition of IAFV sums up the different source IP addresses of each SDDi of F in a certain period, then subtract the number of different destination IP addresses m, and divide m at last. So IAFV can reflect the characteristics of a DDoS attack including the burst in the traffic volume, asymmetry of the flow, distributed source IP addresses and a concentrated destination IP address. The process of IAFV method is given in Algorithm 1. Algorithm 1. The IAFV method Input: an initial network flow data F, a sample interval Δt, a stopping criterion C, an arrival time of an IP Packet T, a source IP address S, a destination IP address D, an IP address class set SD, SDS and SDD, an IP address features IAFV. Output: IAFV time series which characterize the essential change features of F. processing procedure: 1. Initialization-related variables; 2. While (criterion C is not satisfied){ 3. Read the T, S and D of an IP packet from F; 4. if (T is not over the sample interval Δt){ 5. flag= New_SD(S,D,SD); // Judge whether the (S,D) is a new element of SD 6. Add_SD(flag,S,D, SD); // add a new element (S,D) to SD } 7. if (the arrival time of IP Packet exceeds the sample interval Δt){ 8. remove_SD(SD); // remove all the (S,D) with same S and different D from SD. 9. Add_SDS(SD,SDS); //add all the (S,D) of SD with different S and same D to SDS. 10. classify_SDS(SDS,SDD); // classify SDS by D and then add all the (S,D) of SDS to SDD. 11. m=Size(SDD); //count the number of the elements in SDD. 1 m 12. IAFV = (∑ SIP( SDDi ) − m) m i =1 //calculate IAFV of SDD 13. return IAFV ;}}

DDoS Attack Detection Algorithm Using IP Address Features

211

4 Detection Method Based on IAFV To raise the detection rate, decrease the false alarm rate, and enhance the adaptability of detection method, we propose a simple but robust scheme to detect DDoS attacks by extracting IAFV time series from normal flow and DDoS attack flow respectively, and use the SVM (Support Vector Machine) classifier to detect DDoS attacks. By sampling the network flow data F with sampling interval Δt, and calculating the IAFV of every sample, we can get the IAFV time series sample set A after sampling N times, A(N,Δt)={IAFVi,i=1,2,…,N}, N is the length of the time series. After Using IAFV time series to describe the state change features of network flow, detecting DDoS attack is equivalent to classifying IAFV time series virtually. SVM classifier can get the optimal solution base on the existing information under the condition that the sample size tends to be infinite or be limited. It can establish a mapping of a non-linear separable data sample in higher dimensional characteristic space by selecting the non-linear mapping function (kernel function), construct the optimal hyperplane, and transform a non-linear separable data sample into a linear separable data sample in the higher dimensional characteristic space. Furthermore, it can solve the problem of higher dimension, and its computational complexity is independent of the data sample dimension. Therefore we use the SVM classifier, which can be established by learning from the IAFV time series of the normal flow samples and DDoS attack flow samples, to classify the IAFV time series gotten by sampling network flows with sample interval ΔT, and identify DDoS attack. The SVM classifier [15] is

η = ∑ β i yi K (ϕi , ϕ ) + b M

(2)

i =1

in which η is the classification result for sample to be tested, βi is the Lagrange multipliers, yi is the type of classification, yi∈{-1,1}, K(ϕi,ϕ) is the kernel function, b is the deviation factor, ϕi is the classification training data sample, i=1,2,…,M,ϕ is the sample to be tested. The optimal hyperplane that the SVM classifier establishs in higher dimensional characteristic space is ⎛ ⎞ f (ϕ ) = sgn ⎜ ∑ βi yi K (ϕi , ϕ ) + b ⎟ ⎝ i∈SV ⎠

in which, b = 1 ∑ βi yi ( K (ϕr ,ϕi ) + K (ϕs , ϕi )) , 2 i∈SV

(3)

SV (Support Vector) is the support vector, ϕr is any positive support vector, ϕs is any negative support vector. The coefficient can be obtained by the quadratic programming: min W ( β ) = min β

β

M 1 M M β i β j yi y j K (ϕi , ϕ j ) − ∑ β i ∑∑ 2 i =1 j =1 i =1

(4)

212

J. Cheng et al.

∑β y M

s.t.

i

i

= 0, 0 ≤ β i ≤ C (i = 1, 2,..., M )

i =1

in which, β is a vector formed by Lagrange multipliers βi , C is the parameter to price the misclassification. Solving the coefficients of SVM classifier is a typical constrained quadratic optimization problem, there are lots of sophisticated algorithms for solving this kind of problem. In the paper we use the SVM algorithm supposed by J. Platt[16] that can support large-scale data training set. We compared the experimental results from various kernel functions such as linear, ploy, gauss and tanh. The results show that the linear kernel function is the best one. Then the optimal value of the parameter C is obtained through Cross-validation method.

5 Experiments The data sets in this paper use normal flow data sets in 1999 and DDoS flow data sets LLDoS2.0.2 in 2000 from MIT Lincoln lab [17]. In the experiment, the normal flow samples are from normal flow data sets, and the attack flow samples are from DDoS flow data sets. 70 IAFV of Normal Network Flow IAFV of DDoS Attack Flow

IAFV of Network Flow(0.01s)

IAFV of Network Flow(0.001s)

8

6

4

2

0 1.1

1.15 1.2 1.25 1.3 1.35 1.4 1.45 Time Sample Point of LLDoS 2.0.2 Network Flow

1.5

20 10 0

1

1.1 1.2 1.3 1.4 1.5 4 Time Sample Point of LLDoS 2.0.2 Network Flow x 10

Fig. 2. IAFV time series in 0.01s sample interval

400 300 200 100 1000 1500 Time Sample Point of LLDoS 2.0.2 Network Flow

2000

Fig. 3. IAFV time series in 0.1s sample interval

False Alarm Rate and Detection Rate• %•

IAFV of Network Flow(0.1s)

30

100 IAFV of Normal Network Flow IAFV of DDoS Attack Flow

500

0 500

40

x 10

700 600

50

5

Fig. 1. IAFV time series in 0.001s sample interval

IAFV of Normal Network Flow IAFV of DDoS Attack Flow

60

False Alarm Rate of IAFV Detection Rate of IAFV False Alarm Rate of EFD Detection Rate of EFD

80

60

40

20

0

1

2

3

4 5 6 7 8 Increase Multiple of Network Flow

9

10

Fig. 4. False alarm rate and detection rate of different algorithm

DDoS Attack Detection Algorithm Using IP Address Features

213

The sample interval Δt is set to 0.1s, 0.01s and 0.001s. The IAFV time series are computed by sampling LLDoS2.0.2 repeatedly. The comparisons of IAFV time series between normal flow and attack flow by sampling many times are showed as figure 1, figure 2 and figure 3, which illuminate that the IAFV time series are sensitive to attack flow while insensitive to normal flow. Therefore, IAFV can perfectly reflect the different state characteristics between normal flow and DDoS attack flow. We compared the method used in this paper with some previous related works. The proposed method in this paper is similar to Entropy of Feature Distributions method. Many group experiments are done, in which the sample interval Δt is 0.001s, the sample length is 40, and the parameter to price the misclassification C is 0.5. The training sample sets of IAFV and EFD are respectively gotten by sampling the normal flow and attack flow and computing the time series of IAFV and EFD. The rate of the normal network flow is increased from 1 to 10, and we get test normal flow FTi(i=1,2,…,10) of the 10 groups correspondingly. By mixing FTi(i=1,2,…,10) with DDoS attack flow, the test attack flow FFi(i=1,2,…,10) of the 10 groups in the experiment are gotten. Therefore, we can get test flow (FTi,FFi) i=1,2,…,10 of many groups of the experiment. By sampling and computing IAFV and EFD time series of 10 groups respectively we can get 10 groups of test IAFV and EFD. The detection results are shown in Figure 4.The detection rate of IAFV is reduced with the increase of the normal background network flow, as showed in figure 4, from 99.9% to 97.4%. The average detection rate of 10 groups experiment result is 96.5%. This result demonstrates that IAFV can accurately identify abnormal flows containing DDoS attack and it is sensitive to abnormal network flows caused by attack flows, which have the advantage of detecting the attacks as soon as possible. The main reasons for false negative are from two aspects: firstly, due to the increase of normal flow, the whole network flows take on normal state, which disturbs the extract of varied features about network state caused by attack flows and reduces the detection rate. Secondly, the network state shift caused by network random noise results in false negative. The false alarm rate of IAFV gradually increases with the increment of normal flows, from 0.0% to 1.8%. The average false alarm rate of 10 groups is 1.3%. The result indicates that IAFV can accurately identify normal flow and won’t lead to high false positive because of the increment of normal flow. The main reasons for false positive are from two aspects: firstly, due to the increment of network flow, the network state shift results in false positive. Secondly, the network state shift caused by network random noise results in false positive. As illustrated in figure 4, with the increment of normal background network flows, the detection rate of EFD gradually decreases from 99.2% to 94.9%, the false alarm rate increases from 0.0% to 28.4%, the average detection rate of 10 groups is 96.3% and the average false alarm rate is 16.6%. EFD is designed to extract distributed IP addresses features of DDoS attack using four-dimensional characteristic vector, but our algorithm IAFV is designed to extract four inherent features of DDoS attack using one-dimensional characteristic vector. By comparison, we can draw that IAFV can detect the DDoS attack more effectively than EFD. The above experiments demonstrate that IAFV can accurately detect DDoS attacks and effectively distinguish attack flows from normal flows. It is an effective method to detect DDoS attack which can be deployed on attack source, media and terminal equipments.

214

J. Cheng et al.

6 Conclusions and Future Work In this paper we analysis the existing detection methods of DDoS. Considering the characteristics of DDoS attack flow such as abrupt traffic change, flow dissymmetry, distributed source IP addresses and concentrated target IP addresses, we propose the concept of IAFV and a detect method for DDoS attack based on IAFV. In this method the characteristic of network flow states varying with the time is described by IAFV time series. Detecting DDoS attack is equivalent to classifying IAFV time series. By learning from the normal flow samples and DDoS attack flow samples, a SVM classifier can be established, and then we can use it to classify network flows and identify DDoS attack. The experiments show that our method can identify the abnormal flow containing DDoS attacks and normal network flows effectively, increase detection rate, and reduce the false alarm rate. How to set effective parameters in various real world applications adaptively is a problem we will investigate in the future. Acknowledgments. This work is supported by National Science Foundation of China (60603062), Scientific Research Fund of Hunan Provincial Education Department (07C718), Science Foundation of Hunan Provincial (06JJ3035), and Application of Innovation Plan Fund of the Ministry of Public Security(2007YYCXHNST072).

References 1. Handley, M.: DoS-resistant Internet subgroup report. Internet Architecture WG. Tech. Rep. (2005), http://www.communications.net/object/download/1543/ doc/mjh-dos-summary.pdf 2. Cheng, C.M., Kung, H.T., Tan, K.S.: Use of spectral analysis in defense against DoS attacks. In: Proceedings of IEEE GLOBECOM 2002, pp. 2143–2148 (2002) 3. Manikopoulos, C., Papavassiliou, S.: Network intrusion and fault detection: A statistical anomaly approach. IEEE Commun. Mag., 76–82 (2002) 4. Lakhina, A., Crovella, M., Diot, C.: Diagnosing Network-Wide Traffic Anomalies. In: Proceedings of ACM SIGCOMM, Portland, Oregon, USA (August 2004) 5. Kulkarni, A., Bush, S., Evans, S.: Detecting distributed denial-of-service attacks using Kolmogorov complexity metrics. GE Research & Development Center. Tech. Rep: Schectades, New York (2001) 6. Dongqing, Z., Haifeng, Z., Shaowu, Z., et al.: A DDoS Attack Detection Method Based on Hidden Markov Model. Journal of Computer Research and Development 42(9), 1594– 1599 (2005) 7. Sanguk, N., Gihyun, J., Kyunghee, C., et al.: Compiling network traffic into rules using soft computing methods for the detection of flooding attacks. Applied Soft Computing, 1200–1210 (2008) 8. Gil, T.M., Poletto, M.: MULTOPS: A data-structure for bandwidth attack detection. In: Proceedings of the 10th USENIX Security Symposium (2001) 9. Wang, H., Zhang, D., Shin, K.G., Detecting, S.Y.N.: flooding attacks. In: Proceedings of IEEE INFOCOM, pp. 1530–1539 (2002) 10. Keunsoo, L., Juhyun, K., Ki, H.K., et al.: DDoS attack detection method using cluster analysis. Expert Systems with Applications, 1659–1665 (2008)

DDoS Attack Detection Algorithm Using IP Address Features

215

11. Abdelsayed, S., Glimsholt, D., Leckie, C., et al.: An efficient filter for denial-of service bandwidth attacks. In: Proceedings of the 46th IEEE GLOBECOM, pp. 1353–1357 (2003) 12. Lakhina, A., Crovella, M., Diot, C.: Mining Anomalies Using Traffic Feature Distributions. In: Proceedings of ACM SIGCOMM, Philadelphia, Pennsylvania, USA (2005) 13. Peng, T., Leckie, C., Kotagiri, R.: Proactively detecting distributed denial of service attacks using source ip address monitoring. In: Proceedings of the Third International IFIPTC6 Networking Conference, pp. 771–782 (2004) 14. Kejie, L., Dapeng, W., Jieyan, F., et al.: Robust and efficient detection of DDoS attacks for large-scale internet. Computer Networks, 5036–5056 (2007) 15. Burger, C.: A tutorial on support vector machines for pattern recognition. Data Mining and Knowledge Discovery 2(2), 121–167 (1998) 16. Platt, J.: Sequential minimal optimization: A fast algorithm for training support vector machines. Microsoft Research, Tech Rep: MSR-TR-98-14 (1998) 17. http://www.ll.mit.edu/mission/communications/ist/corpora/ ideval/data/index.html

Learning with Sequential Minimal Transductive Support Vector Machine⋆ Xinjun Peng1,2 and Yifei Wang3 1

2

Department of Mathematics, Shanghai Normal University 200234, P.R. China Scientific Computing Key Laboratory of Shanghai Universities 200234, P.R. China 3 Department of Mathematics, Shanghai University 200444, P.R. China [email protected], yifei [email protected]

Abstract. While transductive support vector machine (TSVM) utilizes the information carried by the unlabeled samples for classification and acquires better classification performance than support vector machine (SVM), the number of positive samples must be appointed before training and it is not changed during the training phase. In this paper, a sequential minimal transductive support vector machine (SMTSVM) is discussed to overcome the deficiency in TSVM. It solves the problem of estimation the penalty value after changing a temporary label by introducing the sequential minimal way. The experimental results show that SMTSVM is very promising. Keywords: statistical learning; support vector machine; transductive inference; sequential minimization.

1

Introduction

Support vector machine (SVM), proposed by Vapnik and co-workers[2,10,11], has become one of the most popular methods in machine learning during the last years. Compared with other methods, such as neural networks (NN) [9], SVM brings along some a bunch of advantages. First, it is based on a quadratic programming (QP) problem, which assures that once a solution has been reached, it is the unique (global) solution. Second, its solution is a sparse model, which causes to derive good generalization. Third, SVM implements the structural risk minimization (SRM) principle, not empirical risk minimization (ERM) principle, that minimizes the upper bound of the generalization error. Fourth, it has a clear geometric intuition on the classification task. Due to the above nice merits, SVM has been successfully used in a number of applications [8], and extended to solve nonlinear regression problems [3]. Many studies on SVM try to optimize the classification performance over labeled samples. However, in many real-world cases, it is impossible to classify all training samples, or only a particular set of samples is needed to determine ⋆

Supported by the Shanghai Leading Academic Discipline Project (No. S30405), and the NSF of Shanghai Normal University (No. SK200937).

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 216–227, 2009. c Springer-Verlag Berlin Heidelberg 2009 

Learning with Sequential Minimal Transductive Support Vector Machine

217

labels. This idea leads to the concept of transductive inference. Transductive support vector machine (TSVM)[5] is an SVM combining with the transductive learning procedure. TSVM utilizes the information of the labeled samples and unlabeled samples for classification and predicts the optimal labels for them. TSVM uses the pair-wise exchanging criterion to update the labels of unlabeled test samples. However, the number of positive unlabeled samples Np has to be specified at the beginning of the learning. Nonetheless, in general cases it is often difficult to estimate Np correctly. In TSVM, the fraction of labeled positive examples is used to estimate Np . This may lead to a fairly large estimating error, especially when the number of labeled samples is small. When the estimated Np has a big deviation from the actual number of the positive samples, the performance of TSVM decreases significantly. Chen et al.[1] discussed a progressive transductive support vector machine (PTSVM) to overcome the deficiency of TSVM. In PTSVM the unlabeled samples are labeled and modified iteratively with the pairwise labeling and dynamical adjusting, till a final solution is progressively reached. However, in PTSVM the regularization factors of slack variables for the temporary test samples are the same in the iteration process. Due to this restriction, PTSVM is not suitable for the case that the test set is imbalanced. Wang et al.[12] proposed a method to train TSVM with the proper number of positive samples (PPTSVM). PPTSVM uses the individually judging and changing criterion instead of the pair-wise exchanging one to minimize the objective function. Notice that in each iteration PPTSVM only adjusts at most one temporary label of the test samples which leads to the low learning speed. Besides, the estimation of penalty in PPTSVM is not true. In this paper, we proposed a sequential minimal transductive support vector machine (SMTSVM) to overcome the deficiency shown in PPTSVM. SMTSVM estimates the slack variable of label-adjusted unlabel test sample by introducing a sequential minimal approach[4]. Theoretical analysis shows that the approximated slack variable of the label-adjusted test sample can not be represented simply by the initial slack variable. After estimating the new empirical penalty value, SMTSVM compares the two penalty values and adjusts the label of test sample if necessary. Experimental results show that SMTSVM is very promising for learning labels of the test samples and finding a suitable hyperplane. The remaining of this paper is organized as follows: Section 2 briefly dwells on TSVM and some other TSVM classifiers. The sequential minimal transductive support vector machine with the theory analysis are discussed in Section 3. Section 4 compares the performances of PPTSVM and SMTSVM with experimental results. Finally, we summarize our work in the last Section.

2

Review of TSVMs

The transductive learning in pattern recognition is completely different from the inductive learning. In many machine learning applications, obtaining classification labels is expensive, while large quantities of unlabeled samples are readily available. Because the quantity of the labeled samples is relatively small, they

218

X. Peng and Y. Wang

can not describe the global data distribution well. This possibly leads to a classifier with poor generalization performance. Considering the fact that unlabeled samples are significantly easier to be obtained than labeled ones, one would like the learning algorithm to take as much advantage of unlabeled samples as possible. By including the unlabeled samples in training, semi-supervised learning can be used to perform transductive learning, where the labeled samples and unlabeled working data are given, then the decision function is constructed based on all available samples. In transductive learning, the learning process uses a small number of labeled samples and a large number of unlabeled samples, the latter often provide enough information about the distribution of whole sample space. This simpler task can result in theoretically better bounds on the generalization error, thus reducing the amount of required labeled data for good generalization. 2.1

Original TSVM

TSVM is an application of transductive learning theory of SVM [5]. The principle of TSVM can be described as follows. Detailed descriptions and proofs can be found in Ref.[5]. Given a set of independent, identically distribution labeled samples (x1 , y1 ), . . . , (xn , yn ), xi ∈ Rm , yi ∈ {−1, 1}, i = 1, . . . , n,

(1)

and another set of unlabeled samples from the same distribution x∗n+1 , x∗n+2 , . . . , x∗l .

(2)

TSVM labels the test samples according to the side of the hyper-plane that they lie on. The decision formula is given by H(w, b) : f (x) = wT x + b.

(3)

According to the principle of transductive learning, the optimization problem of TSVM [6] is given by min

l n   1 T w w+C ξj∗ ξi + C ∗ 2 j=n+1 i=1

s.t. yi (wT xi + b) ≥ 1 − ξi , ξi ≥ 0, yj∗ (wT x∗j

+ b) ≥ 1 −

ξj∗ ,

ξj∗

(4)

≥ 0,

where ξi ’s and ξj∗ ’s are the slack variables of training and test samples, respectively; C and C ∗ are the user-defined parameters, in which C ∗ ≤ C is called the effect factor of unlabeled test samples; yj∗ ’s are the temporary labels of unlabeled test samples. TSVM can be roughly listed as following steps: (1) Specify C and C ∗ < C, run an initial SVM with all labeled samples and produce an initial classifier. Specify the number of the positive-labeled samples

Learning with Sequential Minimal Transductive Support Vector Machine

219

Np in the unlabeled samples according to the proportion of positive samples in the training set. (2) Classify the test samples with the initial classifier. Label Np test samples ∗ and with the largest decision values as positive and others negative. Specify C+ ∗ C− with small values. (3) Retrain SVM over all samples. For the newly yielded classifier, exchange labels of one pair of different-labeled unlabeled samples using a certain rule to make the objective function in (4) decrease as much as possible. This step is repeated until no pair of samples satisfying the exchanging condition is found. ∗ ∗ ∗ ∗ (4) Increase C+ and C− slightly and return to Step 3 until C+ or C− is greater ∗ than C . The label pair-wise exchanging criterion in Step 3 ensures that the objective function of the optimization problem decreases after the changing of labels and thus an optimal solution is obtained. The successive updating of the temporary effect factor in Step 4 shows the influence of unlabeled samples increase gradually. An obvious deficiency in TSVM is that the number of positive samples Np in the test sample set has to be pre-specified according to the proportion of positive labeled samples, and it is not changed during the entire training process. However, it is easy to know that the pre-specified Np often disagrees with the real number of positive samples in the test set, which causes TSVM to obtain a bad separating hyperplane. 2.2

Some Related Algorithms

As TSVM can not give the proper Np for the test set, some improved algorithms have been discussed recently. In 2003, Chen et al.[1] developed a modified TSVM algorithm called the progressive transductive support vector machine (PTSVM). In PTSVM, the number of the positive unlabeled samples is not pre-specified using the proposition of positive labeled samples. In each iteration, one or two unlabeled samples that can be labeled with the strongest confidences are chosen and labeled, and all improper labels of the test samples are canceled. However, the regularization factors of the slack variables for the temporary test samples in each iteration are the same, which is not suitable for imbalanced cases. Liu and Huang [7] proposed a fuzzy TSVM (FTSVM) algorithm to solve problems of the web classification. FTSVM multiplies the slack variables oftest samples by membership factors that represent the degree of importance of test samples in iterations. While FTSVM performs well in the web classification, it is hard to compute the membership value for each test sample. More recently, Wang et al.[12] presented a new algorithm to train TSVM with the proper number of positive samples (PPTSVM). In PPTSVM the number of positive samples is allowed to be updated to a proper value which effectively overcomes the problem of fixed the number of positive samples in TSVM with pair-wise exchanging criterion. PPTSVM uses the individually judging and changing criterion to judge whether a test sample lies on the error side and its label should be changed.

220

X. Peng and Y. Wang

  Specially, let △ = I + ξi∗ − I − ξj∗ . If a test sample x∗i is labeled positive and its slack variable ξi∗ satisfies Np − 1 △ + max{2 − ξi∗ , 0}, Nn + 1 Nn + 1

ξi∗ >

(5)

or if a test sample x∗j is labeled negative and its slack variable ξj∗ satisfies ξj∗ >

Nn − 1 △ + max{2 − ξj∗ , 0}, Np + 1 Np + 1

(6)

then the label change of this test sample decreases the objective function. That is, the slack variable of a test sample x∗i after changing its temporary label is approximated by max{2 − ξi∗ , 0}, where ξi∗ is the slack variable of x∗i before changing its label. That is, for a decision function f (x), the slack variable ξi∗ of a sample x∗i is computed as ξi∗ = max{0, 1 − yi∗ f (x∗i )},

(7)

then the slack variable of x∗i after changing its temporary label is ηi∗ = max{0, 1 − (−yi∗ )f (x∗i )} = max{0, 2 − ξi∗ }.

(8)

Notice that in TSVM the decision function f (x) can be represented as f (x) =

n 

l 

αi yi K(xi , x) +

αi yi∗ K(x∗i , x) + b,

(9)

i=n+1

i=1

the representation of f (x) is changed if one changes the label of x∗i as (−yi∗ ), which means that the new slack variable ηi∗ can not be represented simply max{2 − ξi∗ , 0}. That is, the individually judging and changing criterion (5) or (6) does not reflect the empirical risk of changing one temporary label. In the next section, we will discuss a sequential minimal transductive support vector machine (SMTSVM) to overcome the deficiency shown in the PPTSVM.

3

Sequential Minimal TSVM (SMTSVM)

In SMTSVM, we use the following penalty item for describing test samples C



l  j=n+1

∗ ξj∗ = C+

 i∈I +

∗ ξi∗ + C−



ξj∗ ,

(10)

j∈I −

where I + and I − are the index set of temporary positive and negative test ∗ ∗ and C− are the regularization factors or the slack variables of samples, C+ temporary positive and negative test samples, which are related to the numbers of temporary positive and negative samples. To avoid the imbalanced case in the

Learning with Sequential Minimal Transductive Support Vector Machine

221

∗ ∗ test sample set, we define C+ and C− as in inverse proportion to the numbers of temporary positive and negative samples, respectively ∗ ∗ C+ /Nn = C− /Np = a,

(11)

where Np and Nn are the numbers of temporary positive and negative samples, and a is a positive constant, such as a = 1E − 4. As mentioned above, the main deficiency of PPTSVM is that the representation of slack variable does not reflect the changing of empirical risk of the test sample. In fact, if it changes the temporary label of one test sample, its Lagrange coefficient αi and some other Lagrange coefficients will be updated. Thus we have to update all αi ’s in order to estimate its slack variable. Without loss of generality, assuming that the temporary label of x∗1 is changed as (−y1∗ ), and two Lagrange coefficients are updated, that is, α1 and another Lagrange coefficient α2 . To calculate the new values of two coefficients, we notice that values should be on a line in order to satisfy the linear constraint n the new l ∗ α y + i=1 i i i=n+1 αi yi = 0, specially, α1 and α2 should satisfy old ∗ − α1 y1∗ + α2 y2 = Constant = αold 1 y1 + α2 y2 ,

(12)

∗ ∗ ∗ ∗ or C). (C− ) and 0 ≤ α2 ≤ C+ (C− where α1 and α2 should satisfy 0 ≤ α1 ≤ C+ Denote Kij = K(xi , xj ), and define

vi =

l 

yj αj Kij = f (xi ) −

2 

yj αj Kij − b, i = 1, 2,

(13)

j=1

j=3

here we omit the superscript (∗) for all test samples for brevity. Consider the objective function of α1 and α2 : 1 1 W (α1 , α2 ) = α1 + α2 − K11 α21 − K22 α22 2 2 −(−y1 )y2 K12 α1 α2 − (−y1 )α1 v1 − y2 α2 v2 + constant.

(14)

According to Eq.(12), we have old − sα1 + α2 = sαold 1 + α2 = γ,

(15)

where s = y1 y2 . Substitute Eq.(15) into Eq.(14) leads to 1 1 W (α1 ) = γ + α1 + sα1 − K11 α21 − K22 (γ + sα1 )2 2 2 +sK12 α1 (γ + sα1 ) + y1 v1 α1 − y2 v2 (γ + sα1 ) + constant.

(16)

The extreme point of α1 satisfies ∂W (α1 ) = 1 + s − γsK22 + γsK12 + y1 v1 − y2 v2 s ∂α1 −K11 α1 − K22 α1 + 2K12 α1 = 0.

(17)

222

X. Peng and Y. Wang

Then (K11 + K22 − 2K12 )αnew = 1 + s + y1 (v1 − v2 ) + sγ(K12 − K22 ) 1 = y1 [y1 + y2 + v1 − v2 + γy2 (K12 − K22 )]. (18) That is, αnew Ky1 = y1 + y2 + y2 (sα1 + α2 )(K12 − K22 ) + f (x1 ) − f (x2 ) 1

−y1 α1 K11 − y2 α2 K12 + y1 α1 K12 + y2 α2 K22 = y1 + y2 + (y1 α1 + y2 α2 )(K12 − K22 ) + f (x1 ) − f (x2 )

−y1 α1 K11 − y2 α2 K12 + y1 α1 K12 + y2 α2 K22 = y1 + y2 + f (x1 ) − f (x2 ) − y1 α1 K,

(19)

where K = K11 + K22 − 2K12 = ||ϕ(x1 ) − ϕ(x2 )||2 . Eq.(19) means that αnew = −αold 1 1 +

1 + s + y1 (f (x1 ) − f (x2 )) . K

(20)

On the other hand, according to Eq.(12) we have αnew = αold 2 2 +

1 + s + y2 (f (x1 ) − f (x2 )) . K

(21)

∗ ∗ Notice that αnew and αnew should be bounded by zero and C+ (C− or C), if 1 2 not, we define ⎧ < 0, if αnew ⎨ 0, 1 new,bound ∗ ∗ ∗ ∗ > C+ /C− , α1 (22) = C+ /C− , if αnew 1 ⎩ new α1 , otherwise,

and αnew,bound 2

⎧ ⎨ 0, ∗ ∗ /C− , = C/C+ ⎩ new α2 ,

if αnew < 0, 2 ∗ ∗ > C/C+ /C− , if αnew 2 otherwise.

(23)

Using αnew,bound and αnew,bound , and all αi ’s, i = 1, 2, we derive a novel sep1 2 arating decision function. Notice that this hyperplane is an approximated one since, if changes a temporary label of the test samples, there exists more than two Lagrange coefficients are updated in fact, and in our approach only two coefficients are considered to be updated. According to the novel decision function, we can simply calculate all slack variables and determine if we need to change the temporary label of the test sample x1 or not. Another very important problem in the process of adjusting the two coefficients is how, given the test sample x1 and its temporary y1 , to determine another sample. In this work, we use a simple way to choose x2 : Select the nearest sample of x1 in feature space, i.e., select x2 such that K is the smallest one for all samples. In fact, this method is reasonable since, if changes the temporary

Learning with Sequential Minimal Transductive Support Vector Machine

223

label of x1 , the impact on the Lagrange coefficient of the nearest sample x2 is the more possible largest in all training and test samples. We write the major steps of SMTSVM as follows: (1) Specify the parameters C and C ∗ , run the initial SVM with all labeled samples and derive an initial classifier. Pre-specify the number of the positive samples Np in the test sample set according to the proportion of positive samples in the training set, and label the test samples using the classifier. ∗ ∗ = aNp , where a is a small positive constant = aNn and C− (2) Define C+ ∗ ∗ ∗ such as a = 0.0001. If C+ < C or C− < C ∗ then repeat Steps 3-6. (3) Run SVM with training and test samples, if there exist some test samples whose slack variables are nonzero, select a test sample with the largest slack variable value and its nearest sample. (4) Update the Lagrange coefficients of the two selected samples using Eqs.(20) and (21), and snip them according to Eqs.(22) and (23) if they are in the corresponding regions. (5) Calculate the slack variables for all samples updated to the  according ∗ ∗ ∗ + ξ decision function and compute the empirical risk C i ξi + C+ + i I I − ξi . (6) If the updated empirical risk is smaller than the old one, change the ∗ ∗ ∗ = with C+ and C− temporary label of the selected test sample, and update C+ ∗ aNn and C− = aNp , where Np and Nn are the current numbers of positive and negative samples in the test set. Go to Step 3. (7) Update the value of a as a := 2a and go to Step 3. (8) Output the labels of the test samples and stop. Similar to PPTSVM, SMTSVM changes the temporary label of the selected test sample in each iteration. However, the difference between them is that SMTSVM gives a suitable way to approximate the decision function, while PPTSVM only uses an over-simple way to estimate the slack variable of the selected test sample. The experiments in next section show that SMTSVM is a better approach to determine the labels of test samples.

4

Numerical Simulations

In order to test the performances of proposed SMTSVM and PPTSVM algorithms for transductive pattern recognition tasks, we test two groups of trails. The first one is an artificial transductive classification problem, and another one is a real benchmark transductive classification problem. 4.1

Artificial Data

The artificial samples consist of some two-dimensional data generated randomly, as shown in Figure 1. The positive and negative samples are respectively represented by ”+” and ”×”, and the training samples are symbolized as ””. It is obviously that the distribution of the training samples can not represent that of the whole samples.

224

X. Peng and Y. Wang

Figure 2 shows the classification result of SVM. Due to the fact that the distribution of training samples is different from that of the whole samples, the separating hyperplane is far from the real one. Figure 3 shows the classification result of PPTSVM, in which the initial number of positive samples is appointed by the initial classifier. The result indicates that the separating hyperplane derive better accuracy than that of SVM. However, there still exists some test examples are mislabeled using PPTSVM. Figure 4 gives the result of proposed SMTSVM. It has been seen that this method derives the best result among these algorithms: The hyperplane is near to the optimal one when knowing the labels of all test

Positive

Negative

Fig. 1. The 2-dimensional artificial samples. The positive and negative samples are respectively represented by ”+” and ”×”, and the training samples are symbolized as ””.

Positive

Negative

Fig. 2. The separating hyperplane of SVM

Learning with Sequential Minimal Transductive Support Vector Machine

225

Positive

Negative

Fig. 3. The separating hyperplane of PPTSVM

Positive

Negative

Fig. 4. The separating hyperplane of SMTSVM

samples. A reason for this phenomenon is that in PPTSVM the estimated slack variable of the selected test sample is far from the real values, while SMTSVM updates some Lagrange coefficients in order to estimate the empirical risk value, which gives a better estimation. 4.2

Benchmark Data

In this subsection we compare the performances of SMTSVM and PPTSVM on the USPST database. The USPST database consists of 2007 samples with ten classes from digits ”0” to ”9”. In the experiments, we choose some of the ten digits to run PPTSVM and SMTSVM. We randomly select half of samples

226

X. Peng and Y. Wang Table 1. Comparisons of the accuracies of PPTSVM and SMTSVM Class Algorithm Np : 90% Np : 70% Np : 50% Np : 30% Np : 10% 6 vs 2 PPTSVM 89.34 91.90 92.45 92.17 90.43 SMTSVM 93.25 94.30 94.30 94.15 93.85 6 vs 3 PPTSVM 90.65 92.48 95.75 93.18 90.85 SMTSVM 96.27 98.70 98.70 98.45 97.32 6 vs 7 PPTSVM 90.73 92.35 94.60 92.18 89.76 SMTSVM 96.79 98.27 98.72 98.10 97.42 6 vs 8 PPTSVM 87.24 91.82 93.78 92.16 90.67 SMTSVM 95.78 97.56 97.84 97.84 96.12 6 vs 9 PPTSVM 92.57 94.72 96.58 93.73 91.62 SMTSVM 98.18 98.73 99.36 99.36 98.57

of two digits as the test samples, and another half of samples as the training (55%) and unlabeled (45%) test samples. The parameters of each trail are all identical, that is, RBF kernel is used with C = 10 and γ = 1.0E − 04. In the experiments, the initial proportion of Np of the unlabeled test set varies from 10% to 90%. Comparisons of the run results are listed in Table 1. By comparing the results of Table 1, we can find that SMTSVM obtains the better accuracies than PPTSVM, especially, when the initial proposition of Np is far from the real case, such as 10% or 90%, the former is more accurate than the latter. These results show again that SMTSVM derives a better approximation of the empirical risk by using the sequential minimization way than using a simple approximation in PPTSVM.

5

Conclusions

TSVM utilizes the information carried by the unlabeled samples for classification and acquires better classification performance than SVM. The recently proposed PPTSVM uses the individually judging and changing criterion to overcome the deficiency of the pair-wise exchanging criterion in TSVM. However, in PPTSVM a over-simple way is used to estimate the empirical risk after adjusting a temporary label which leads to a poor classification result. This work discussed a novel sequential minimal TSVM (SMTSVM) algorithm, in which the sequential minimization idea is introduced to estimate the empirical risk after adjusting a temporary label of test samples. The analysis shows that SMTSVM gives a better way to approximate the empirical risk than PPTSVM and then derives better classification result. The experiments on the artificial and benchmark databases indicate that SMTSVM obtains the better accuracy than PPTSVM because of the better approximation of empirical risk when adjusting temporary labels.

Learning with Sequential Minimal Transductive Support Vector Machine

227

References 1. Chen, Y.S., Wang, G.P., Dong, S.H.: Learning with progressive transductive support vector machine. Patte. Recog. Lett. 24, 1845–1855 (2003) 2. Christianini, V., Shawe-Taylor, J.: An Introduction to Support Vector Machines. Cambridge University Press, Cambridge (2002) 3. Dong, B., Cao, C., Lee, S.E.: Applying support vector machines to predict building energy consumption in tropical region. Energy and Buildings 37, 545–553 (2005) 4. Joachims, T.: Making Large-Scale SVM Learning Practical. In: Adv. Kernel Methods Vector Learn. MIT Press, Cambridge (1998) 5. Joachims, T.: Transductive inference for text classification using support vector machines. In: Proc. ICML 1999, 16th Internat. Conf. Mach. Learn, pp. 200–209 (1999) 6. Joachims, T.: Transductive learning via spectral graph partitioning. In: Proc. Internat. Conf. Mach. Learn. (ICML 2003), pp. 290–297 (2003) 7. Liu, H., Huang, S.T.: Fuzzy transductive support vector machines for hypertext classification. Internat. J. Uncert., Fuzz. Knowl. Syst. 12(1), 21–36 (2004) 8. Osuna, E., Freund, R., Girosi, F.: Training support vector machines: An application to face detection. In: Proc. IEEE Conf. Comput. Visi. Pattern Recogn., pp. 130–136 (1997) 9. Ripley, B.D.: Pattern Recognition and Neural Networks. Cambridge University Press, Cambridge (1996) 10. Vapnik, V.: The Natural of Statistical Learning Theory. Springer, New York (1995) 11. Vapnik, V.: Statistical Learning Theory. Wiley, New York (1998) 12. Wang, Y., Huang, S.: Training TSVM with the proper number of positive samples. Patte. Recog. Lett. 26, 2187–2194 (2005)

Junction Tree Factored Particle Inference Algorithm for Multi-Agent Dynamic Influence Diagrams Hongliang Yao, Jian Chang, Caizi Jiang, and Hao Wang Department of Computer Science and Technology, Hefei University of Technology, Hefei, Anhui province, China 230009

Abstract. As MMDPs are difficult to represent structural relations among Agents and MAIDs can not model dynamic environment, we present Multi-Agent dynamic influences (MADIDs). MADIDs have stronger knowledge representation ability and MADIDs may efficiently model dynamic environment and structural relations among Agents. Based on the hierarchical decomposition of MADIDs, a junction tree factored particle filter (JFP) algorithm is presented by combing the advantages of the junction trees and particle filter. JFP algorithm converts the distribution of MADIDs into the local factorial form, and the inference is performed by factor particle of propagation on the junction tree. Finally, and the results of algorithm comparison show that the error of JFP algorithm is obviously less than BK algorithm and PF algorithm without the loss of time performance. Keywords: Influence Diagrams, Particle Filter, Junction Trees.

1 Introduction Influence Diagrams(IDs) are presented by Howard, and IDs have become an important tool to represent single-Agent’s decision-making problem [1]. In order to use IDs dealing with decision problems of Multi-Agent, D.Koller presents a Multi-Agent influence diagrams (MAIDs) [2]. MAIDs may represent efficiently structural relations among Agents, but it can not model dynamic decision-making and other Agents in environrment. Multi-Agent Markov Decision Processes (MMDPs) [3] are widely used for processing Multi-Agent dynamic decision problems. Unfortunately, MMDPs are hard to represent the structural relations among Agents [4,5]. Considering the shortages of MAIDs and MMDPs, we present a new model of Multi-Agent Dynamic Influence Diagrams (MADIDs) for modeling the dynamic Multi-Agent systems [13]. MADIDs use hierarchical structure to represent a dynamic Multi-Agent system, where every Agent is associated with an Influence Diagram. Comparing with MMDPs and MAIDs, MADIDs have stronger knowledge representation ability, and MADIDs may efficiently model dynamic environment and structural relations among Agents. Boyen-Kollen (BK) algorithm [6] is a major approximate reference method of the dynamic probability model. Based on the idea of BK algorithm, the factored X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 228–236, 2009. © Springer-Verlag Berlin Heidelberg 2009

Junction Tree Factored Particle Inference Algorithm

229

frontier(FF) algorithm is presented [7]. Instead pf doing exact updating and then projecting in BK algorithm, the FF algorithm computes the marginals directly; but FF algorithm introduces more error than BK algorithm [8]. Particle Filter (PF) is a common inference method [9], which approximates posterior probability distribution of state by a set of samples. The PF algorithm can approximate arbitrary probability distribution and adjust the number of particle by reasoning, but PF algorithm can not efficiently compute for the medium-sized problems. The junction tree factored particle filter (JFP) algorithm is presented by combing the advantages of the junction trees(JT) and particle filter. Firstly, the junction trees of MADID is constructed; then, based on the strategic relevance of Agents, an incremental decomposition method is introduced to split nodes of the JT for improving computation efficiency. The inference errors are decreased by inducing separator in JFP. Moreover, in order to reason the utility nodes of MADIDs, JFP algorithm introduces marginalization operation of utility node. The experiment results show that the error of JFP algorithm is obviously less than BK algorithm and PF algorithm without the loss of time performance.

2 Multi-Agent Dynamic Influence Diagrams (MADIDs) A MADID is a triple ( M , Bt , Bts ) , where M is the number of Agents, and influence diagram of the MADID at time t, and

Bts = ( Et ,Vts )

where

Bt denotes

is transition model,

Et is a set of directed edges between Bt and Bt −1 , and Vts is a set of variables linked by Et . The set of variables of MADID is denoted by V D X Y U ,

=( , , , )

where D is the set of decision variables, and X is the set of state variables, and Y is the set of observed variables associated with X , and U is the set of utility nodes. At time t, let X t

= { X t1 ,...., X tM } be the set of state variables, Yt = {Yt1 ,...Yt n } be the set of

observed

variables, Dt = {Dt1 ,...., Dtm }

be

the

set

of i

decision i

i

variables

i

and U t = {U t1 ,...U tk } be the set of utility variables, where X t , Yt , Dt ,U t are the sets of variables of Agent i. A MADID consists of a structural strategy model, a probability model and a utility model. Structural strategy model.

Let

Λ t = (δ ti ,..., δ tM ) be a set of decision rules of i

all Agents at time t, and the structural strategy model assigns a decision rule δ t to a i

decision node Dt , where tions of

δ ti

is a map from the set of parents of

Dti to the set of ac-

Dti , and there is:

δ ti : Ω Pa ( D ) → Ω D i t

i t

(1)

230

H. Yao et al.

ΩPa(Di ) is the value space of parents of Dti , and Ω Di is the action space of

Where

Dti . A strategy profile σ t assigns a decision rules to every decision node in the set of t

t

decision nodes at time t. Probability model. Let decision nodes be regarded as random nodes, given decision i

rule δ t , the conditional probability of the decision node

Dti is:

⎧⎪1 whenδ ti ( Pa( Dti )) = d ij Pδ i ( Dti | Pa( Dti )) = ⎨ t ⎪⎩0 else

d ij represents one of the action set of Agent i.

Where

Given

σ t , the joint probability distribution of MADID at time t can be written as:

Pσ t ( X t , Yt , Dt ) = ⋅



Dtk ∈Dt

Where

(2)

∏ P( X

k t

| Y0:t , D0:t )

X tk ∈ X t

∏ P (Y

k

t

| X tk )

X tk ∈ X t

(3)

Pδ k ( Dtk | pa ( Dtk )) t

X tk is the set of state variables of Agent k , and Yt k is the set of observed

variables. Utility model. The utility function associates decision nodes with state variables. For i

i

i

each utility node U t , there is a local utility function U t ( Pa (U t set of its parents

)) associated with the

i t

U t ( X t , Dt ) = ∑i =1U ti ( Pa(U ti ))

Pa (U ) . At time t, the sum of all local utility function is: m

(4)

Thus, given strategy profile σ t , the joint expectation utility can be written as:

EU (σ t ) = ∑ Pσ t ( X t , Yt , Dt ) X tk

∑U σ ( pa(U

U tk ∈U t

t

k t

))

(5)

σ 0 of a MADID and the initial utility function U o ( X 0 , D0 ) , at time t=1, σ 1 and U1 ( X1 , D1 ) are unchanged with time.

Theorem 1. Given initial strategy profile

Proof. From Eq.1 and Eq.6, it’s obviously that on the structure of

σ 1 and U1 ( X1 , D1 ) absolutely depend

Bt and Bts . At the time t=1, due to that the structure of

Junction Tree Factored Particle Inference Algorithm

231

Bt and Bts of MADID is unchanged with the time, so do σ 1 and U1 ( X1 , D1 ) . Whereas, at time t=0, σ 0 and U o ( X 0 , D0 ) have nothing to do with time, so them should be given in advance.

2 The Hierarchical Decomposition of MADIDs 2.1 The Building of the Junction Tree Decomposing Graphical models into the tree is an efficient method to improve efficiency of inference of Graphical models. Definition 1. Chordal graph. A chordal graph G is an undirected graph, where all cycles of length four or more have a chord .A chord of a cycle is a connected pair of nodes not consecutive in the cycle. Definition 2. Cluster. A cluster is a maximal complete set of nodes. A set of nodes is complete if it is fully connected. Definition 3. Moralizing. Pair of parents of every node in G is ‘married’ by inserting a link between them. Then, directions of all edges are dropped. Definition 4. Triangulation. Triangulation converts the moral graph into a chordal graph by eliminating nodes in the moral graph. The JT of an ID is represented as T

= (Γ, Δ) , where Γ is the set of clusters, and clusters

Δ is used to connect two clusters in Γ. For a pair of adjacent clusters C i and C j , where Ci ∈Γ, C j ∈Γ and S k ∈ Δ , S k is a separator between C i and C j , then in

VS k = VCi ∩ VC j . 2.2 The Increment Decomposition of Outer Junction Tree The complexity of most operations of junction tree T = (Γ,Δ) is linear relation with the size

∑ S(φ

S (T ) of T , whereas the size of T possibly is a NP problem. The size of T is the

sum of probability potential function: S (T ) =

X

).

X ∈Γ∪Δ

Definition 5. Potential. Potential is a non-negative real function and projects every evidences of a variable or a set of variables onto non-negative real value. We use φ or ψ to denote potential, and potential is called function by us. Let

∑ψ

Ci be an arbitrary cluster in a junction tree T, then its probability potential is:

φC =

∏ P( X | pa( X )) , and its utility potential isψ C

X ∈VC

=

X i ∈VC

Xi

.

232

H. Yao et al.

Definition 6. Marginalizing. Let variables utility potential of cluster C are

R ⊆ C , and probability potential and

φc and ψ c , respectively.

We denote the operation by

‘marg( )’, then the marginalizing operation of probability potential and the marginal utility potential of R can be represented as follows:

m arg(C, R, φ ) =

∑φ

c

; m arg(C , R,ψ ) =

VC \ R

∑ ∑

VC \ R VC



φCψ C φ \R C

.

Let SP(T) be a possible splitting set of a junction tree T (Γ, Δ ) ,and let u and v be the sets of variables, where u is the set of variables consisting of variables of an Agent itself and environment variables, and v is the set of variables that is left variables by omitting the variables belongs to Agent itself in u. An ordered pair {u , v} can be generated. The set SP(T) consists of this ordered pairs that variables in {u , v} share exactly one cluster of T: SP (T ) = {{u , v} | ∃C ∈ Γ.{u , v} ⊆ VC } . The incremental decomposition of clusters of T

= (Γ,Δ)is based on the strategic

relevance of Agents. To perform a split {u, v}∈ SP(T ) on T means to remove a cluster

C with {u , v} ⊆ VC from the T, but add two new clusters C u and C v with

VCu = VC \ {v} and VCv = VC \ {u} , and also add a new separator S with V S = VC \ {u , v} , connecting Cu and C v in the JT to satisfy the partial order based on strategic relevance. Separators from adjacent clusters

D of C are bend to Cu if u ∈ VCk and to Cu

otherwise. The new clusters’ probability and utility potential are:

φC = m arg(C , v, φ ) u

,

ψ u = m arg(C , v,ψ )

;

φC = m arg(C , u, φ ) v

,

ψ C = m arg(C , u,ψ ) . The new separator’s probability potential and utility potenu

tial are: φ S = m arg( C , (v, u ), φ ) andψ S = m arg(C , (u , v),ψ ) . Based on the method of Kjaerulff [11], we present an incremental decomposition method of clusters, where the {u,v} is a ordered pair.

3 The Junction Tree Factored Particle Inference Algorithm The main idea of JFP algorithm: JFP algorithm converts the distribution of MADIDs into the local factorial form by hierarchical decomposition of MADIDs, and the inference is performed by factor particle of propagation on the Junction Tree. Let Γ = {c1 ,..., c k } be a set of clusters, which is obtained by hierarchical decomposition. The probability distribution of each cluster in Γ is approximated by factor particles. For any cluster c, use a set

{xt(,1c) ,..., xt(,Nc c ) } which contains N factor particle

Junction Tree Factored Particle Inference Algorithm

to represent the posterior probability distribution factored particle

233

P ( X tc | Y0:t ) of cluster c, where each

xt(,ic) is a complete evidence of xtc , and N c is the number of the par-

ticle of cluster c. Combining BK and PF algorithm, we have:

1 Nc ˆ P( X t | Y0:t , D0:t ) ≈ ∏ δ ( X t ,c − xt(,ic) ) ∑ Γ N c i −1

(6)

{ X 1 ,..., X M } is a set of nodes of the cluster c; for each time t, the cluster c has a factored particle table {xt ,c } , and every row of the factored particle table represents

Where

(i )

an especial factor particle xt ,c . It would introduce much error because BK algorithm constructs mutual independent clusters by weak relevance among variables. To reduce this error, we join an approximate formula of a conditional probability distribution of a separator s ( s ∈ Δ ), we can obtain:

∏ N ∑δ ( X Nc

1

Pˆ ( X t | Y0:t , D0:t ) ≈

Γ

∑δ ( X

t ,c

c i −1 Ns

1 ∏ Δ Ns

− xt(,ic) ) (7)

t ,s

(i ) t ,s

−x )

i =1

For a given strategy profile, the joint expected utility Uˆ (σˆ ) at time t is:

EU (σ ) = ∑ Pσ ( X t , Yt |Dt ) X tk

∑U σ ( pa(U

k t

))

(8)

U tk ∈U t

Where, P ( X ,Y | D ) = Pˆ ( X | Y , D ) P(Y k | X k ) P (Dk | pa(Dk )) , ∏ σi t 0:t 0:t ∏ t t t t t t t σ X tk ∈X t

state variables of the k’th Agent,

X tk is the set of

Dtk ∈Dt

Yt k is the set of observed value variables.

Definition 7. Proto-junction tree. The nodes in proto-junction GT are consisted with nodes of Γt , Γt +1 and Fts . The family of a variable x is denoted by

f x which consists of X and the set of X’s

f tx = {x ∪ pa( x)} . In transition network, the set of families of all nodes of Vts is represented as : Fts = { f tx | x ∈Vts } , where the potential of f tx is φtx , and the

parents

potential of

Fts is: Φ ts = ∏ φts . x∈Vts

234

H. Yao et al.

Construction and initialization of proto-junction tree: 1) The junction tree is constructed for influence diagram B0 by CJT algorithm, and then we split the junction tree by strategic relevance and weak relevance, and obtain J 0 , where J 0 = {Γ0 , Δ 0 } .

Γ and Fts into GT. = Φ ts .

2) Create an empty junction tree GT, and add the clusters of 3) Probability potential of proto-junction tree GT is Φ GT

The forward propagation from one step to the next step is given as follows: (1) Proto-junction tree GT is constructed, and probability potentials

Φ ts = ∏ φts in x∈Vts

Fts is multiplied into GT (2) For i=1,…, N; The particles of every variable are sampled by initial value of its parent. (3) Let t=0; (4) Create a temporary copy G of GT. (5) Projection: let Rt be a complete particle table and X c be the variable set of cluster C, and the operation of projecting

Rt on C is R

= π

t ,c

X c

R

t

( (6) Equijoin: joining all the factor particle tables, that is Rt = ∞ c∈Γ Rt ,c . (i )

(7) Let wt ,c

= 1 . For every variable X t j,c of C ∈ Γt , samples ( xtj,c ) ( i ) according to

the distribution (8)

P( X t j,c | Pa( X t j,c ) (i ) ) in two time slices.

S k is a separator between C i and C j , then VSk = VCi ∩ VC j , we can obtain its

particle table by getting the particles of intersection of (9) For every For every

Ci and C j .

Ct ∈ Γt : φCt = m arg(G, VCt , φ ) , ψ Ct = m arg(G , VCt ,ψ ) ;

S t ∈ Δ t : φ S t = m arg( J 0 , V S t , φ ) , ψ St = m arg(G,VSt ,ψ ) .

(10) For every

Ct ∈ Γt , S t ∈ Δ t : G =

∏ ∏

Ct ∈Γt

φC

φS S ∈Δ t

t

t

Φ ts .

t

(11) Insert new evidence Y t + 1 to G, and perform a local message-pass between clusters that it renders G consistent.

C ∈ Γt , uses their weights wt(,ic) to replace n ( i particles xt ,c . A new complete particle table Rt +1 is created by propagation for Rt . j

(12) Resampling. For the variable X t ,c of (13) t=t+1, and return (4).

Junction Tree Factored Particle Inference Algorithm

235

4 Cooperation of Pass-Catch in Robocup We use a MADID to emulate the three Agents’ pass-catch problem in a 10m*10m fixed scene. Let player A and player B be cooperation Agents, where A is an Agent of controlling ball. Player C is an interference Agent. We map sequential observed space into discrete grid area. According to their relationship, the grid areas are divided into strong interference region, middle interference region and small interference region. Table 1. The Experiment results of algorithms for different PJT Size Algorithm

k

Time(sec.)

PF

12

61.718

BK JFP JFP JFP JFP

3 3 5 6 8

16.04 16.07 18.06 19.12 21.63

Fig. 1. The mean error of BK PF and JFP algorithm

For the MADID model, we set the time steps as 50. Based on the Bayesian network toolkit FullBNT[12], we run the program in the environment of Matlab. Table1 represents the running time in JFP algorithm for different width of tree k (width of tree is defined as the number of the node of the maximum cluster on the junction tree). From table1, we can conclude that the running time will grow as the width of tree is added. When the minimum width of tree k=3, the running time of BK is almost the same as JFP algorithm. But BK algorithm is difficult to work out the minimum width of tree for its manual way, and also introduce much error. Fig.1 shows the error of BK, PF and JFP algorithm, where the sample numbers of JFP and PF algorithm are 400 and the widths of tree of JFP and BK algorithm are 3. We

236

H. Yao et al.

can conclude that the error of JFP algorithm is obviously less than that of BK algorithm when the widths of tree are identical; also the error of JFP algorithm is obviously less than that of PF algorithm when the sample numbers are identical.

5 Conclusion We present Multi-Agent dynamic influences (MADIDs) for modeling Multi-Agent systems in dynamic environment. Based on the hierarchical decomposition of MADIDs, a junction tree factored particle filter(JFP) algorithm is presented by combing the advantages of the junction trees and particle filter. Finally, the simulative experiment and comparison of algorithms are given for a model in RoboCup environment.

Acknowledgment The work is supported by the National Natural Science Foundation of China (Grant No. 60705015), and the Natural Science Foundation of An-Hui province (Grant No. 070412064).

References 1. Howard, R.A., Matheson, J.E.: Influence diagrams. Readings on the Principles and Applications of Decision Analysis 2, 719–792 (1981) 2. Koller, D., Milch, B.: Multi-agent influence diagrams for representing and solving games. In: IJCAI, pp. 1024–1034 (2001) 3. Boutilier, C.: Sequential optimality and coordination in multi-agent systems. In: IJCAI 1999, pp. 478–485 (1999) 4. Barto, A.G., Mahadevan: Recent Advances in Hierarchical Reinforcement Learning. Discrete Event Dynamic Systems. Theory and Applications 13(1/2), 41–77 (2003) 5. Wang, H.W., Li, C., Liu, H.: Entropic measurements of complexity for Markov decision processes. Control and Decision 19(9), 983–987 (2004) 6. Boyen, X., Kollen, D.: Tractable inference for complex stochastic processes. In: Proc. Of UAI 1998, pp. 33–42 (1998) 7. Paskin, M.A.: Thin junction tree filters for simultaneous localization and mapping. In: Proc. of IJCAI 2003, pp. 157–1164 (2003) 8. Frick, M., Groile, M.: Deciding first-order properties of locally tree-decomposable graphs. Journal of the ACM (48), 1184–1206 (2001) 9. Doucet, A., de Freitas, N., Murphy, K.: Rao-blackwellised particle filtering for dynamic Bayesian networks. In: Proceedings of the UAI-16th, pp. 253–259 (2000) 10. Burkhard, H.D., Duhaut, D., Fujita, M., Lima, P.: The road to RoboCup 2050. IEEE Robotics & Automation Magazine 9(2), 31–38 (2002) 11. Kjaerulff, U.: Reduction of computational complexity in Bayesian networks through removal of weak dependences. In: UAI 1994, pp. 374–382 (1994) 12. Murphy, K.: The bayes net toolbox for matlab. Computing Science and Statistics 33 (2001) 13. Yao, H.-L., Hao, W., Zhang, Y.-S.: Research on Multi-Agent Dynamic Influence Diagrams and Its Approximate Inference Algorithm. Chinese Journal of Computers 2(31), 236–244 (2008)

An Efficient Fixed-Parameter Enumeration Algorithm for Weighted Edge Dominating Set⋆ Jianxin Wang, Beiwei Chen, Qilong Feng, and Jianer Chen School of Information Science and Engineering, Central South University, Changsha 410083, P.R. China [email protected]

Abstract. Edge Dominating Set problem is an important NP-hard problem. In this paper, we give more detailed structure analysis for the problem, and adopt the enumerate-and-expand technique to construct a fixed-parameter enumeration algorithm. Based on the relationship between Edge Dominating Set and Minimal Vertex Cover, we first find all minimal vertex covers up to 2k size for the instance of problem and then expand these vertex covers with matching property and dynamic programming to get the z smallest k-edge dominating sets. At last, we present an efficient fixed-parameter enumeration algorithm of time complexity O(5.62k k4 z 2 + 42k nk3 z) for the Weighted Edge Dominating Set problem, which is the first result for the enumeration of the Weighted Edge Dominating Set problem.

1

Introduction

Edge Dominating Set problem is an important NP-hard problem with wide applications in many fields such as telephone switching networking. We first give some related definitions. Definition 1. Edge Dominating Set(EDS): Given a graph G = (V, E), an edge dominating set of G is a subset D of E such that each edge in E is either in D or incident to an edge in D, the objective is to find a D of minimum size. Definition 2. Weighted Edge Dominating Set(WEDS): Given a weighted graph G = (V, E), each edge of G with a positive weight, the objective is to find an edge dominating set of minimum weight. Definition 3. Parameterized Edge Dominating Set: Given a graph G = (V, E), the objective is to find an edge dominating set of size no more than k. ⋆

This work is supported by the National Natural Science Foundation of China (No. 60773111), the National Grand Fundamental Research 973 Program of China (No. 2008CB317107), the Excellent Youth Foundation of Hunan province of China (No. 06JJ10009), Program for New Century Excellent Talents in University (No. NCET-O5-0683) and Program for Changjiang Scholars and Innovative Research Team in University (No. IRT0661).

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 237–250, 2009. c Springer-Verlag Berlin Heidelberg 2009 

238

J. Wang et al.

Definition 4. Parameterized Weighted Edge Dominating Set: Given a weighted graph G = (V, E), each edge of G with a positive weight, the objective is to find an edge dominating set of weight no more than k. For the EDS problem, Randerath and Schiermeyer [1] presented the first exact algorithm of time complexity O(1.4423m ), where m is the number of edges of G. Raman [2] and Fomin [3] improved the above result to O(1.4423n ) and O(1.4082n ) respectively, where n is the number of vertices of G. In [4], Rooij and Bodlaender gave an exact algorithm with running time O(1.3226n ). From the point of approximation algorithm, the best known result was proposed in [5], which gave a 2-approximation algorithm for WEDS problem. Recently, parameterized computation theory was applied to solve the EDS and WEDS problems. Fernau [6] presented parameterized algorithms of time complexity O∗ (2.62k ) for EDS and WEDS problem respectively. The above result was further reduced by Fomin [7], which gave a parameterized algorithm of time O∗ (2.4181k ). Most optimization problems are concerned with finding a single solution of optimal value for a problem instance [8]. However, for many practical problems, people often want to seek a number of good solutions rather than a single good solution, which results in the enumeration of solutions. Traditional enumeration strategy asks to enumerate all solutions for a given problem instance. It is always unfeasible and also needless. Many computational applications only seek a certain number of good solutions [9-11]. The research on fixed-parameter enumeration algorithm has attracted many attentions. The definition of Fixed-Parameter Enumerable(FPE) was proposed for the first time in [12]: An NP optimization problem is fixed-parameter enumerable if there is an algorithm that, for a given problem instance (x, k) and an integer z, generates the z best solutions of size k to x in time f (k)nO(1) z O(1) . Fixed-parameter enumeration algorithm for Weighted Edge Dominating Set has great application in practice, especially in telephone switching networking. In this paper, we are focused on the fixed-parameter enumeration algorithm for the Weighted Edge Dominating Set problem, which is formally defined as follows. Definition 5. Weighted Edge Dominating Set Enumeration: Given a weighted graph G = (V, E), and positive integers k and z, each edge of G with a positive weight, the objective is to generate the z smallest k-edge dominating sets of G(an edge dominating set of k edges is called k-edge dominating set). For Weighted Edge Dominating Set problem, there was no efficient fixedparameter enumeration algorithm available. In this paper, we give further structure analysis for the problem, and adopt effective enumeration strategy to enumerate solutions: first find minimal vertex covers for the instance of problem and then expand these vertex covers with matching property and dynamic programming to get the z smallest k-edge dominating sets. Based on the approach, we present a fixed-parameter enumeration algorithm of time complexity O(5.62k k 4 z 2 + 42k nk 3 z), which effectively solves Weighted Edge Dominating Set enumeration problem for the first time.

An Efficient Fixed-Parameter Enumeration Algorithm

239

The paper is organized as follows. In section 2, we introduce some related definitions and lemmas. In section 3, we present algorithms to solve two special Edge Cover enumeration problem. In section 4, we give detailed analysis for the fixed-parameter enumeration algorithm. Finally, we draw some final conclusions and propose some research directions in section 5.

2

Preliminaries

Given a graph G = (V, E) and a subset A of V , a subset B of E, VB denotes the set of all terminals of B, EA denotes the set of all edges with two terminals in A, G[A] = (A, EA ). G(V, E \ B) denotes the graph constructed by deleting the edges in B from G. Lemma 1. [6] Given a graph G = (V, E) and a subset D of E, if D is a k-edge dominating set of G, then VD is a vertex cover of size no more than 2k of G. Definition 6. Given a graph G = (V, E) and a vertex cover C of G, if all subsets of C are not vertex covers of G, then C is called a minimal vertex cover of G. Lemma 2. [6] Given a graph G = (V, E) and a k-edge dominating set D of G, then one of the subsets of VD must be a minimal vertex cover of G. Definition 7. Given a graph G = (V, E) and a subset F of V , if exists an edge set Ce such that all vertices in F are covered by Ce , then Ce is called an edge cover of F . Lemma 3. [6] Given a graph G = (V, E) and a vertex cover C of G, if Ce is an edge cover of C, then Ce is also an edge dominating set of G. According to lemma 2 and lemma 3, let W be a k-edge dominating set of G, then W is a k-edge cover of a minimal vertex cover of G, the size of the minimal vertex cover is no more than 2k. Definition 8. Given a graph G = (V, E), the set that is composed of some disjoint edges of G is called a matching of G. Given a graph G = (V, E), if exists a matching M of G such that VM = V , then M is called a perfect matching of G. The size of the perfect matching is |V |/2. Lemma 4. Given a graph G = (V, E) and a subset C of V , if Ce is an edge cover of C, then one of the subsets of Ce must be a matching of G[C](the matching may be a null-set or contains some disjoint edges of G). Lemma 5. Given a set S of size n, each element of S with a weight, the z smallest elements of S can be found in time O(n). Proof. It is obvious that the zth smallest element s of S can be found in time O(n), and the element with smaller weight than s must be one of the z − 1 smallest elements of S. By comparing other elements with s, we can find the z − 1 smallest elements in time O(n). So the z smallest elements of S can be found in time O(2n), which can be shown as O(n).

240

3

J. Wang et al.

The Enumeration Algorithms for Special Edge Cover

Two special edge cover problems will be used in the process of solving the Weighted Edge Dominating Set enumeration problem. In this section, we first introduce the two special edge cover problems and present effective enumeration algorithms to generate z smallest solutions for them. 3.1

The Enumeration Algorithm for Edge Cover Based on Perfect Matching

Edge Cover Based on Perfect Matching: Given a weighted graph G = (V, E), a perfect matching M of G, and non-negative integers h and z, each edge of G with a positive weight, the objective is to get the z smallest h-edge covers of V such that the edge covers are constructed by t edges in M and h − t edges of G(V, E \ M )(t = |M |). Let U be an h-edge cover of V , and the edge cover is composed of t edges in M and h − t edges of G(V, E \ M ). We will use dynamic programming to generate the z smallest U , just as follows: First, assume the edges of G(V, E \ M ) are {e1 , e2 , e3 , . . . , ei , . . . , ea }, a = |E \ M |, Gi = (V, M ∪ {e1 , e2 , e3 , . . . , ei }); Then, for each Gi and integer j(1 ≤ j ≤ h), generate the z smallest Uij (Uij is a j-edge cover of V , and is composed of t edges in M and j − t edges of G(V, {e1 , e2 , e3 , . . . , ei })); At last, the algorithm can return the set of z smallest Uah , which is also the set of the z smallest U . The specific enumeration algorithm is given in Figure 1.

Matching-ECS(G, M, h, z) Input: a weighted graph G = (V, E), perfect matching M of G, and nonnegative integers h and z, t = |M | Output: the set of z smallest U 1. assume the edges of G(V, E \ M ) are {e1 , e2 , e3 , . . . , ei , . . . , ea }, a = |E \ M |; 2. S1,j = ∅ except S1,t = {M } and S1,t+1 = {M ∪ e1 }; 3. for i=2 to a do for j=1 to h do ′ = Si−1,j ; 3.1. Si,j 3.2. add ei to each (j − 1)-edge cover in Si−1,j−1 to construct j-edge ′′ covers, and let Si,j contain those j-edge covers; ′ ′′ ∪ Si,j into Si,j ; 3.3. put the z smallest sets in Si,j 4. return Sa,h ; Fig. 1. Enumeration algorithm for edge cover based on perfect matching

Theorem 1. For the instance (G, M, h, z), the algorithm Matching-ECS will return the set of z smallest U in time O(ahz), where a = |E \ M |.

An Efficient Fixed-Parameter Enumeration Algorithm

241

Proof. Assume the edges of G(V, E \ M ) are {e1 , e2 , e3 , . . . , ei , . . . , ea }, Gi = (V, M ∪ {e1 , e2 , e3 , . . . , ei }). Each Gi is consistent with a list Li = [Si,0 , Si,1 , . . . , Si,h ], where Si,j contains the z smallest Uij (Uij is a j-edge cover of V , and is composed of t edges in M and j − t edges of G(V, {e1 , e2 , e3 , . . . , ei })). For any j, S1,j is empty except S1,t = {M } and S1,t+1 = {M ∪ e1 }. Suppose we have constructed the list Li−1 , and then we need construct the list Li . ′ ′′ Suppose Si,j contains the z smallest Uij that do not contain ei , and Si,j ′ ′′ contains the z smallest Uij that contain ei . Then, Si,j = Si−1,j , and Si,j can be obtained by adding the edge ei to each set in Si−1,j−1 . It is easy to get that Si,j ′ ′′ is the set of the z smallest sets in Si,j ∪ Si,j . The algorithm Matching-ECS can return the set Sa,h which is the set of z smallest U . The time complexity of step 1 and step 2 are O(a) and O(h) ′ ′′ and Si,j contains only z sets respectively, respectively. Note that Si−1,j−1 , Si,j so according to lemma 5, step 3.2 can run in O(z) and step 3.3 can run in O(2z), then step 3 runs in time O(2ahz). Therefore, the time complexity of algorithm Matching-ECS is bounded by O(a + h + 2ahz), which can be shown as O(ahz). 3.2

The Enumeration Algorithm for Edge Cover Based on Special Sub-graph

Edge Cover Based on Special Sub-graph: Given a weighted graph G = (V, E), a vertex cover A1 of G, a subset A2 of A1 , and non-negative integers l and z, each edge of G with a positive weight, the objective is to generate the z smallest l-edge covers of A1 − A2 such that the edge covers are constructed by the edges of G(V, E \ (EA1 −A2 ∪ EA2 )). Let B be a l-edge cover of A1 − A2 , and the edge cover is composed of the edges of G(V, E \ (EA1 −A2 ∪ EA2 )). Based on dynamic programming, the general idea of finding the z smallest l-edge covers is as follows: First, assume the edges of G(V, E \ (EA1 −A2 ∪ EA2 )) are {e1 , e2 , e3 , . . . , ei , . . . , eb } such that the edges having common vertex in A1 − A2 appear in consecutive subsegment, Gi = (Vi , {e1 , e2 , e3 , . . . , ei }), Vi is the set of all terminals of {e1 , e2 , e3 , . . . , ei }, b = |E \ (EA1 −A2 ∪ EA2 )|; Then, for each Gi and integer j(1 ≤ j ≤ l), generate the z smallest j-edge covers of Vi ∩ (A1 − A2 ); At last, the algorithm can return the set of the z smallest l-edge covers of A1 − A2 , which is also the set of z smallest B. The specific enumeration algorithm is given in Figure 2. Theorem 2. For the instance (A1 , A2 , G, l, z), the algorithm Subgraph-ECS will return the set of z smallest B in time O(blz), where b = |E \(EA1 −A2 ∪EA2 )|. Proof. The algorithm Subgraph-ECS should find the l-edge covers of A1 − A2 , and the edge covers are constructed by edges of G(V, E \ (EA1 −A2 ∪ EA2 )). So if |A1 −A2 | > 2l or some vertices in A1 −A2 are isolated in G(V, E\(EA1 −A2 ∪EA2 )), such l-edge covers could not be found, just return “No”. Assume the edges of G(V, E \ (EA1 −A2 ∪ EA2 )) are {e1 , e2 , e3 , . . . , ei , . . . , eb } such that the edges having common vertex in A1 − A2 appear in consecutive subsegment. Gi = (Vi , {e1 , e2 , e3 , . . . , ei }), Vi is the set of all terminals of

242

J. Wang et al.

Subgraph-ECS(A1 , A2 , G, l, z) Input: a weighted graph G = (V, E), a vertex cover A1 of G, a subset A2 of A1 , and non-negative integers l and z Output: the set of z smallest B if such set exists 1. Assume the edges of G(V, E \(EA1 −A2 ∪EA2 )) are {e1 , e2 , e3 , . . . , ei , . . . , eb } such that the edges having common vertex in A1 −A2 appear in consecutive subsegment, where b = |E\ (EA1 −A2 ∪ EA2 )|; 2. if |A1 − A2 | > 2l then return “No”; 3. if some vertices in A1 − A2 are isolated in G(V, E \ (EA1 −A2 ∪ EA2 )) then return “No”; 4. if there is only one point of e1 is contained in A1 − A2 then S1,j = ∅ except S1,1 = {{e1 }}; else S1,j = ∅ except S1,0 = {∅} and S1,1 = {{e1 }}; 5. for i=2 to b do for j=1 to l do 5.1. if there is only one point v of ei is contained in A1 − A2 then if v is not the point of any edges in {e1 , e2 , e3 , . . . , ei−1 } then add the edge ei to each set in Si−1,j−1 and put these new sets into Si,j ; else if v is the common vertex of {ei−a , . . . , ei−1 } then ′ Si,j = Si−1,j ; add the edge ei to each set in Si−1,j−1 ∪ Si−a−1,j−1 and put the z smallest ones ′′ of these new sets into Si,j ; ′ ′′ ∪ Si,j , and put them into select the z smallest sets from Si,j Si,j ; 5.2. if two points of ei are not contained in A1 − A2 then ′ Si,j = Si−1,j ; add the edge ei to each set in Si−1,j−1 and put these new sets into ′′ ; Si,j ′ ′′ ∪ Si,j , and put them into Si,j ; select the z smallest sets from Si,j 6. return Sb,l ; Fig. 2. Enumeration algorithm for edge cover based on special sub-graph

{e1 , e2 , e3 , . . . , ei }. Gi is consistent with list Li = [Si,0 , Si,1 , . . . , Si,h ], Si,j is the set of the z smallest j-edge covers of Vi ∩ (A1 − A2 ) (the edge cover of j edges is called j-edge cover). Suppose that we have constructed the list Li−1 , then we need to construct the list Li . If there is only one point of e1 is contained in A1 − A2 , then for any j, S1,j is empty except S1,0 = {∅}; else for any j, S1,j is empty except S1,0 = {∅} and S1,1 = {{e1 }}. To construct Li , we distinguish the cases based on the type of the edge ei .

An Efficient Fixed-Parameter Enumeration Algorithm

243

Case 1: There is only one point v of ei is contained in A1 − A2 . If v is not the point of any edges in {e1 , e2 , e3 , . . . , ei−1 }, since v needs to be covered by the edge covers in Li , ei must be contained in the edge cover. Therefore, the j-edge covers in Si,j can be obtained by adding edge ei into each (j − 1)-edge cover in Si−1,j−1 . ′ If v is the common vertex of {ei−a , . . . , ei−1 }, let Si,j contain the z smallest ′′ j-edge covers of Vi ∩ (A1 − A2 ) that do not contain ei , and Si,j contain the z smallest j-edge covers of Vi ∩ (A1 − A2 ) that contain ei . we can get that ′ ′′ = Si−1,j . The edge covers contained in Si,j can be divided into the following Si,j two subcases: (1) only ei in {ei−a , . . . , ei } is contained in edge cover; (2) there are at least two edges in {ei−a , . . . , ei } that are contained in edge cover. The two kinds of edge covers can be obtained by adding ei into each set of Si−a−1,j−1 and adding ei into each set of Si−1,j−1 respectively. Therefore, Si,j contains the ′ ′′ z smallest sets in Si,j ∪ Si,j . Case 2: Two points of ei are not contained in A1 − A2 . Then it is easy to get that one point of ei is contained in A2 and the other ′ is contained in V − A1 . Since Si,j contains the z smallest j-edge covers of Vi ∩ ′′ contains the z smallest j-edge covers (A1 − A2 ) that do not contain ei , and Si,j ′ ′′ of Vi ∩ (A1 − A2 ) that contain ei , we can get that Si,j = Si−1,j . Then, Si,j can be obtained by adding ei into each set of Si−1,j−1 . Therefore, Si,j contains the ′ ′′ z smallest sets in Si,j ∪ Si,j . In conclusion, the algorithm Subgraph-ECS can return Sb,l , which is the set of the z smallest l-edge covers of A1 − A2 , that is, the algorithm can generate the z smallest B. Since |A1 −A2 | ≤ 2l, the number of edges of G(V, E \(EA1 −A2 ∪EA2 )) is b, so the time complexity of step 1 and step 3 are O(2bl) and O(2l) respectively. ′ ′′ and Si,j contains Step 4 can run in time O(l). Because Si−1,j−1 , Si−a−1,j−1 , Si,j only z sets respectively, according to lemma 5, step 5.1 can run in time O(2z + 2z) = O(4z) and step 5.2 can run in time O(z + 2z) = O(3z). So step 5 runs in O(4blz). Therefore, the total time complexity for the algorithm Subgraph-ECS is bounded by O(2bl + 2l + l + 4blz), which can be shown as O(blz).

4

The Fixed-Parameter Enumeration Algorithm

The fixed-parameter enumeration algorithm for the Weighted Edge Dominating Set problem is constructed as follows: First, find all minimal vertex covers up to size 2k, and for each minimal vertex cover C, enumerate all even subsets T of C (T contains even vertices of C, and the matching of G[C] must cover an even subset of C). Therefore, the original instance can be decomposed into a sequence of subinstances ξ = (C, T, G). Then, enumerate the k-edge dominating sets for each sub-instance ξ = (C, T, G). At last, select the z smallest ones from the obtained k-edge dominating sets to get the z smallest k-edge dominating sets of G. 4.1

The Structure Decomposition Algorithm

For a given instance of the Weighted Edge Dominating Set enumeration problem, we will first decompose the instance into a sequence of sub-instances. The general

244

J. Wang et al.

Structure-EDS(G, k) Input: a weighted graph G = (V, E) and non-negative integer k Output: a collection O of a sequence of triples ξ = (C, T, G) 1. list all minimal vertex covers up to size 2k, and put them into Q1 ; 2. i=1; 3. for each minimal vertex cover C in Q1 do for t=0 to k do 3.1. enumerate all subsets of size 2t of C, and put them into Q2 ; 3.2. while Q2 is not empty do pick up one set T from Q2 ; Q2 = Q2 − T , Ci = C, Ti = T , Gi = G; put the triple ξi = (Ci , Ti , Gi ) into collection O; i++; 4. return O; Fig. 3. Structure decomposition algorithm

idea for this process is as follows: First list all minimal vertex covers up to size 2k by a branch process, and enumerate all even subsets of each minimal vertex cover, then we can obtain a group of sub-instances. Each sub-instance is denoted by a triple ξ = (C, T, G), set C is a minimal vertex cover of G, T is an even subset of C, and G is the given graph G = (V, E). The specific algorithm for the above process is given in Figure 3. For a triple ξ = (C, T, G), if a k-edge dominating set D of G is the k-edge cover of C, and a perfect matching of G[T ] is the subset of D, then we say D is consistent with the triple ξ = (C, T, G). One triple can be consistent with more than one k-edge dominating set of G, and one k-edge dominating set of G can also be consistent with more than one triple. Theorem 3. Given an instance (G, k) of the Weighted Edge Dominating Set problem, the algorithm Structure-EDS returns a collection O of at most 42k triples in time O(42k + 4k n) such that by enumerating all corresponding k-edge dominating sets for each triple in O, we can obtain all k-edge dominating sets of G. Proof. Let D′ be a k-edge dominating set of G, according to lemma 2 and lemma 3, D′ is the k-edge cover of one minimal vertex cover C1 . By lemma 4, we can assume that matching M1 of G[C1 ] is the subset of D′ . Suppose that T1 is an even subset of C1 , and is formed by all terminals of edges in M1 , so M1 is a perfect matching of G[T1 ]. The algorithm Structure-EDS gets all minimal vertex covers up to size 2k, and enumerates all even subsets for them. Thus, triple ξ1 = (C1 , T1 , G) that is consistent with D′ must be contained in collection O. So the k-edge dominating set of G must be consistent with at least one triple in O. By enumerating all corresponding k-edge dominating sets for each triple in O, we can obtain all k-edge dominating sets of G.

An Efficient Fixed-Parameter Enumeration Algorithm

245

In step 1, all minimal vertex covers up to size 2k can be generated in O(4k n), and the number of such vertex covers will be no more than 4k [13]. According to binomial theorem, it can be done in time O(4k ) to enumerate all 2t-subsets of C for each t (0 ≤ t ≤ k), and will obtain at most 4k subsets for each C. Thus, step 3 runs in time O(42k ). Therefore, the time complexity of the algorithm StructureEDS is O(42k + 4k n), and the collection O contains at most 42k triples. 4.2

The Sub-instance Enumeration Algorithm

For each sub-instance obtained in Section 4.1, we need to find the possible corresponding solutions. The general idea of enumeration algorithm for the subinstance is as follows: For a given triple ξ = (C, T, G), non-negative integers k, z, and h, the corresponding k-edge dominating set of ξ is divided into two parts: D1 and D2 , where D1 contains h edges of G[T ], and D2 contains k − h edges of G(V, E \ (EC−T ∪ ET )). We first enumerate the corresponding z smallest D1 of ξ(let δ be the set of the z smallest D1 ): Let Q be the set of the h smallest edges of G[T ], enumerate the z smallest perfect matchings M of G(T, ET \ P ) for all (h − t)-subsets P of Q, where t = |T |/2, and then call the algorithm Matching-ECS(G[T ], M, h, z) to find the z smallest D1 (M ) for each M (D1 (M ) is composed of t edges in M and other h − t edges of G[T ]). Then, call the algorithm Subgraph-ECS (C, T, G, k − h, z) to enumerate the corresponding z smallest D2 of ξ. At last, consider all the possible combinations D of D1 and D2 , and return the z smallest D. The specific algorithm is given in Figure 4. Theorem 4. Given an instance (ξ, k, z, h), where ξ = (C, T, G), the algorithm Enumeration-EDS can generate the corresponding z smallest k-edge dominating sets of ξ in time O(2k k 3 z 2 +nk 2 z) such that each edge dominating set is composed of h edges of G[T ] and k − h edges of G(V, E \ (EC−T ∪ ET )). Before presenting the proof of Theorem 4, we first prove an auxiliary statement. Lemma 6. Given an instance (ξ, k, z, h), where ξ = (C, T, G), the set R1 in algorithm Enumeration-EDS contains the corresponding z smallest D1 (|D1 | = h) of ξ. Proof. Since one of the perfect matchings of G[T ] is a subset of the corresponding k-edge dominating set of ξ, so the set D1 that is consistent with ξ must be composed of t edges in a perfect matching M of G[T ] and h−t edges of G(T, ET \ M ). Let D1 (M ) denote D1 that contains all edges of M , and minD1 (M ) denote the D1 (M ) with smallest weight. Then minD1 (M ) is composed of t edges in M and the h − t smallest edges of G(T, ET \ M ). Let P ′ be the set of the h − t edges. The set Q contains the h smallest edges of G[T ], for |M ∩ Q| ≤ t, there are at least h − t edges of G(T, ET \ M ) contained in Q, so the edges in P ′ are all from Q. Accordingly, for a perfect matching M of G[T ], minD1 (M ) is composed of t edges in M and h − t edges in a (h − t)-subset of Q. Assume minD1 (M1 ) is composed of t edges in M1 and h − t edges in P1 , it is obvious that M1 is the perfect matching of G(T, ET \ P1 ). If M1 is not one of

246

J. Wang et al.

Enumeration-EDS(ξ, k, z, h) Input: a triple ξ = (C, T, G), non-negative integers k, h, and z Output: the set of the corresponding z smallest k-edge dominating sets of ξ such that each edge dominating set is composed of h edges of G[T ] and k − h edges of G(V, E \ (EC−T ∪ ET )). 1. put the h smallest edges of G[T ] into Q; 2. enumerate all (h − t)-subsets P of Q, and put them into Ω; 3. for each P in Ω do enumerate the z smallest perfect matchings M of G(T, ET \ P ), and put them into Ψ ; 4. for each M in Ψ do Φ1 =Matching-ECS(G[T ], M, h, z); Φ = Φ ∪ Φ1 ; 5. select the z smallest sets from Φ, and put them into R1 ; 6. R2 =Subgraph-ECS(C, T, G, k − h, z); 7. for each D1 in R1 do for each D2 in R2 do D = D1 ∪ D2 , put D into ∆; 8. return the set η1 of the z smallest D in ∆; Fig. 4. Sub-instance enumeration algorithm

the z smallest perfect matchings of G(T, ET \ P1 ), then the set being composed of the edges in P1 and the edges in anyone of the z smallest perfect matchings is surely smaller than the set minD1 (M1 ) being constructed by the edges in P1 and the edges in M1 . Therefore, minD1 (M1 ) is not contained in δ, and it is obvious that all D1 (M1 ) are not contained in δ. In conclusion, if D1 (M ) ∈ δ, then for at least one set P , M must be one of the z smallest perfect matchings of G(T, ET \ P ). Accordingly, all sets D1 contained in δ can be generate as follows: Enumerate the z smallest perfect matchings M of G(T, ET \ P ) for all sets P first, then generate the z smallest D1 (M ) for each M respectively by the algorithm Matching-ECS(G[T ], M, h, z), and put these D1 (M ) into the set Φ. The z smallest sets in Φ are surely the corresponding z smallest D1 of ξ, which are contained in R1 . Based on Lemma 6, we give the proof of Theorem 4. Proof. (Theorem 4) In the algorithm Enumeration-EDS, the corresponding kedge dominating set of ξ is divided into two parts: the set D1 that is composed of h edges of G[T ] and the set D2 that is composed of k − h edges of G(V, E \ (EC−T ∪ ET )). We need enumerate the z smallest D1 and D2 respectively for ξ. For the triple ξ = (C, T, G), its corresponding k-edge dominating set is also the k-edge cover of C, and its corresponding set D1 covers T . Therefore, its corresponding set D2 should be the (k − h)-edge cover of C − T . Enumerating the z smallest D2 for ξ means enumerating the z smallest (k − h)-edge covers of C − T , and these edge covers are composed of the edges of G(V, E \ (EC−T ∪

An Efficient Fixed-Parameter Enumeration Algorithm

247

ET )). By lemma 6, the set R1 in algorithm Enumeration-EDS contains the corresponding z smallest D1 of ξ. According to theorem 2, the algorithm SubgraphECS(C, T, G, k−h, z) can generate the corresponding z smallest D2 of ξ, which are put into R2 . For each D1 in R1 and each D2 in R2 , construct the set D = D1 ∪ D2 , and put D into the set ∆. The z smallest sets of ∆ are the final solutions. Now, we analyze the time complexity of algorithm Enumeration-EDS. Because the number of the edges of G[T ] is no more than 4k 2 , according to lemma 5, it is easy to get that step 1 runs in time O(4k 2 ). And step 2 runs in time O(2k ), the set Ω contains at most 2k subsets P . Step 3 enumerates the z smallest perfect matchings M of G(T, ET \ P ) for each set P . An algorithm in [14] was presented to enumerate the z largest perfect matchings of a given weighted graph in time O(n3 z), where n is the number of the vertices of the graph. The algorithm also can be used to enumerate the z smallest perfect matchings. Given a weighted graph G = (V, E) and let w be the largest weight of the edges of G, construct a new graph G′ = (V, E), and let the weight of each edge of G′ : w2 = w − w1 (w1 is the weight of the edge in G). Therefore, the z largest perfect matchings of G′ are the z smallest perfect matchings of G. Enumerating the z smallest perfect matchings of G(T, ET \ P ) for a set P runs in time O(|T |3 z) = O(8t3 z), t = |T |/2, t ≤ k. Since the number of set P is at most 2k , we can get that step 3 runs in time O(8k 3 z2k ), and can generate at most 2k z perfect matchings. Step 4 enumerates the z smallest D1 (M ) for each M by algorithm MatchingECS, and put them into the set Φ. Because the number of M is no more than 2k z, so the size of Φ is at most 2k z 2 . According to theorem 1, the time complexity of the algorithm Matching-ECS(G[T ], M, h, z) is bounded by O(ahz), where a is the number of the edges in G(T, ET \M ), a ≤ 4k 2 , h ≤ k, so step 4 runs in time O(4k 3 z 2 2k ). Step 5 runs in time O(2k z 2 ) for the size of Φ is at most 2k z 2 . Step 6 enumerates the z smallest D2 by the algorithm Subgraph-ECS, and put them into R2 . According to theorem 2, the time complexity of the algorithm Subgraph-ECS(C, T, G, k − h, z) is bounded by O(bkz − bhz), where b is the number of the edges in G(V, E \ (EC−T ∪ ET )), b ≤ 2kn, h ≤ k, we can get that step 6 runs in time O(2nk 2 z). The size of R1 and R2 are both z. Thus, step 7 runs in time O(z 2 ), and there are no more than z 2 sets in ∆. According to lemma 5, step 8 runs in time O(z 2 ). Therefore, the time complexity of the algorithm Enumeration-EDS is bounded by O(4k 2 + 2k + 8k 3 z2k + 4k 3 z 2 2k + 2k z 2 + 2nk 2 z + z 2 + z 2 ), which can be shown as O(2k k 3 z 2 + nk 2 z). 4.3

The General Fixed-Parameter Enumeration Algorithm

For an instance of the Weighted Edge Dominating Set problem, in order to generate the z smallest k-edge dominating sets of the instance, we first construct a sequence of sub-instances by the structure decomposition algorithm, and then enumerate solutions for those sub-instances by sub-instance enumeration algorithm. The specific fixed-parameter enumeration algorithm is given in Figure 5.

248

J. Wang et al.

FPE-EDS(G, k, z) Input: a weighted graph G = (V, E), non-negative integers k and z Output: the z smallest k-edge dominating sets of G 1. O=Structure-EDS(G, k); 2. if O=∅ then return “No”; 3. for each ξ in O do for h = 0 to k do η1 =Enumeration-EDS(ξ, k, z, h); η=η ∪ η1 ; 4. return the z smallest sets in η; Fig. 5. Fixed-parameter enumeration algorithm for WEDS

Theorem 5. Given an instance (G, k, z) of the Weighted Edge Dominating Set problem, the algorithm FPE-EDS can get the z smallest k-edge dominating sets of G in time O(5.62k k 4 z 2 + 42k nk 3 z). Proof. According to theorem 3, the algorithm Structure-EDS can generate a collection O that contains a sequence of triples ξ = (C, T, G). Enumerating all k-edge dominating sets for each triple in O can obtain all k-edge dominating sets of G. It is obvious that the corresponding k-edge dominating set of ξ = (C, T, G) can be divided into two parts: D1 and θ, where the set D1 is constructed by h edges of G[T ] and the set θ is formed by k − h edges of G(V, E \ ET ). In order to enumerate the k-edge dominating sets of G, we need to enumerate the corresponding θ of ξ. Suppose there is an edge e ∈ EC−T , let T1 = Ve ∪ T . If a corresponding θ of ξ does not contain the edge e, then we still can get θ after deleting e. If a corresponding θ of ξ contains the edge e, let D′ be a corresponding k-edge dominating set of ξ, and D′ is composed of the edges in θ which contains edge e and the edges in a D1 (M )(M is a perfect matching of G[T ]). It is easy to get that e ∪ M is a perfect matching of G[T1 ]. Therefore, D′ is also a k-edge dominating set that is consistent with ξ1 = (C, T1 , G), and is composed of k − h1 edges of G(V, E \ (e ∪ ET )) and h1 edges of G[T1 ](the h1 edges are the edges in e ∪ M ), where h1 = h + 1. Therefore, by enumerating the corresponding D1 and D2 for ξ1 = (C, T1 , G) and h1 , we can also find D′ . So we only need to enumerate the corresponding D1 and D2 for each triple ξ = (C, T, G) and h, and the k-edge dominating set of G must be an union of D1 and D2 . From the above analysis, in the algorithm Enumeration-EDS, we can get the corresponding z smallest D1 and D2 of a given triple ξ = (C, T, G), and also the union of each D1 and D2 . Therefore, at last, by choosing the z smallest ones from all obtained unions, the algorithm FPE-EDS can find the z smallest k-edge dominating sets of G. By theorem 3, step 1 runs in time O(42k + 4k n). Since the number of triples in O is at most 42k , and by theorem 4, we can conclude that the time complexity of step 3 is bounded by O(5.62k k 4 z 2 + 42k nk 3 z), the size of the set η is at most

An Efficient Fixed-Parameter Enumeration Algorithm

249

42k kz. Thus, step 4 runs in time O(42k kz). In conclusion, the algorithm FPEEDS can get the z smallest k-edge dominating sets of G in time O(42k + 4k n + 5.62k k 4 z 2 + 42k nk 3 z + 42k kz), which can be shown as O(5.62k k 4 z 2 + 42k nk 3 z).

5

Conclusions

In this paper, we present an efficient enumeration algorithm of time complexity O(5.62k k 4 z 2 +42k nk 3 z) for Weighted Edge Dominating Set enumeration problem for the first time, which can find the z smallest k-edge dominating sets of G. We apply the enumerate-and-expand technique to derive the algorithm. First, find all minimal vertex covers up to 2k size, and then expand these vertex covers with matching property and dynamic programming. Moreover, we propose an enumeration algorithm of time complexity O(ahz) for edge cover based on perfect matching problem, and an enumeration algorithm of time complexity O(blz) for edge cover based on special sub-graph problem. In addition, the approach used in this paper can also be applied to solve other problems, such as Minimum Maximal Matching problem. The study on Weighted Edge Dominating Set enumeration problem is significant to the research on Minimum Maximal Matching problem. The framework of Fixed-Parameter Enumerable is practically significant for many optimization problems, especially open up an interesting research direction for many infeasible enumeration problems.

References 1. Randerath, B., Schiermeyer, I.: Exact algorithms for minimum dominating set, Technical Report, TCologne: Zentrum fur Angewandte Informatik (2005) 2. Raman, V., Saurabh, S., Sikdar, S.: Efficient exact algorithms through enumerating maximal independent sets and other techniques. Theory of Computing Systems 41(3), 563–587 (2007) 3. Fomin, F.V., Gaspers, S., Saurabh, S.: Branching and treewidth based exact algorithms. In: Proceedings of the 17th International Symposium on Algorithms and Computation, pp. 16–25 (2006) 4. van Rooij, J.M.M., Bodlaender, H.L.: Exact Algorithms for Edge Domination. Technical Report UU-CS-2007-051, Netherlands: Dept. of Information and Computing Sciences Utrecht University (2007) 5. Parekh, O.: Edge domination and hypomatchable sets. In: Proceedings of the SODA, pp. 287–291 (2002) 6. Fernau, H.: Edge dominating set: efficient enumeration-based exact algorithms. In: Proceedings of the 2nd International Workshop on Parameterized and Exact Computation, pp. 142–153 (2006) 7. Fomin, F.V., Gaspers, S., Saurabh, S., Stepanov, A.A.: On two techniques of combining branching and treewidth. Technical Report No. 337, Norway: Dept. of Informatics, University of Bergen (2006) 8. Papadimitriou, C.H.: Computational Complexity. Addison-Wesley, Reading (1994) 9. Gramm, J., Niedermeier, R.: Quartet inconsistency is fixed parameter tractable. In: Amir, A., Landau, G.M. (eds.) CPM 2001. LNCS, vol. 2089, pp. 241–256. Springer, Heidelberg (2001)

250

J. Wang et al.

10. Scott, J., Ideker, T., Karp, R., Sharan, R.: Efficient algorithms for detecting signaling pathways in protein interaction networks. In: Miyano, S., Mesirov, J., Kasif, S., Istrail, S., Pevzner, P.A., Waterman, M. (eds.) RECOMB 2005. LNCS (LNBI), vol. 3500, pp. 1–13. Springer, Heidelberg (2005) 11. Pevzner, P., Sze, S.: Combinatorial approaches to finding subtle signals in DNA sequences. In: Proceedings of the 8th International Conference on Intelligent Systems for Molecular Biology, pp. 269–278 (2000) 12. Chen, J., Kanj, I.A., Meng, J., Xia, G., Zhang, F.: On effective enumerability of NP problems. In: Proceedings of the 2nd International Workshop on Parameterized and Exact Computation, pp. 215–226 (2006) 13. Damaschke, P.: Parameterized enumeration, transversals, and imperfect phylogeny reconstruction. In: Downey, R.G., Fellows, M.R., Dehne, F. (eds.) IWPEC 2004. LNCS, vol. 3162, pp. 1–12. Springer, Heidelberg (2004) 14. Chegireddy, R., Hamacher, W.: Algorithms for finding K-best perfect matchings. Discrete applied mathematics 18(22), 155–165 (1987)

Heuristics for Mobile Object Tracking Problem in Wireless Sensor Networks Li Liu1,2,⋆ , Hao Li2,∗ , Junling Wang1 , Lian Li1 , and Caihong Li1,∗ 1

School of Information Science and Engineering, Lanzhou University, Lanzhou, Gansu 730000, P. R. China 2 LRI, Univ Paris-sud and CNRS, Orsay F-91405, France

Abstract. The network lifetime and application requirement are two fundamental, yet conflicting, design objectives in wireless sensor networks for tracking mobile objects. The application requirement is often correlated to the delay time within which the application can send its sensing data back to the users in tracking networks. In this paper we study the network lifetime maximization problem and the delay time minimization problem together. To make both problems tractable, we have the assumption that each sensor node keeps working since it turns on. And we formulate the network lifetime maximization problem as maximizing the number of sensor nodes who don’t turn on, and the delay time minimization problem as minimizing the routing path length, after achieving the required tracking tasks. Since we prove the problems are NP-complete and APX-complete, we propose three heuristic algorithms to solve them. And we present several experiments to show the advantages and disadvantages referring to the network lifetime and the delay time among these three algorithms on three models, random graphs, grids and hypercubes.

1

Introduction

One of the import applications for wireless sensor networks is mobile object tracking, e.g. the sensor nodes are deployed for tracking enemy vehicles or tracking the habit of wild animals. And a number of applications require the sensor nodes send the mobile object’s data acquired, especially location data, back to the end users (or sinks). In practical cases, sensor nodes use multihop communication(Mobihoc2000) to reach the sinks. In multihop WSNs, communication between two sensor nodes may involve a sequence of hops through a chain of pairwise adjacent sensor nodes. However, sensor nodes are constrained in energy supply. A sensor node is unable to function while its energy is exhausted. Tremendous research efforts (INFOCOM07; SECON07; MobiHoc06) have been spent on the problem of energy conservation through scheduling the sensor node between active state and sleep state in wireless sensor networks. Practically, a sensor node can be in one ⋆

Corresponding authors: [email protected], [email protected], [email protected]

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 251–260, 2009. c Springer-Verlag Berlin Heidelberg 2009 

252

L. Liu et al.

of the following three states: active, idle, or sleep. The active state is when all the components are turned on. The idle state is when the transceiver is neither transmitting nor receiving but keep listening. And the sleep state is when the radio is turned off. However, to coordinate the sensor network, sensor nodes have to exchange data frequently to show their current states, which induces additional expenses on energy and bandwidth. In a large density sensor network, a sensor node may be in active state frequently to exchange its state information with other nodes while coordinating all sensor nodes, which induce the power dissipation rapidly. Additionally, the global scheduling needs synchronization support. However, if synchronization cannot be maintained, for example, under poor propagation conditions, the coordination is indisciplinable. Hence communication without synchronization may be preferable. To avoid the global scheduling, one intuitive solution is that since a sensor node is scheduled in active state, it keeps in active state until it runs out of power. In practical cases, a sensor node can turn itself in idle state while it is not required transmitting nor receiving. According to (Sinha and Chandrakasan), the measured power consumption in various sensor modes is 976mW in active state, 403mw in idle state. A sensor node in idle state can run in a much lower energy mode but still keep its radio on. From the above discussions, we notice that energy requirement and delay requirement are two essentials to track a mobile object. Although energy efficiency and delay requirement have been extensively studied separately in recent year (ICMSAS04; IRTETAS06; SIGCSE06), few works study two goals together, and consider the tradeoff between the energy and delay requirements. In this paper, we address this problem with multihop routing approach and propose three heuristics to achieve the energy and delay requirements. The remainder of this paper is organized as follows. In Section 2, we describe some assumptions and definitions of the problem, and then study its complexity. In Section 3, we present three algorithms to solve the problem, and in Section 4 we present some numerical results. Section 5 concludes this paper.

2 2.1

Problem Formulation Assumptions, Notations and Definitions

Several assumptions are proposed in this paper. A set of sensor nodes coordinate to track a set of mobile objects, called targets, as well as they send the tracking information cooperatively back to the end-user, called sinks. Sensor nodes have two states, sleep and active. The wireless sensor network is modeled as a directed graph G(V, E), where V = N ∪ R is the set of all sensor nodes and sink nodes in the network. N denotes the set of sensor nodes who can sense the targets and communicate with each other, and R denotes the set of sink nodes who collect targets’ data. E is the set of all directed links in the network. A directed link (s, d) exists if the Euclidean distance between the two node, s and d, is less than or equal to the transmission range of the node s.

Heuristics for Mobile Object Tracking Problem

253

As sensor nodes have limited energy capacity, we define each sensor node has its lifetime. A sensor node v has the lifetime of ev time units, called its energy capacity. Since a sensor node turns on, its working duration is ev time units. During the working duration, a sensor node is in active state. After ev time units, it runs out of energy. We denote the states of a sensor node v by a function state defined as: a sleep node with state(v) = 0 when it is in sleep state; an active node with state(v) = 1 when it is in active state; a halt node with state(v) = −1 when it works beyond ev time units. A sensor node who detects a target is called source node. Definition 1. Network Lifetime Maximization Problem (NLMP) Given a directed graph G(V, E) with n nodes and a function state for each node v ∈ V , an ordered set of m source nodes S ⊂ V , and a sink node r ∈ V . Select a set of routing paths for all source nodes in order. Maximize the number of residual nodes. We denote L(s), the length of Rs , as the number of sensor nodes by which the data have beendelivered. And we denote L(S) as average routing path length, L(s) where L(S) = s∈S . To minimize the delay time for each data delivery, we m define the problem of minimizing the average routing path length. Definition 2. Routing Path Length Minimization Problem (RPLMP) Given a directed graph G(V, E) with n nodes and a function state for each node v ∈ V , an ordered set of m source nodes S ⊂ V , and a sink node r ∈ V . For each source node s ∈ S in order, select a routing path Rs . Minimize the average routing path length L(S). We define the problem as minimizing the average routing path length instead of minimizing the delay time for each data delivery. Although the objective of the problem does not guarantee that each data delivery achieves the minimal average routing path length, we consider it as a tractable problem and show its efficiency in our experiments. 2.2

NP-Complete

To prove N LM P NP-complete, first we introduce the Steiner Tree problem in graphs, which defined in decisional form as follows: Given a graph G = (V, E), and a subset of the vertices H ⊂ V , find a subtree T of G that includes all the vertices of H, where T contains k edges. Theorem 1. Steiner tree problem in graphs is NP-complete. We give a NP-complete version of N LM P , called k-NLMP : Given a directed graph G(V, E) with a function state for each node v ∈ V , an ordered set of m source nodes S ⊂ V , and a sink node r ∈ V . There are k residual nodes after finding a set of routing paths for all source nodes in order.

254

L. Liu et al.

Theorem 2. k-NLMP is NP-complete. Proof. It is easy to show that k-NLMP ∈ N P , since a nondeterministic algorithm needs only to count the number of residual nodes and then verify in polynomial time if there are k residual nodes. To show that k-NLMP is NP-hard, we reduce the Steiner Tree problem to it. We construct a network, where ev is sufficiently large for each node v in the network. It means that once a node v turns on, state(v) keeps equal to 1 until all of the source nodes find routing paths. Since the problem requires k residual nodes left after selecting routing paths, the number of active nodes is n − m − 1 − k, except the source nodes S and the sink node r. Therefore the problem turns to the following problem: given a graph G = (V, E), and a subset of the vertices H, where H = S ∪ {r}, find a subtree T that includes all the vertices of H, where T contains n−m−1−k vertices excluding H. As T has n−k vertices, it implicitly has n−k−1 edges. Therefore the problem on the constructed network is a Steiner Tree problem which is already proved NP-complete. Therefore k-NLMP is NP-complete. The Steiner Tree problem is known to be APX-complete (Bern and Plassmann), which means that no polynomial time approximation scheme exists. And currently the best approximation algorithm for the Steiner Tree problem has a performance ratio of 1.55, whereas the corresponding lower bound is smaller than 1.01. Since the Steiner tree problem is one of a special case of N LM P , N LM P is an APXcomplete, and its corresponding lower bound is not greater than 1.01.

3

Algorithms

As N LM P is NP-complete, this section presents three heuristic algorithms to solve N LM P and RP LM P together. The results of these three algorithms are the set of m routing paths for m source nodes. 3.1

Na¨ıve Shortest Path Selection (N SP S) Algorithm

N SP S algorithm is a basic algorithm that selects the shortest paths from the source nodes to the sink node in order. N SP S algorithm achieves that each selected path is the shortest one, which has the minimal routing path length. However, note that N SP S algorithm does not take any factor of the number of sleep nodes or active nodes into account while selecting paths. The time complexity of N SP S algorithm is O(mn log n). 3.2

Dual Shortest Path Selection (DSP S) Algorithm

DSP S algorithm takes as input an graph G = (V, E) with function state, an ordered set of m source nodes S = {s1 , s2 , . . . , sm } ⊂ V , and a sink node r ∈ V . Initially, for each sensor node v, state(v) = 0, which means all sensor nodes are in sleep state at the beginning, except for the sink node with state(r) = 1.

Heuristics for Mobile Object Tracking Problem

255

DSP S algorithm selects routing paths from each source node to the sink node r in order. For each source node, DSP S algorithm uses the same procedure. The following steps show tth selection of routing path for source node st . STEP 1: Construct a new graph G′ , called contracted graph, where G′ is a contracted version of the original graph G. The construction of G′ follows that (1) find all of the maximal connected subgraphs, called original subgraphs, such that for each subgraph, every node v satisfies state(v) = 1, and denote the original subgraphs as C1 , C2 , . . . , Ck ; (2) replace these k original subgraphs by k substitutive nodes in G′ . Let Voriginal = {v : state(v) = 0} ∪ {r}, and a set of substitutive nodes VC = {c1 , c2 , . . . , ck }. Let V (G′ ) = Voriginal ∪ VC and E(G′ ) = {(a, b) : a, b ∈ Voriginal and(a, b) ∈ E(G)} ∪ {(a, ci )or(ci , a) : a ∈ Voriginal , ci ∈ VC , b ∈ Ci , (a, b) ∈ E(G)}. STEP 2: Find a shortest path p′ , called contracted path, from the source node st to r in the contracted graph G′ . STEP 3: Restore path p, where p is the original path of p′ in graph G. The restore of p follows that (1) for each substitutive node cij in path p′ , find a shortest path in the original subgraph Cij . Denote all of substitutive nodes in path p′ as ci1 , ci2 , . . . , cil . For each cij , and its left adjacent node u, right adjacent node v in the path p′ , a new graph H, called restored graph, is constructed by the original subgraph Cij and u,v, where V (H) = V (Cij ) ∪ {u, v} and E(H) = E(Cij ) ∪ {(u, a) : a ∈ V (Cij ), (u, a) ∈ E(G)} ∪ {(a, v) : a ∈ V (Cij ), (a, v) ∈ E(G)}. Find the shortest path pij from u to v in graph H. (2) replace ci1 , ci2 , . . . , cil of the contracted path p′ by the paths pi1 , pi2 , . . . , pil to form the original path p. The path p is the routing path for source node t. STEP 4: Change the state of all sleep nodes in path p to 1. DSP S algorithm employs shortest path method twice considering both the routing path length and the number of sleep nodes. If we only select a shortest path from the source node to the sink node in the original graph, which only concerns the shortest routing length, i.e. N SP S, it may induce more sleep nodes to turn on, which exhausts more sensor nodes and shorten the total network lifetime. Although DSP S algorithm can’t guarantee the selected path is the best choice for minimal length and minimal number of sleep nodes simultaneously, it works well for the tradeoff between the minimal length and the minimal sleep nodes according to the experiments. The worst case time complexity of DSP S algorithm remains O(mn2 ). 3.3

Weighted Shortest Path Selection (W SP S) Algorithm

The solution can be stated similarly to the solution of weighted shortest path problem, as follows: Given a Graph G = (V, E) with weights wi where wi is the cost of sensor node i. wi is defined as wi = 0 if i is in active state, wi = 1 if i is in sleep state, wi = ∞ if i is a halt node. For each source node si in ordered set S, W SP S algorithm aims to select a path to r with the lowest cost. However, W SP S algorithm is possible to find several paths with the minimal number of sleep nodes potentially, but with the different path length. Assume

256

L. Liu et al.

two path p, q, both with the minimal number of sleep nodes, but  p  0, the algorithm finds a string s of length L such that for every si ∈ calB there is a length-L substring ti of si with d(ti , s) ≤ (1 + ǫ)db , and for every length-L string gi ∈ G, d(gi , s) ≥ (1 − ǫ)dg if a solution to the original pair (db ≤ dg ) exists. The PTAS can simultaneously approximate both db and dg . Recently, lots of fixed-parameter algorithms for a simplified version, the closest substring/string problem, have been proposed. Stojanovic et al. provided a linear time algorithm for d=1 [18]. Grammet al. provided the first fixed-parameter algorithm for the closest string problem with running time O(nL + ndd+1 ) [17]. Marx have presented two algorithms for the closest substring problem that runs in time O((|Σ|−1)dlogd+2 (nm)⌈logd⌉+1 ) where n is the number of given strings, d is the allowed distance and m is the length of the given strings [15]. Ma and Sun proposed a O(Ln+nd(|Σ|−1)4d) algorithm for the closest string problem, where Σ is the alphabet. This gives a polynomial time algorithm when d = O(logn) and Σ has constant size. Using the same technique, they additionally provided a more efficient sub-exponential time algorithm for the closest substring problem [14]. The distinguishing (sub)string selection is much harder. Gramm et al. designed a fixed-parameter algorithm for a modified version of the distinguishing substring selection problem [16]. They assume that the strings are binary and dg is first maximized and db is minimized under the fixed dg . This modified version is much easier than the original problem. The two groups can be treated separately for the modified version. In this paper, we design an O(Ln + nd23.25d × (|Σ| − 1)d ) time fixedparameter algorithm for the closest string problem which improves upon the best known O(Ln + nd24d × (|Σ| − 1)d ) algorithm in [14], where |Σ| is the size of the alphabet. It should be emphasized that our new algorithm for the closest string problem works for strings over alphabet Σ of unbounded size. We also design fixed-parameter algorithms for both the farthest string problem and the distinguishing string selection problem. Both algorithms run in time O(Ln+ nd23.25db ) when dg ≥ L − db and the input strings are binary strings over Σ = {0, 1}.

Efficient Algorithms for the Closest String

2

263

The Closest String

In this section, we will study the closest string problem. We propose some new algorithms that work well when d is small. First, we define some notations. Let si and sj be two strings of the same length. We define P (si , sj ) to be the set of all positions that si and sj disagree. Let L = {1, 2, . . . , L} be the set of all L positions of the given strings and P be any subset of L. We define P¯ = L − P to be the set of positions that are not in P . We always use s to represent the optimal center string. Outline of the Algorithms: Our algorithms follow the same fashion of the O(Ln + nd24d × (|Σ| − 1)d) algorithm in [14]. The basic idea is to arbitrarily fix one of the given strings in B, say, s1 and try to change at most d positions from s1 to get the desired center string s. If we directly select at most d positions from L, we have to spend O(CdL )(|Σ| − 1)d time. A better way is to consider some subset of L and choose k ≤ d positions at a time and repeat the process until d positions are selected. Let s′ be the current center string obtained from s1 after some modification. Each time we consider P (s′ , sj ) ⊆ L for a given string sj ∈ B such that d(s′ , sj ) > d and select k ≤ d positions in P (s′ , sj ) and change the letters for all selected positions. The smaller |P (s′ , sj )| is, the more efficient the algorithm is. Let P be the union of P (s′ , sj ) for all sj ’s that have been used before. For the next round, we will find another sj ′ such that d(s′ , s′j ) > d and select some positions in P (s′ , sj ′ ) − P to change. After each round, the number of remaining positions that can be changed is reduced. The process stops until the number of positions that can be changed is reduced from d to 0. The algorithm is given in Figure 1. The initial values are as follows: s′ = s1 , U = P = ∅, S = ∅ and e = d. Here s′ is the current center string, U is the set of positions in s1 that the algorithm has changed, S is the set of strings in B that have been selected in Step 1 of the algorithm in the previous rounds, P = ∪sj ∈S P (s′ , sj ) and e is the number of remaining positions that the algorithm can possibly change for the rest of rounds. In the algorithm, the parameter δj that first appears in Step 1 is very crucial in the analysis of the running time. In Step 3, when computing R, we ignore the positions in P that have been considered before. In Step 4, when guessing the value of k, the number of positions in R = P (s′ , sj ) where the current center string s′ and the final center string s are different. The k value will be at least δj and this can save some running time in practice. The parameter δj plays a crucial role in reducing the running time of the algorithm. Lemma 1. Let s′ be the center string obtained after the previous rounds and s be the final center string. Let U be the set of positions that have been correctly changed in the previous round. That is, s′ and s are identical at all positions in U . Let sj is the string selected in Step 1 for the current round and k¯ be the number of positions in P (s′ , sj ) − U such that s′ and s differ. Then k¯ ≥ δj .

264

L. Wang and B. Zhu Algorithm: closestString An instance of search space U , S, P , e, s′ (center string), s1 ,s2 , . . ., sn . A string s such that d(s, si ) ≤ d for i = 1, 2, . . . , n, or FALSE if there is no solution. find a string sj such that d(s′ , sj ) = d + δj for some δj > 0. if no sj is found in Step 1, return s′ as the output. if δj > e then return NULL. R = P (s′ , sj ) − P . for k = δj , δj + 1, . . . , e do P = P ∪ P (s′ , sj ). Select k positions in R. Add the selected positions to U . e = min{e − k, k − δj }. S = S ∪ {sj }. Try (|Σ| − 1)k possible ways to change the k letters and for each of the obtained new s′ call closestString(U, S, P, e, s′ , s1 , s2 , ..., sn ) if all the calls return NULL, then return FALSE

Input Output 1. 2. 3. 4. 5.

6.

Fig. 1. Algorithm 1: The closestString()

¯ Proof. Let K = {i|i ∈ P (s′ , sj ) − U & s[i] = sj [i] & s[i] = s′ [i]}. Thus, |K| ≤ k. By the definitions of P (s′ , sj ) and P¯ (s′ , sj ), s′ and sj are identical at the positions in P¯ (s′ , sj ). Thus, any modification of s′ at positions in P¯ (s′ , sj ) will increase the value of d(s′ , sj |P¯ (s′ , sj )). By the definition of K, sj and s disagree at all ¯ where positions in P (s′ , sj )−U −K. Thus, d(s, sj ) ≥ d(s′ , sj )−|K| ≥ d(s′ , sj )−k, s is the final center string. (See Figure 2.) If k¯ < δj , d(s, sj ) ≥ d(s′ , sj ) − k¯ = d + δj − k¯ > d. This is a contradiction to the definition that s is the final center string. ⊓ ⊔ From Lemma 1, we know that the value k in Step 4 should be at least k¯ ≥ δ.

P¯ (s , sj )

P (s , sj ) ✛

K ✲





P (s′ , sj ) − U − K and s and sj disagree



U ✲

s′ = sj and any modification of s′ will increase d(s, sj |P¯ (s′ , sj ))

Fig. 2. The partition of L

From Figure 1, we can easily see that Observation 1: Let sj be a string selected in Step 1 in some round. d(s′ , sj ) changes round after round during the execution of the algorithm. The value of d(s′ , sj ) reaches the minimum (≤ d) right after sj is selected in Step 1 and the k positions are selected and the k letters are converted to be identical to sj . A key idea in [14] is that each time the recursive function closestString() is called, the value of e (the number of remaining positions to select) is reduced by at least half. Here we have a stronger lemma. Let e′ be the number of remaining positions that the algorithm can select at present and e be the number of

Efficient Algorithms for the Closest String

265

remaining positions that the algorithm can select after one more round. Let k be the number of positions selected in this round and δj the value in Step 1 for this round. Lemma 2. e = min{e′ − k, k − δj }. Proof. Consider the current round where sj is found in Step 1 and k positions are selected from R ⊆ P (s′ , sj ) in Step 5. Let s′′ be the updated s′ after changing the k letters. From Observation 1, d(s′′ , sj ) ≤ d. Note that, before updating, d(s′ , sj ) = d + δj > d. After updating, d(s′′ , sj ) = d + δj − k. In the rest rounds, if the algorithm selects e positions to change to get the final solution s, then d(s, sj ) = d(s′′ , sj ) + e. Since d(s, sj ) ≤ d, we have e ≤ k − δj . Moreover, by the definition of e′ , after selecting k positions in this round, the number of remaining positions that the algorithm can select is at most e′ − k. Thus, the lemma holds. ⊓ ⊔ If the algorithm returns FALSE, then all calls of closestString() return NULL. That is, in Step 3 of the algorithm, we always have δj > e. From Lemma 2 and the way that we update e in Step 5, the number of remaining positions e that the algorithm can change is less than δj . Thus, after changing at most e positions we still have d(s′ , sj ) ≥ d + δj − e > d. Therefore, for all calls of closestString(), there is no center string s with d(s, si ) ≤ d for all si ∈ B. This is a way to save running time. Next, we give a proof for the correctness of the algorithm. Theorem 1. Algorithm 1 can correctly compute an optimal center string if such a center string exists and Algorithm 1 returns FALSE if there is no center string s satisfying d(s, si ) ≤ d for all si ∈ B. Proof. If Algorithm 1 outputs a center string s′ , then from the algorithm, we know that there is no sj ∈ B such that d(s′ , sj ) ≥ d. That is, for all string si ∈ B, we have d(s′ , sj ) ≤ d. Thus, we have the desired center string s′ . Now we want to show that if there exists a center string s such that d(s, si ) ≤ d for all si ∈ B, the algorithm can always output a desired center string. Without loss of generality, we can assume that P (s, s1 ) − [∪nj=1 P (s1 , sj )] = ∅.

(1)

(Otherwise, for any position k ∈ P (s, s1 ) − [∪nj=1 P (s1 , sj )], we have s1 [k] = si [k] for all si ∈ B. Thus, we can change s to s′ by setting s′ [k] = s1 [k] for k ∈ P (s, s1 ) − [∪nj=1 P (s1 , sj )]. We know that s′ is also a desired center string, i.e., d(s′ , si ) is less than d for all si ∈ B.) Let sj1 be the string found in Step 1 of the first round call. Let P1 be the set of all the positions in P (s1 , sj1 ), where s and s1 differ. We can find all the positions in P1 by trying all possibilities in Step 4 and Step 5. By induction on the number of rounds and from equation (1), we can show that for some q > 0, the algorithm can find P1 , P2 , . . . Pq such that P (s, s1 ) = ∪qi=1 Pi , where Pi is the set of all positions in P (s1 , sji ) such that s and s1 differ, and sji is the string

266

L. Wang and B. Zhu

selected in Step 1 of the i-th round after the first (i − 1) rounds correctly find P1 , P2 , . . ., Pi−1 , respectively. For each position in P (s, s1 ), the algorithm has tried the |Σ| − 1 letters to change in Step 5 and must be correct once. Thus, the algorithm can output a desired center string. ⊓ ⊔ Lemma 3. Let k be the number of positions selected in the first round and k ′ the number of remaining positions to be selected after the first round, and δj the value in Step 1 of the first round. k′ ≤

d − δj . 2

Let B(U, e) = {si |d(s′ , si ) > d} be the set of all given strings with d(s′ , si ) > d when we call closestString (U, S, e, s′ , s1 , s2 , ..., sn ). We define max (d − d(s′ , si |U )).

d(U, e) =

si ∈B(U,e)

Let T (d(U, e), e) be the size of the search space tree (running time required for closestString (U, e, s′ , s1 , s2 , ..., sn ) ignoring the time in Step 1). The following lemma is from Theorem 1 in [14]. Here the value d(U, e) was d in [14]. We observe that it is true for any d(U, e) and we can reduce the running time based on this observation. Lemma 4. T (d(U, e), e) ≤ Ced(U,e)+e × 22e × (|Σ| − 1)d . Theorem 2. The running time of Algorithm 1 is at most O(Ln + nd23.5d ), where n is the number of string in B, L is the length of the strings in B, and d is the maximum distance between a given string si ∈ B and the center string s. Proof. Let us focus on the size of the search space by ignoring the time spent in Step 1. Let k, k ′ and δj be defined as in Lemma 3. Without loss of generality, we assume that δj < d. (Otherwise, Algorithm 1 completes after the first round call of closestString() and the search space ignoring the running time in Step 1 is O(Cd2d ) ≤ O(22d ).) The search space of Algorithm 1 is upper bounded by d 

T ≤

d+δj

[Ck

T (d, k ′ )],

(2)

k=δj d+δ

where Ck j is the time required for the first round of the algorithm to select k positions from the d + δj positions in P (s1 , sj ) and T (d, k ′ ) is the search space for the rest of rounds to select totally k ′ positions. Now, we want to show that T (d, k ′ ) ≤ 22.5d−1.5δj .

(3)

From Lemma 4 and Lemma 3, ′





22k ≤ 2d+3k ≤ 2d+3 T (d, k ′ ) ≤ Ckd+k ′

d−δj 2

≤ 22.5d−1.5δj .

Efficient Algorithms for the Closest String

267

Combining (2) and (3), we have T ≤

d 

d+δj

[Ck

T (d, k ′ )] ≤ (

=2

d+δj

Ck

) × 22.5d−1.5δj ≤ 2d+δj × 22.5d−1.5δj

k=δj

k=δj 3.5d−0.5δj

d 

≤2

3.5d

.

(4)

Let us consider the total running time of Algorithm 1. In the preprocess phase, we compute P (s1 , si ) for all si ∈ B − {s1 }. It takes O(nL) time. After that, we can spend O(nd) time in Step 1 to find sj . Therefore, the total running time is at most O(Ln + nd × 23.5d ). ⊓ ⊔ A Modified Algorithm: Now, we modify Algorithm 1. Every time we call closestString(), we always use some sj such that d(s1 , sj ) = d + δj is the biggest among all sj ∈ B. This algorithm is referred to as Algorithm 2. The point here is that we have to select k ≥ δj positions for each round and the number of remaining positions for rest rounds is at most k − δ. If δj is big, we can quickly get the (at most) d positions in the algorithm. Consider the execution of Algorithm 2. Assume that the first time the algorithm chooses to use string sj in Step 1 such that d(s1 , sj ) = d + δj is the biggest, and the second time the algorithm chooses sj ′ in Step 1 with d(s′ , sj ′ ) = d + δj ′ . Let U be the set of all positions in P (s1 , sj ) that were changed in Step 5 of the first round. Assume that |U | = δj + kk for some kk ≥ 0. Let s′ be the center obtained after the first round executive of the algorithm and S2 = {si |d(s′ , si ) > d for any si ∈ B} be the set of strings in B such that d(s′ , si ) > d. Let U ′ (si ) ⊆ U be the set of all positions in U such that s′ and si are identical for si ∈ S2 . Lemma 5. For any si ∈ S2 , |U ′ (si )| < δj +

kk 2 .

Proof. By the modification of the algorithm, d(s1 , sj ) = d + δj ≥ d(s1 , si ) for any si ∈ S2 . Thus, we have d(s1 , si ) ≤ d + δj . If |U ′ (si )| ≥ δj + kk 2 , then kk kk d(s′ , si ) ≤ d + δj ′ ≤ d + δj − (δj + kk ) + = d. (The other at most positions 2 2 2 in U are mismatches.) This is a contradiction to the definition of S2 . Therefore, |U ′ (si )| < δ + kk 2 for any si ∈ S2 . Lemma 5 shows that d(s′ , si |U ) ≥ kk 2 . Thus, the value of d(U, e) in Lemma 4 . It is easy to see that the value of kk is at most 0.5d. This can be reduced by kk 2 will further reduce the total running time of the algorithm. Theorem 3. The running time of Algorithm 2 is O(Ln + nd23.25d−0.25δ ).

3

The Binary Farthest String Problem

The farthest string problem is a special case of the distinguishing string selection problem, where B is empty. In this section, we consider the binary case, where each string in G is a binary string on {0, 1}. The main observation here is that

268

L. Wang and B. Zhu Algorithm: farthestString An instance of search space U , S e, s′ (center string), g1 ,g2 , . . ., gn . A string s such that d(s, gi ) ≥ d for i = 1, 2, . . . , n, or FALSE if there is no solution. find a string gj such that d(s′ , gj ) = L − (d + δj ) for some δj > 0 and δj is the biggest. if no gj is found in Step 1, return s′ as the output. if δj > e then returnNULL. R = P¯ (s′ , gj ) − U − gi ∈S P¯ (gi , gj ). for k = δj , δj + 1, . . . , e do Select k positions in R and convert them to the opposite letters. Add the selected positions to U . e = min{e − k, k − δj }. S = S ∪ {sj }. Call f arthestString(U, S, e, s′ , g1 , g2 , ..., gn ) if all the calls return NULL, then return FALSE

Input Output 1. 2. 3. 4. 5.

6.

Fig. 3. Algorithm 3: The farthestString()

a symmetric algorithm of closestString also works for the binary case of the farthest string problem. B asic I deas: The basic idea is to start with a center string s′ = g¯1 that is a complementary string of an arbitrarily fixed string g1 ∈ G, i.e., if g1 [k] = 0 then s′ [k] = 1 and if g1 [k] = 1 then s′ [k] = 0. We then try to select at most d positions to convert the letters to the opposite letters, i.e., 0 is converted to 1 and 1 is converted to 0. To reduce the search space, each time we consider to select some positions in P¯ (s′ , gj ) (of size at most 2db ) for some gj ∈ G. The algorithm is given in Figure 3. The initial values are as follows: s′ = g¯1 U = ∅; S = ∅ and e = db . We can verify that the following lemma that is symmetric to Lemma 1 holds. Lemma 6. Let U be the set of positions that have been correctly changed in the previous round. That is, s′ and the final center string s are identical at all positions in U . Let k be the maximum number of positions in P¯ (s′ , gj ) − U such that sj and the final center string s are identical at the k positions. Then k ≥ δ. Let e′ be the number of remaining positions that the algorithm can select at present and e be the number of remaining positions that the algorithm can select after one more round. Let k be the number of positions selected in this round and δj the value in Step 1 for this round. Similarly, we can verify that the following lemma that is symmetric to Lemma 2 holds. Lemma 7. e = min{e′ − k, k − δj }. Let U be the set of all positions in P (¯ g1 , sj ) that were converted to the opposite letters in Step 5 of the first round. Let s′ be the center string obtained after the first round executive of the algorithm and S2 = {gi |d(s′ , gi ) < L−db for any gi ∈ G} be the set of strings in G such that d(s′ , si ) < L − db . Let U ′ (gi ) ⊆ U be the

Efficient Algorithms for the Closest String

269

Algorithm: distinguishingString An instance of search space U , S, e, s′ (center string), s1 ,s2 , . . ., sn1 , gn1 +1 , gn1 +2 , . . ., gn2 . Output A string s such that d(s, si ) ≤ db for i = 1, 2, . . . , n and d(s, gi ) ≥ L−db for i = n1 + 1, n1 + 2, . . . n2 , or FALSE if there is no solution. 1. find a string sj ∈ B or gj ∈ G such that d(s′ , sj ) = db + δj or d(s′ , gj ) = L − (db + δj ) such that δj > 0 is the biggest for i = 1, 2, . . . , n2 . 2. if no sj or gj is found in Step 1, return s′ as the output. 3. if δj > e then return NULL. if sj is selected in  Step 1 then  R = P (s′ , sj ) − si ∈S P (s′ , si ) − gi ∈S P¯ (s′ , gi ) else   R = P¯ (s′ , gj ) − si ∈S P (s′ , si ) − gi ∈S P¯ (s′ , gi ). 4. for k = δj , δj + 1, . . . , e do 5. Select k positions in R and convert them to the letters identical to sj . Add the selected positions to U . e = min{e − k, k − δj }. S = S ∪ {sj }. Call closestString(U, S, e, s′ , s1 , s2 , ..., sn ) 6. if all the calls return NULL, then return FALSE Input

Fig. 4. Algorithm 4: The distinguishingString()

set of all positions in U such that gj and gi disagree for gi ∈ S2 . A symmetric version of Lemma 5 also holds. Theorem 4. The running time of Algorithm 3 is O(23.25d−0.25δ ).

4

The Binary Distinguishing String Selection Problem

Now, we are ready to give the algorithm for the distinguishing string selection problem. Again, we consider the binary case. The basic idea is to start with a string in B, say, s1 and try to select at most d positions to convert the letters at the selected positions. To reduce the search space, we select a string sj or gj in Step 1 and use select some positions in P (s′ , sj ) or P¯ (s′ , gj ), where s′ is the current center string. The algorithm is in fact a combination of Algorithm 2 and Algorithm 3. Again, we always select the string sj or gj such that δj is the biggest among all strings in B ∪ G in Step 1. The initial values are as follows: s′ = s1 , U = ∅, S = ∅ and e = db . The complete algorithm in given in Figure 4. Theorem 5. The running time of Algorithm 4 is O(Ln + nd23.25d−0.25δ ). Acknowledgments. Lusheng Wang is fully supported by a grant from the Research Grants Council of the Hong Kong Special Administrative Region, China [Project No. CityU 121207].

References ¨ 1. Lucas, K., Busch, M., MOssinger, S., Thompson, J.A.: An improved microcomputer program for finding gene- or gene family-specific oligonucleotides suitable as primers for polymerase chain reactions or as probes. CABIOS 7, 525–529 (1991)

270

L. Wang and B. Zhu

2. Lanctot, K., Li, M., Ma, B., Wang, S., Zhang, L.: Distinguishing string selection problems. In: Proc. 10th ACM-SIAM Symp. on Discrete Algorithms, pp. 633–642 (1999); also Information and Computation 185(1), 41–55 (2003) 3. Dopazo, J., Rodr´ıguez, A., S´ aiz, J.C., Sobrino, F.: Design of primers for PCR amplification of highly variable genomes. CABIOS 9, 123–125 (1993) 4. Proutski, V., Holme, E.C.: Primer master: A new program for the design and analysis of PCR primers. CABIOS 12, 253–255 (1996) 5. Gramm, J., Huffner, F., Niedermeier, R.: Closest strings, primer design, and motif search. In: Currents in Computational Molecular Biology, poster abstracts of RECOMB 2002, pp. 74–75 (2002) 6. Wang, Y., Chen, W., Li, X., Cheng, B.: Degenerated primer design to amplify the heavy chain variable region from immunoglobulin cDNA. BMC Bioinformatics 7(suppl. 4), S9 (2006) 7. Deng, X., Li, G., Li, Z., Ma, B., Wang, L.: Genetic design of drugs without sideeffects. SIAM Journal on Computing 32(4), 1073–1090 (2003) 8. Ben-Dor, A., Lancia, G., Perone, J., Ravi, R.: Banishing bias from consensus sequences. In: Hein, J., Apostolico, A. (eds.) CPM 1997. LNCS, vol. 1264, pp. 247– 261. Springer, Heidelberg (1997) 9. Wang, L., Dong, L.: Randomized algorithms for motif detection. Journal of Bioinformatics and Computational Biology 3(5), 1039–1052 (2005) 10. Davila, J., Balla, S., Rajasekaran, S.: Space and time efficient algorithms for planted motif search. In: Proceedings of International Conference on Computational Science, vol. (2), pp. 822–829 (2006) 11. Fellows, M.R., Gramm, J., Niedermeier, R.: On the parameterized intractability of motif search problems. Combinatorica 26(2), 141–167 (2006) 12. Frances, M., Litman, A.: On covering problems of codes. Theoretical Computer Science 30, 113–119 (1997) 13. Li, M., Ma, B., Wang, L.: On the closest string and substring problems. J. ACM 49(2), 157–171 (2002) 14. Ma, B., Sun, X.: More Efficient Algorithms for Closest String and Substring Problems. In: Vingron, M., Wong, L. (eds.) RECOMB 2008. LNCS (LNBI), vol. 4955, pp. 396–409. Springer, Heidelberg (2008) 15. Marx, D.: Closest Substring Problems with Small Distance. SIAM. J. Comput., Vol 38(4), 1382–1410 (2008) 16. Gramm, J., Guo, J., Niedermeier, R.: On exact and approximation algorithms for distinguishing substring selection. In: Lingas, A., Nilsson, B.J. (eds.) FCT 2003. LNCS, vol. 2751, pp. 195–209. Springer, Heidelberg (2003) 17. Gramm, J., Niedermeier, R., Rossmanith, P.: Fixed-Parameter Algorithms for CLOSEST STRING and Related Problems. Algorithmica 37(1), 25–42 (2003) 18. Stojanovic, N., Berman, P., Gumucio, D., Hardison, R., Miller, W.: A linear-time algorithm for the 1-mismatch problem. In: Proceedings of the 5th International Workshop on Algorithms and Data Structures, pp. 126–135 (1997) 19. Li, M., Ma, B., Wang, L.: Finding Similar Regions in Many Strings. In: Proceedings of the Thirty-first Annual ACM Symposium on Theory of Computing, Atlanta, pp. 473–482 (1999) 20. Li, M., Ma, B., Wang, L.: Finding Similar Regions in Many Sequences. J. Comput. Syst. Sci. 65(1-2), 111–132 (2002); special issue for Thirty-first Annual ACM Symposium on Theory of Computing (1999)

The BDD-Based Dynamic A* Algorithm for Real-Time Replanning⋆ Yanyan Xu1,2 , Weiya Yue3,⋆⋆ , and Kaile Su4 1

State Key Laboratory of Computer Science, Institute of Software, Chinese Academy of Sciences, Beijing, China 2 School of Information Science and Engineering, Graduate University of the Chinese Academy of Sciences, Beijing, China [email protected] 3 University of Cincinnati, Cincinnati, OH, USA [email protected] 4 Key Laboratory of High Confidence Software Technologies (Peking University), Ministry of Education, Beijing, China [email protected]

Abstract. Finding optimal path through a graph efficiently is central to many problems, including route planning for a mobile robot. BDDbased incremental heuristic search method uses heuristics to focus their search and reuses BDD-based information from previous searches to find solutions to series of similar search problems much faster than solving each search problem from scratch. In this paper, we apply BDD-based incremental heuristic search to robot navigation in unknown terrain, including goal-directed navigation in unknown terrain and mapping of unknown terrain. The resulting BDD-based dynamic A* (BDDD*) algorithm is capable of planning paths in unknown, partially known and changing environments in an efficient, optimal, and complete manner. We present properties about BDDD* and demonstrate experimentally the advantages of combining BDD-based incremental and heuristic search for the applications studied. We believe that our experimental results will make BDD-based D* like replanning algorithms more popular and enable robotics researchers to adapt them to additional applications.

1

Introduction

Incremental search methods reuse information from previous searches to find solutions to series of similar search problems much faster than solving each search problem from scratch [1]. Heuristic search methods, on the other hand, use heuristic information to guide the search to the goal and solve search problems much faster than uninformed search methods [2]. In the past several years, incremental heuristic algorithms, that generalize both incremental search and ⋆

⋆⋆

Supported by the National Natural Science Foundation of China under Grant Nos. 60721061, 60833001 and 60725207. Corresponding author.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 271–282, 2009. c Springer-Verlag Berlin Heidelberg 2009 

272

Y. Xu, W. Yue, and K. Su

heuristic search, have been developed. Examples include LPA* [3], D* lite [4,5] and DD* lite [6]. Recently, a BDD-based incremental algorithm [7], that reuses information from previous searches, has been proved to be an efficient method for replanning problems. It combines BDD-based search [8,9] with incremental heuristic search to repeatedly finds shortest paths from a start vertex to a goal vertex in a given graph as the topology of the graph changes. In this paper, we generalize BDDbased incremental search to BDD-based incremental heuristic search and apply it to robot navigation in unknown terrain. Building on BDD-based incremental heuristic search, we therefore present BDDD*, a replanning algorithm that implements the same navigation strategy as D* [10] but is algorithmically different. Our experiments show that BDDD* is an efficient algorithm and we believe that our theoretical and empirical analysis of BDDD* will provide a strong foundation for further research on fast replanning methods in artificial intelligence and robotics. In the following, we first generalize BDD-based incremental search to BDDbased incremental heuristic search. Then, based on BDD-based incremental heuristic search, we explain BDDD* algorithm. We then evaluate BDDD* experimentally in a range of search and replanning domains. Finally, we draw a conclusion and explain our future work.

2

Motivation

Consider a robot-navigation task in unknown terrain, where the robot always observes which of its adjacent vertices are traversable and then moves to the one with the minimal cost. The robot starts at vstart and wants to move to vgoal . It always computes a shortest path from its current vertex to the goal vertex under the assumption that vertices with unknown blockage status are traversable with their costs. It then follows this path until it reaches the goal vertex, in which case it stops successfully, or the topology of the search graph changes, in which case it recomputes a shortest path from the current vertex to the goal vertex. It can utilize initial knowledge about the blockage status of vertices in case it is available. A simple example is shown in Figure 1. There are two graphs in Figure 1. The left one is the initial graph and the right one is the changed graph. In the changed graph, the vertex v4 and its two related edges (v3 → v4 and v4 → v5 ) are deleted, so we draw them with dashed lines. As the topology of the graph h=2

V1

h=1 1

h=2

V2

V1

1

h=1 1

V2

1 4

h=3

V0

4

V0 V5

h=3 1

V3 h=2

2

V4 h=1

2

h=0

V5 1

V3

2

h=3 h=2

Fig. 1. A simple example

V4

2

h=0

The BDD-Based Dynamic A* Algorithm for Real-Time Replanning

273

changes, we always need recalculate a shortest path from the current vertex of the robot to the goal vertex. Notice that only one vertex has been deleted in the changed graph and the other vertices remain unchanged. Thus, we can reuse previous search results to repeatedly find shortest paths from the current vertex to the goal vertex as the topology of the graph changes. This is what BDD-based incremental heuristic search does.

3

BDD-Based Incremental Heuristic Search

We now describe BDD-based heuristic search and BDD-based incremental search, and then combine them to develop BDD-based incremental heuristic search. 3.1

BDD-Based Heuristic Search

Definition 1. A search problem can be represented by a tuple (V, T, i, G): – V is the set of vertices, – T ⊆ V × N + × V is a transition relation which represents the set of weighted edges, and (v, c, v ′ ) ∈ T iff there exists a weighted edge from v to v ′ with cost c, – i is the initial vertex, and – G is the set of goal vertices. (V, T ) defines the search graph and a solution to a search problem (V, T, i, G) is a path π = v0 , ..., vn where v0 = i, vn ∈ G and (vj , c(vj ,vj+1 ) , vj+1 ) ∈ T for n−1 0 ≤ j ≤ n − 1. Define the function cost(π)= j=0 c(vj ,vj+1 ) , then an optimal solution is a path π such that cost(π) ≤ cost(π ′ ) for any other solution π ′ . In BDD-based heuristic search, we need encode vertices and costs as boolean vectors, and then BDDs can be used to represent the characteristic functions of a set of vertices ΦV , the transition relation ΦT and the priority queue Open consisting of a set of vertices with their f -values. To make this clear, consider the left search graph in Figure 1. The graph consists of six vertices v0 -v5 and six weighted edges. The h-value of each vertex and costs of edges are marked on the graph. A vertex v is represented by a bit vector with three elements v = (x0 x1 x2 ). According to the h-value and costs of edges in the graph, we get the minimal h-value is 0 and the maximal f -value is 6, so we need three boolean variables (c0 c1 c2 ) to encode them. To represent the transition relation T using a BDD, we first need to refer to current vertex variables and next vertex variables. We adopt the usual notation in BDD literature of primed variables for the next state, so we use x′ = (x′0 x′1 x′2 ) to encode next vertex variables. The BDD for T is depicted in the left graph of Figure 21 . 1

In this paper, we don’t consider the variable orderings on BDDs and just use cudd2.4.1 to perform it. Moreover, for convenience, we only draw the paths leading to the leaf vertex labeled 1. The paths leading to the leaf vertex labeled 0 are omitted.

274

Y. Xu, W. Yue, and K. Su c0

c0

c1

c1

c1

c1

c2

c2

c2

c2

c2

x0

x0

x0

x0

x0

x1

x1

x1

x2

x2

x2

x2

X0'

X0'

X0'

x1

x1

x2 X0'

X0'

x1

X1'

X1'

X2'

X1'

X2'

X0'

X0'

X1'

X1'

X2'

X2'

1

1

T

T'

Fig. 2. The BDDs for T and T ′

c0

c0

c1

c1

c1

c1

c2

c2

c2

c2

c2

c2

x0

x0

x0

x0

x0

x0

x0

x1

x1

x1

x1

x1

x2

x2

x2

x1

c0

c0

c0

c1

c1 c2

c2

x2

x2

x2

1

1

1

1

1

1

2

3

4

5

Fig. 3. The BDDs for Open

The priority queue Open can be seen as a set of tuples (v,f -value). BDD allows sets of vertices to be represented very efficiently. The vertices in Open are expanded one after another and the ExistAnd() function V ′ = (∃x.V (x) ∧ T (x, x′ ))[x/x′] determines all successor vertices V ′ of the set V in one evaluation step. Consider the left graph in Figure 1. Let v0 be vstart and v5 be vgoal . The priority queues we get step by step are shown in Figure 3, and finally we have found an optimal solution path v0 → v3 → v4 → v5 with its cost 5. 3.2

BDD-Based Incremental Search

As the topology of the graph changes, the transition relation T will change. BDD-based incremental search uses the previous BDD for T to construct the new BDD for the changed transition relation T ′ . Lemmas and theorems below will help to get the new BDD T ′ .

The BDD-Based Dynamic A* Algorithm for Real-Time Replanning

275

Lemma 1. Given an BDD T , if we delete a path p, which is represented by a cube c, from T , then we can get the new BDD T ′ through T ∧ ¬c, that is, T ′ =T ∧ ¬c. P roof. Trivial. Lemma 2. Given an BDD T , if we add a path p, which is represented by a cube c, to T , then we can get the new BDD T ′ through T ∨ c, that is, T ′ =T ∨ c. P roof. Trivial. Theorem 1. Let the BDD for the transition relation of the graph G be T . If a vertex v and all its related edges are deleted, then we can get the new BDD for the changed transition relation T ′ of the new graph G′ through the two steps below: – Let V be the BDD for the vertex v, and let BDD O=T ∧ ¬V ; – let V ′ be the BDD for the primed representation of the vertex v, then T ′ = O ∧ ¬V ′ . P roof. The vertex v and all its related edges are deleted, so in the new graph G′ , v has no transition to its successors and v’s predecessors have no transition to v, either. The transitions among other vertices would not be affected by deleting v. – Since O=T ∧ ¬V , by Lemma 1, we know that in the BDD O, the vertex v has no transition to other vertices; – Since T ′ =O ∧ ¬V ′ , by Lemma 1, we know that in the BDD T ′ , v’s predecessors have no transition to v, either. So, after the two steps, we can get T ′ , which is the transition relation of the new graph G′ . Theorem 2. Let the BDD for the transition relation of the graph G be T . If we add a vertex v and edges related to v to G, then we can get the BDD for the new transition relation T ′ of the new graph G′ through the two steps below: – Let the BDD for the transition relation of v to its successors be Tv→succ(v) , and let O=T ∨ Tv→succ(v) ; – Let the BDD for the transition relation of v’s predecessors to v be Tprev(v)→v , and then T ′ =O ∨ Tprev(v)→v . P roof. Similar to the proof of Theorem 1 (by Lemma 2). Theorem 3. Let the BDD for the transition relation of the graph G be T . When the cost of an edge is changed, for example, (v, c, v ′ ) → (v, c′ , v ′ ), then we can get the BDD for the new transition relation T ′ of the new graph G′ through the two steps below: – Let the BDD for the transition relation (v, c, v ′ ) be T(v,c,v′ ) , and let O=T ∧ ¬T(v,c,v′ ) ; – Let the BDD for the transition relation (v, c′ , v ′ ) be T(v,c′ ,v′ ) , and then T ′ = O ∨ T(v,c′ ,v′ ) .

276

Y. Xu, W. Yue, and K. Su

P roof. Similar to the proof of Theorem 1 (by Lemma 1 and 2). According to Theorem 1, 2 and 3, we can use the old transition relation T to get the new transition relation T ′ as the topology of the graph changes. The example in Figure 1 will help us to understand the procedure. Using Theorem 1, we can get the BDD for the transition relation T ′ of the changed graph (the right one) in Figure 1, and it is shown in the right graph of Figure 2. We omit the temp BDDs used in this procedure. 3.3

BDD-Based Incremental Heuristic Search

Given a graph, BDD-based incremental heuristic search first searches a shortest path using the method shown in section 3.1, and as the topology of the graph changes, it updates the transition relation T using Theorem 1, 2 and 3, and then it researches the shortest paths again and again. We now present the property of BDD-based incremental heuristic search to show that it terminates, is correct, similar to A*, and efficient. We omit the proof due to the space limitation. Theorem 4. Given an admissible heuristic function h, BDD-based incremental heuristic search is optimal and complete.

4

BDD-Based Dynamic A* (BDDD*)

So far, we have described BDD-based incremental heuristic search, that repeatedly determines shortest path between vstart and vgoal as the topology of the graph changes. We now use BDD-based incremental heuristic search to develop BDDD*, that repeatedly determines shortest paths between the current vertex of the robot and the goal vertex as the topology of the graph changes while the robot moves towards the goal vertex. BDDD* is a dynamic, incremental heuristic search algorithm intended for solving problems of robot navigation over unknown and changing terrain. BDDD* attempts to determine the lowest cost sequence of rounds that will take a robot from vstart to vgoal , where each round is a movement of the robot along a weighted edge to another vertex, and sequence cost is the sum of costs of the edges traversed as they were traversed. The problem is complicated because it allows edge costs to change between moves; these changes are unknown until they happen and they are not predictable. BDDD* terminates when the robot reaches the goal vertex or it finds there is no path. Like D* algorithm, BDDD* searches from vgoal to vstart , and it is assisted by two functions which estimate the cost of the shortest path from vgoal to any v based on current edge costs. One function, g(v) estimates costs from vgoal , which is identical to the function used by A*. Another, more informed onestep-lookahead estimate based on g(v), is expressed as a function (Succ(v) ∈ V denotes the set of successors of v ∈ V in the graph):  0 if v = vgoal rhs(v) = minv′ ∈Succ(v) (g(v ′ ) + c(v, v ′ )) otherwise.

The BDD-Based Dynamic A* Algorithm for Real-Time Replanning

277

The name rhs comes from DynamicSWSF-FP where they are the values of the right-hand sides (rhs) of grammar rules. The heuristics h(v, v ′ ) estimate the distance between vertex v and v ′ , and need to satisfy h(vstart , vstart ) = 0 and h(vstart,v ) ≤ h(vstart,v′ ) + c(v ′ , v) for all vertices v ∈ V and v ′ ∈ P red(v) (P red(v) ∈ V denotes the set of predecessors of v ∈ V ). More generally, since the robot moves and thus changes vstart , the heuristics need to satisfy this property for all vstart ∈ V . A vertex v is called locally consistent iff rhs(v) = g(v), otherwise it is called locally inconsistent. Shortest path costs from all vertices to vgoal are known precisely if and only if all vertices are locally consistent. In that case, shortest paths can be computed by following minimum edge costs, ties can be broken arbitrarily. BDDD* maintains a priority queue BDDopen and the priority queue always contains exactly the inconsistent vertices whose g-values BDDD* needs to update to make them consistent. The priority of vertex v in BDDopen is always k(v) = [k1 (v); k2 (v)], where k1 (v) = min(g(v), rhs(v)) + h(vstart , v) and k2 (v) = min(g(v), rhs(v)). The priorities are compared according to a lexicographic ordering. BDDD* recalculates the g-values of vertices in BDDopen (expands the vertices) in the order of increasing k1 (v), which correspond to the f -values of an A* search, and vertices with equal k1 (v) in order of increasing k2 (v), which correspond to the g-values of an A* search. Thus, BDDD* expands vertices in a similar order as an A* search. We present the pseudo-code of BDDD* in Figure 4. The pseudo-code uses the following functions to manage the priority queue BDDopen : BDDopen .LeftKey() returns the smallest priority of all vertices in BDDopen (If BDDopen is empty, then BDDopen .LeftKey() returns [∞; ∞].); BDDopen .Left() deletes the vertex with the smallest priority in BDDopen and returns the vertex; BDDopen . Insert (v, k) conjoins BDDv with the priority k with BDDopen ; BDDopen . Update(v, k) changes the priority of vertex v in BDDopen to k (It does nothing if the current priority of vertex v already equals k.); BDDopen . Remove(v) removes vertex v from priority queue BDDopen . The main function Main() first calls Initialize() to initialize the path-planning problem {02}. Initialize() sets the initial g-values of all vertices to ∞ and sets their rhs-values according to the definition of rhs(v) {20}. Thus, initially vgoal is the only locally inconsistent vertex and is inserted into BDDopen with a key {22}. This initialization guarantees that the first call to ComputeShortesPath() performs exactly a BDD-based heuristic search. BDDD* then scans graph for changed edge costs {07}. If some edge costs have changed, it calls UpdateVertex() {18} to update the rhs-values and keys of the vertices potentially affected by the changed edge costs as well as their membership in BDDopen if they become locally consistent or inconsistent, and finally recalculates a shortest path by calling ComputeShortestPath() {19}, that repeatedly expands locally inconsistent vertices in order of their priorities {27}. A locally inconsistent vertex v is called locally overconsistent iff g(v) > rhs(v). When ComputeShortestPath() expands a locally overconsistent vertex {32-33}, then it sets the g-value of the vertex to its rhs-value, which makes the vertex

278

Y. Xu, W. Yue, and K. Su procedure Main() 01 vlast = vstart ; 02 Initialize(); 03 ComputeShortestP ath(); 04 while(vstart = vgoal ) 05 vstart = arg minv′ ∈Succ(vstart ) (g(v ′ ) + c(vstart , v ′ )); 06 M ove to vstart ; 07 Scan graph f or changed edge costs; 08 if any edge costs changed 09 km = km + h(vlast , vstart ); 10 vlast = vstart ; 11 f or all directed edges (u, v) with changed edge costs 12 cold = c(u, v); 13 U pdate the edge cost c(u, v); 14 if (cold > c(u, v)) 15 if (u = vgoal ) rhs(u) = min(rhs(u), g(v) + c(u, v)); 16 else if (rhs(u) = cold + g(v)) 17 if (u = vgoal ) rhs(u) = minv′ ∈Succ(u) (g(v ′ ) + c(u, v ′ )); 18 U pdateV ertex(u); 19 ComputeShortestP ath(); procedure Initialize() 20 f or all v ∈ V rhs(v) = g(v) = ∞, rhs(vgoal ) = 0; //Construct BDDrhsg 21 Construct BDDT , BDDvstart , and BDDvgoal , and km = 0; 22 BDDopen = BDD([h(vstart ,vgoal );0],vgoal ) ; procedure UpdateVertex(v) 23 if (g(v) = rhs(v) && v ∈ BDDopen ) BDDopen .U pdate(v, CalculateKey(v)); 24 else if (g(v) = rhs(v) && v ∈ BDDopen ) BDDopen .Insert(BDD(CalculateKey(v),v) ); 25 else if (g(v) = rhs(v) && v ∈ BDDopen ) BDDopen .Remove(v); procedure ComputeShortestPath() . 26 while(BDDopen .Lef tKey() < CalculateKey(vstart ) || rhs(vstart ) = g(vstart )) 27 u = BDDopen .Lef t(); 28 kold = BDDopen .Lef tKey(); 29 knew = CalculateKey(u); . 30 if (kold < knew ) 31 BDDopen .U pdate(u, knew ); 32 else if (g(u) > rhs(u)) 33 g(u) = rhs(u); 34 BDDopen .Remove(u); 35 f or all v ∈ {∃x.(BDDT ∧ BDDu )} 36 if (v = vgoal ) rhs(v) = min(rhs(v), g(u) + c(v, u)) 37 U pdateV ertex(v); 38 else 39 gold = g(u); 40 g(u) = ∞; 41 f or all v ∈ {u} ∪ {∃x.(BDDT ∧ BDDu )} 42 if (rhs(v) = gold + c(v, u)) 43 if (v = vgoal ) rhs(v) = minv′ ∈Succ(v) (g(v ′ ) + c(v, v ′ )) 44 U pdateV ertex(v); procedure CalculateKey(v) 45 return [min(g(v), rhs(v)) + h(vstart , v) + km ; min(g(v), rhs(v))];

Fig. 4. BDDD*

locally consistent. A locally inconsistent vertex v is called underconsistent iff g(v) < rhs(v). When ComputeShortestPath() expands a locally underconsistent vertex {40}, then it simply sets the g-value of the vertex to ∞. This makes the vertex either locally consistent or overconsistent. ComputeShortestPath() therefore updates the rhs-values, checks their local consistency, and adds them to or removes them from BDDopen accordingly {23-25}. BDDD* expands vertices until vcurrent is locally consistent and the key of the vertex to expand next is no less than the key of vstart . If g(vcurrent ) = ∞ after the search, then there is no path from vgoal to vcurrent . In BDDD*, we use BDDrhsg to represent the rhs-values and g-values. Moreover, if a vertex is deleted (or blocked), it means the costs of the edges related to the vertex are changed to ∞), so we need represent the ∞-value in BDDT , BDDrhsg and BDDopen . We use an additional boolean variable to represent the ∞-value. If the value of the additional boolean variable is 1, it means the

The BDD-Based Dynamic A* Algorithm for Real-Time Replanning r0

279

r0

r1

r1

r2

r2

r3

r3

r1

r2

r3

r3

r2

r2

r3

r3

r3

g0

g0

g0

g0

g0

g0

g0

g0

g0

g0

g1

g1

g1

g1

g1

g1

g1

g1

g1

g1

g2

g2

g2

g2

g2

g2

g2

g2

g2

g2

g3

g3

g3

g3

g3

g3

g3

g3

g3

g3

x0

x0

x0

x0

x0

x0

x0

x0

x0

x0

x1

x1

x1

x1

x1

x1

x1

x1

x2

x2

x2 1 BDDrhsg

x2 1 BDDrhsg’

′ Fig. 5. BDDrhsg and BDDrhsg

rhs-value, g-value, f -value or the edge cost is ∞, and if the value of the additional boolean variable is 0, we represent the rhs-value, g-value, f -value or the edge cost as usual. To make this clean, in Figure 5, we give the two final ′ according to the two graphs in Figure 1 (r0 and g0 are BDDrhsg and BDDrhsg the two additional boolean variables), respectively. Notice that, Like BDDopen , BDDrhsg changes continuously during the search. When changes are found, BDDD* reconstructs BDDT , and then it recomputes a new shortest path from vcurrent to vgoal . It is unlikely that BDDD* will find the shortest path that advances the robot from vstart to vgoal because it never has complete information about edge cost changes until the last transition. Moreover, current edge costs are known to BDDD* only within the robot’s view which consists of the edges that are within a fixed distance, called the sensor-radius, from the current position of the robot. However, BDDD* can find the shortest path from vcurrent to vgoal based on the known edge costs within the view and assuming that current estimates of other edge costs are their actual costs. When it does so, it follows the path until this assumption is violated at some vertex v that is within the view. At that point, BDDD* recomputes a new shortest path from vcurrent to vgoal and repeats these procedures until the robot reaches vgoal . In BDDD*, ComputeShortestPath() performs the operations for vertices in the exact same order as it does in D* lite, which implies BDDD* shares many properties with D* lite, including the correctness of ComputeShortestPath() which implies the correctness of BDDD*.

280

Y. Xu, W. Yue, and K. Su

Theorem 5. BDDD* always terminates and one can then follow a shortest path from vcurrent to vgoal by always moving from the current vertex vcurrent , to any successor v ′ that minimizes c(v,v’)+g(v’) until vgoal is reached. Now we analyze the complexity of BDDD*. In BDDD*, there are mainly three BDDs: BDDopen , BDDT and BDDrhsg . Given an n ∗ n maze, there are n2 vertices, but we only need log2 n2 variables to construct BDDs for representing these vertices. Moreover, because of the compact representation of BDDs, the space complexity of BDDD* is expected to be lower than A*. In [7], BDDRPA* benefits from the compact representation of BDDs. Like A*, the time complexity of BDDD* also depends on the heuristic function h.

5

Experimental Results

In this section, the performance of BDDD* (BDDD∗1 ) is compared experimentally to the BDD-based Dynamic A* without using the incremental method (BDDD∗2 ) introduced in section 3.2 on random grid world terrains. In each experiment the initial terrain is a grid world created randomly of n2 vertices, where vstart and vgoal are chosen randomly and n is 50, 100 or 200. On the initial round exactly 0.2*n2 of the vertices are selected randomly and blocked. On succeeding rounds, each of the blocked vertices moves to some adjacent vertex with probability 0.5, the particular target vertex being chosen randomly from all available adjacent vertices. BDDD∗1 and BDDD∗2 witnesses the same initial, and succeeding terrains. The time for an algorithm to compute a path from vstart to vgoal is measured as averages over 100, 60, and 40 experiments for n=50, 100, 200, respectively. The results show the time to compute a path plotted against sensorradius for fixed n and percentage of vertices blocked (20%), and fixed n and sensorradius (5, 10 and 20 for n=50, 100, 200 respectively) in Figures 6 to 8. Because of the compact representation of BDDs, BDDA* [8], SetA* [9] and BDDRPA* [7] are proved to be powerful BDD-based search algorithms. Figures 6 to 8 show that BDDD* takes less time to compute a path from vstart to vgoal with using the incremental techniques introduced in section 3.2, and thus is proved to be an efficient BDD-based dynamic incremental heuristic algorithm. 4.5

4

BDDD*1 BDDD*2

4 3.5

3

3

time(s)

time(s)

BDDD*1 BDDD*2

3.5

2.5 2

2.5 2 1.5

1.5 1

1

0.5

0.5

10

15

20

25

30

35

40

1

percent vertices blocked

Fig. 6. n=50

1.5

2

2.5 3 3.5 sensor-radius

4

4.5

5

The BDD-Based Dynamic A* Algorithm for Real-Time Replanning 40

BDDD*1 BDDD*2

35

30

30

25

25

time(s)

time(s)

40

BDDD*1 BDDD*2

35

20 15

20 15

10

10

5

5

0

281

0 10

15

20

25

30

35

40

1

2

3

4

percent vertices blocked

5

6

7

8

9

10

sensor-radius

Fig. 7. n=100 300 250

300

BDDD*1 BDDD*2

200 time(s)

200 time(s)

BDDD*1 BDDD*2

250

150

150

100

100

50

50

0

0 10

15

20

25

30

35

40

0

percent vertices blocked

2

4

6

8

10 12 14 16 18 20

sensor-radius

Fig. 8. n=200

6

Conclusion

In this paper, we have presented BDDD*, a fast replanning method for goaldirected navigation in unknown terrain that implements the same navigation strategy as D* and D* lite. These algorithms search from the goal vertex towards the current vertex of the robot with using heuristics to focus the search, and use similar ways to minimize reordering the priority queue. However, BDDD* builds on BDD-based incremental heuristic search, that has been proved to be an efficient method for replanning problem. Thus, BDDD* is different from D* lite in the data structure. In future, we will consider some methods to improve the efficiency of BDDD*. For example, we will omit some unnecessary recalculation between robot movements and use the techniques in [9]. We believe that our results will make BDDD*-like replanning algorithms even more popular and enable robotics researchers to adapt them to additional applications.

References 1. Frigioni, D., Marchetti-Spaccamela, A., Nanni, U.: Fully dynamic algorithms for maintaining shortest paths trees. Journal of Algorithms 34(2), 251–281 (2000) 2. Pearl, J.: Heuristics: Intelligent Search Strtegies for Computer Problem Sloving. Addison-Wesley Longman Publishing Co., Inc., Boston (1984)

282

Y. Xu, W. Yue, and K. Su

3. Koenig, S., Likhachev, M., Furcy, D.: Lifelong Planning A*. Artificial Intelligence Journal 155(1-2), 93–146 (2004) 4. Koenig, S., Likhachev, M.: D* Lite. In: Proceedings of the Eighteenth National Conference on Artificial Intelligence and Fourteenth Conference on Innovative Applications of Artificial Intelligence. AAAI 2002, pp. 476–483. AAAI Press, Menlo Park (2002) 5. Ferguson, D., Stentz, A.: The Delayed D* algorithm for Efficient Path Replanning. In: Proceedings of the IEEE International Conference on Robotics and Automation, pp. 2045–2050 (2005) 6. Ayorkor Mills-Tettey, G.: Anthony Stentz and M. Bernardine Dias: DD* Lite: Efficient Incremental Search with State Dominance. In: Proceedings of the twenty-first national conference on Artificial intelligence (AAAI 2006), pp. 1032–1038 (2006) 7. Yue, W., Xu, Y., Su, K.: BDDRPA*: An Efficient BDD-Based Incremental Heuristic Search Algorithm for Replanning. In: Australian Conference on Artificial Intelligence, pp. 627–636 (2006) 8. Edelkamp, S., Reffel, F.: OBDDs in heuristic search. In: Herzog, O. (ed.) KI 1998. LNCS, vol. 1504, pp. 81–92. Springer, Heidelberg (1998) 9. Jensen, R.M., Veloso, M.M., Bryant, R.E.: State-Set branching: leveraging BDDs for heuristic search. Artificial Intelligence 172, 103–139 (2008) 10. Stentz, A.: The Focussed D* Algorithm for Real-Time Replanning. In: Proceddings of the International Joint Conference on Artificial Intelligence. IJCAI, pp. 1652– 1659. Morgan Kanfmann Publishers Inc., San Fransisco (1995)

Approximating Scheduling Machines with Capacity Constraints Chi Zhang⋆ , Gang Wang, Xiaoguang Liu, and Jing Liu Nankai-Baidu Joint Lab, College of Information Technical Science, Nankai University Abstract. In the Scheduling Machines with Capacity Constraints problem, we are given  k identical machines, each of which can process at most mi jobs. M ≤ ki=1 mi jobs are also given, job j has a non-negative processing time length tj ≥ 0. The task is to find a schedule such that the makespan is minimized and the capacity constraints are met. In this paper, we present a 3-approximation algorithm using an extension of Iterative Rounding Method introduced by Jain [4]. To the best of the authors’ knowledge, this is the first attempt to apply Iterative Rounding Method to scheduling problem with capacity constraints. Keywords: Approximation, Scheduling, Capacity Constraints, Iterative Rounding.

1

Introduction

We consider the Scheduling Machines with Capacity Constraints problem (SMCC): There are kidentical machines, and machine i can process at most mi jobs. Given M ≤ 1≤i≤k mi jobs with their processing time lengths, we are to find a schedule of jobs to machines that minimizes the makespan and meets the capacity constraints. Scheduling problem is a classical N P-Hard problem and has been studied extensively. In the general setting, we are given set T of tasks, number k of machines, length l(t, i) ∈ Z + for each t ∈ T and machine i ∈ [1..k], the task is to find aschedule for T , namely, a function f : T → [1..k], to minimize maxi∈[1..k] t∈T,f (t)=i l(t, i) . Lenstra, Shmoys and Tardos [6] gave a 2approximation algorithm for the general version and proved that for any ǫ > 0 no ( 23 − ǫ)-approximation algorithm exists unless P = N P . Their method based on applying rounding techniques on fractional solution to linear programming relaxation. Gairing, Monien and Woclaw [2] gave a faster combinatorial 2-approximation algorithm for the general problem. They replaced the classical technique of solving the LP-relaxation and rounding afterwards by a completely integral approach. For the variation in which the number of processors k is constant, Angel, Bampis and Kononov [1] gave a fully polynomial-time approximation scheme (FPTAS). For the uniform variation where l(t, i) is independent ⋆

[email protected]. Supported in part by the National High Technology Research and Development Program of China (2008AA01Z401), NSFC of China (90612001), SRFDP of China (20070055054), and Science and Technology Development Plan of Tianjin (08JCYBJC13000).

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 283–292, 2009. c Springer-Verlag Berlin Heidelberg 2009 

284

C. Zhang et al.

of the processor i, Hochbaum and Shmoys [3] gave a polynomial-time approximation scheme (PTAS). The SMCC problem is one of the uniform variations, with capacity constraints on machines. One special case of SMCC problem in which there are only two identical machines was studied in [8] [10] [11]. Woeginger [9] gave a FPTAS for the same problem. General SMCC problem is a natural generalization of scheduling problem without capacity constraints and can be used in some applications in real world, such as students distributions in university, the Crew Scheduling problem in Airlines Scheduling [12] [13], etc. In the Crew Scheduling problem, crew rotations, sequences of flights legs to be flown by a single crew over a period of a few days, are given. Crews are paid by the amount of flying hours, which is determined by the scheduled rotations. Airline company wants to equalize the salaries of crews, i.e. to make the highest salary paid to crews minimum. Rotations starts and ends at the same crew base and must satisfy a large set of work rules based labor contracts covering crew personnel. In the concern of safety issues, one common contract requirement is the maximum times of flying of a single crew in a period of time. So the aim is to find a scheduling of rotations to crews that minimizes the highest salary and meets the maximum flying times constraints. In many literature, researchers approached scheduling problem using rounding techniques. Lenstra, Shmoys and Tardos [6] applied rounding method to the decision problem to derive a ρ-relaxed decision procedure and then used a binary search to obtain an approximation solution. In the SMCC problem, the capacity constraints defeat many previous methods. In this paper, our algorithm is one of the class of rounding algorithms, but use a different rounding method introduced by Jain [4]. We do not round off the whole fractional solution in a single stage. Instead, we round it off iteratively. Iterative Rounding Method, introduced by Jain [4], was used in his breakthrough work on the Survivable Network Design problem. This rounding method does not need the half-integrality, but only requires that at each iteration there exist some variables with bounded values. In [4], Jain observed that at each iteration one can always find a edge e has xe at least 1/2, which ensures that the algorithm has an approximation ratio of 2 . As a successful extension of Jain’s method, Mohit Singh and Lap Chi Lau [7] considered the Minimum Bounded Degree Spanning Trees problem and gave an algorithm that produces a solution, which has at most the cost of optimal solution while violating vertices degrees constraints by 1 at most. As far as the authors know, Iterative Rounding Method has been used in graph problems, and has produced many beautiful results. In this paper, we apply Iterative Rounding Method to the scheduling problem with capacity constraints and obtain a 3-approximation algorithm. To the best of the authors’ knowledge, this is the first attempt to approach scheduling problem with capacity constraints using Iterative Rounding Method. The rest of the paper is organized as follows. In Section 2, we formulate the SMCC problem as an Integer Program, give its natural relaxation and introduce our relaxation, Bounded Linear Programming Relaxation (BLPR). In Section 3, we present some properties of BLPR and prove theorems that support our

Approximating Scheduling Machines with Capacity Constraints

285

algorithm. In Section 4, we present two bounding theorems and an approximation algorithm, IRA, and prove that it has an approximation ratio of 3.

2

Preliminary

Formally, the SMCC problem is as follows: Given a positive integer k, k positive integers {mi |mi > 0, 1 ≤ i ≤ k}, M non-negative integers {tj |tj ≥ 0, 1 ≤ j ≤  M ≤ ki=1 mi }, solve the following Integer Program (IP): minimize c M 1≤i≤k subject to j=1 xij tj − c ≤ 0 M x ≤ m 1 ≤i≤k ij i j=1 k 1≤j≤M i=1 xij = 1 xij ∈ {0, 1} 1 ≤ i ≤ k, 1 ≤ j ≤ M k M ≤ i=1 mi There are some relaxations, one of which is the following natural Linear Programming Relaxation (LPR) dropping the integrality constraints. minimize c M 1≤i≤k subject to j=1 xij tj − c ≤ 0 M x ≤ m 1 ≤i≤k ij i j=1 k 1≤j≤M i=1 xij = 1 1 ≤ i ≤ k, 1 ≤ j ≤ M xij ≥ 0 k M ≤ i=1 mi We don’t use LPR directly, but use an alternative relaxation, Bounded Linear Programming Relaxation (BLPR): Given a positive integer k, k positive integers {m |m > 0, 1 ≤ i ≤ k}, M non-negative integers {tj |tj ≥ 0, 1 ≤ j ≤ M ≤ ki i i=1 mi }, a real vector b = (b1 , b2 , . . . , bk ) and F ⊆ {(i, j)|1 ≤ i ≤ k, 1 ≤ j ≤ M }, find a solution under the following constraints subject to

M 

xij tj ≤ bi

1≤i≤k

(1)

1≤i≤k

(2)

1≤j≤M

(3)

j=1

M 

xij ≤ mi

k 

xij = 1

j=1

i=1

xij = 1

(i, j) ∈ F

(4)

xij ≥ 0

1 ≤ i ≤ k, 1 ≤ j ≤ M

(5)

M≤

k  i=1

mi

286

C. Zhang et al.

where vector b = (b1 , b2 , . . . , bk ), called upper bounding vector, is added to depict the upper bounds of lengths of machines more precisely, and F is added to represent the partial solution in algorithm. Each (i, j) ∈ F indicates that job j has been scheduled to machine i . Those {xij |(i, j) ∈ F } are considered as constants. We will show that properly constructing vector b = (b1 , b2 , . . . , bk ) makes the solution produced by our algorithm under control and easy to analyze. Definition 1. In a BLPR problem Λ, upper bounding vector b = (b1 , b2 , . . . , bk ) is called feasible if Λ is feasible. Keeping the upper bounding vector b feasible all the time is the key of our algorithm, which guarantees that we can always find a feasible solution bounded by b.

3

Techniques

Before we present our algorithm, we need to introduce some properties of BLPR. With respect to the partial solution F , let ci denote the number of already scheduled jobs in machine i, namely, ci = |{(i, j)|(i, j) ∈ F }| . Note that mi − ci indicates the free capacity in machine i . We call a job free if it has not been scheduled to any machine and call a machine free if it still has free capacity. For a feasible fractional solution x to Λ, define a bipartite graph G(x) = G(L, R, E), called supporting graph, where L represents the set of free machines, R represents the set of free jobs and / F } . If a job is free, we call it special if its degree in E = {(i, j)|xij > 0, (i, j) ∈ G(x) is at most 2 . We denote the number of free jobs and the  number of free machines by M ∗ and k ∗ respectively. Note that for free job j, (i,j)∈E xij = 1 . Consider the Constraint Matrix of Λ, which consists of the coefficients of the left side of equalities and inequalities, except for the non-negativity constraints from (5):  ⎛ ⎞ t1 t2 . . . tM   ⎜ ⎟ t1 t2 . . . tM ⎜ ⎟ ⎜ ⎟ .. ⎜ ⎟ .  ⎟ ⎜ ⎜ t1 t2 . . . tM ⎟ ⎜  ⎟  ⎜ 1 1 ... 1 ⎟ ⎜ ⎟   ⎜ ⎟ 1 1 ... 1 ⎜ ⎟ (6) ⎜ ⎟ .. ⎜ ⎟ . ⎜   ⎟ ⎜ ⎟ ⎜⎛ ⎞ ⎛ ⎞ ⎛1 1 . . . 1⎞ ⎟ ⎜ 1 ⎟ 1 1 ⎜ ⎟ ⎜⎜ 1 ⎟ ⎜ 1 ⎟ ⎟⎟ ⎜ 1 ⎜⎜ ⎟ ⎜ ⎟ ⎟⎟ ⎜ ⎜⎜ ⎟ ... ⎜ ⎜ .. ⎟ .. ⎟ .. ⎟ ⎝⎝ ⎝ . ⎠ ⎝ . ⎠ . ⎠⎠ 1 1 1 where the 1st to kth rows represent the constraints from (1), the (k + 1)th to (2k)th rows represent the constraints from (2), and the (2k + 1)th to (2k + M )th rows represent the constraints from (3).

Approximating Scheduling Machines with Capacity Constraints

287

One can verify that the (k + 1)th row can be linearly expressed by the rest of rows. Thus the rank of Constraints Matrix is bounded by the following lemma Lemma 1. Constraints Matrix has a rank at most M + 2k − 1 .

⊓ ⊔

Recall that, a basic solution x to Λ is the unique solution determined by a set of linearly independent tight constraints that are satisfied as equalities. We remove all zero variables in x so that no tight constraints comes from (5). Thus the number of non-zero variables in x never exceeds the rank of Constraints Matrix. When F = ∅, the following inequality holds |E| ≤ M + 2k − 1

(7)

We can remove those non-free machines from Λ, move fixed variables {xij |(i, j) ∈ F } to the right side of the equalities and inequalities as constants and remove variables fixed to 0. By doing this, we obtain a new sub-problem and only focus on free jobs and free machines. In the new sub-problem, Lemma 1 holds. So in general, the following corollary holds. Corollary 1. Given a BLPR problem, Λ, its basic solution x and supporting graph G(x) = G(L, R, E), we have |E| ≤ M ∗ + 2k ∗ − 1

(8) ⊓ ⊔

We introduce several theorems on the basic solution to Λ when there are no less free jobs than free machines, namely, M ∗ ≥ k ∗ . Theorem 1. If Λ is feasible with M ∗ ≥ k ∗ , and x is a basic solution, there exist a free machine p and a free job q such that xpq ≥ 1/2 . Proof. For a basic solution x, we construct supporting graph G(x) = G(L, R, E) . Note that we have |E| ≤ M ∗ + 2k ∗ − 1 ≤ 3M ∗ − 1 (9) Suppose we have l ≤ M ∗ special jobs in R, each of which has degree at most 2 in G(x) . The other M ∗ − l free jobs are non-special, thus each of them has degree at least 3 in G(x) . Note that each free job must have at least one edge associated with itself, thus the special jobs contribute at least l edges. The following inequality holds. (10) |E| ≥ 3(M ∗ − l) + l = 3M ∗ − 2l Thus l is at least 1 as expected.

⊓ ⊔

Using similar technique, we can prove corollary below. Corollary 2. In a basic solution x to Λ with M ∗ ≥ k ∗ , there must exist at least M ∗ − k ∗ + 1 special jobs. ⊓ ⊔ According to the definition of special jobs, the following lemma holds.

288

C. Zhang et al.

Lemma 2. If job q is special, there are two free machines p, s with xpq ≥ 1/2, xsq ≤ 1/2 and xpq + xsq = 1 . ⊓ ⊔ For a special job q, we call p the first choice, s the second choice. Tie will be broken by choosing the smaller of p and s as the first choice. We now prove a theorem that will be used extensively in our algorithm. Theorem 2. Given a BLPR problem Λ with M ∗ ≥ 2k ∗ and its basic solution x, there exists a machine p, where there exist two distinct special jobs q1 , q2 both of which choose p as their first choices. Proof. Since M ∗ ≥ 2k ∗ , by Corollary 2, we can ensure in basic solution x there ⊓ ⊔ exist k ∗ + 1 special jobs. With Pigeonhole Principle, our statement holds.

4

A 3-Approximation Algorithm

In this section, we show two main bounding theorems on BLPR and present our algorithm. We first show the theorem for the case M ∗ ≥ 2k ∗ . Theorem 3. Given a BLPR problem, Λ, with M ∗ ≥ 2k ∗ , its basic solution x, two special jobs q1 , q2 both of which choose machine p as their first choices with xpq1 , xpq2 ≥ 1/2 . Without loss of generality we assume that tq1 ≥ tq2 . Based on Λ, we construct a new BLPR problem f (Λ) as follows: 1. F ′ = F + (p, q1 ) ; t 2. b′ = (b1 , b2 , . . . , bp−1 , bp + q21 , bp+1 , . . . , bk ) ; 3. the rest parts of f (Λ) are the same as Λ . If b is a feasible upper bounding vector of Λ then b′ is a feasible upper bounding vector of f (Λ) . Proof. To prove b′ is a feasible upper bounding vector, we prove that f (Λ) is feasible by constructing a feasible solution to it. Because q1 is special, in the construction only two machines are involved. Let s be the second choice of q1 . Consider the constraints on two machines s and p in Λ .  xsq1 tq1 +xsq2 tq2 + 1≤j≤M,j ∈{q / 1 ,q2 } xsj tj ≤ bs  xpq1 tq1 +xpq2 tq2 + 1≤j≤M,j ∈{q / 1 ,q2 } xpj tj ≤ bp  (11) ≤ ms + 1≤j≤M,j ∈{q +xsq2 xsq1 / 1 ,q2 } xsj  ≤ mp + 1≤j≤M,j ∈{q +xpq2 xpq1 / 1 ,q2 } xpj We will construct a feasible solution to f (Λ) based on the feasible solution to Λ . Let α = xsq1 = 1 − xpq1 . Note that we have two special jobs q1 , q2 in machine p, we move α fraction of q1 from s to p and α fraction of q2 from p to s, which implies that we decide to schedule q1 to machine p . By doing this, we t can guarantee that the length of machine p will increase by at most q21 and the length of machine s will not increase.

Approximating Scheduling Machines with Capacity Constraints

289

Let x∗sq1 = 0, x∗pq1 = 1, x∗sq2 = α + xsq2 and x∗pq2 = −α + xpq2 . Since q1 , q2 are special, we have 0 ≤ α ≤ 1/2 ≤ xpq2 . We have the following inequalities x∗sq1 tq1 + x∗sq2 tq2 = (α + xsq2 )tq2 ≤ xsq1 tq1 + xsq2 tq2 x∗pq1 tq1 + x∗pq2 tq2 = (xpq1 + α)tq1 + (−α + xpq2 )tq2 tq ≤ xpq1 tq1 + xpq2 tq2 + 1 2 x∗sq1 + x∗sq2 = x∗sq2 = xsq1 + xsq2 ≤ 1 x∗pq1 + x∗pq2 = 1 + x∗pq2 = xpq1 + xpq2 Thus the following inequalities hold.  x∗sq1 tq1 +x∗sq2 tq2 + 1≤j≤M,j ∈{q / 1 ,q2 } xsj tj  ∗ ∗ xpq1 tq1 +xpq2 tq2 + 1≤j≤M,j ∈{q / 1 ,q2 } xpj tj  + 1≤j≤M,j ∈{q +x∗sq2 x∗sq1 / 1 ,q2 } xsj  ∗ ∗ + 1≤j≤M,j ∈{q +xpq2 xpq1 / 1 ,q2 } xpj

≤ bs ≤ bp + ≤ ms ≤ mp

tq1 2

This implies that there exists a feasible solution to f (Λ) .

(12)

(13) (14) (15)

(16)

⊓ ⊔

We now show the second bounding theorem for the case M ∗ < 2k ∗ . Theorem 4. Given a BLPR problem, Λ, with M ∗ < 2k ∗ , its basic solution x. Let p denote the free machine with the least free capacity left, namely, p has the smallest positive value mi − ci . We also let q denote the free job with the largest length. Based on Λ, we construct a new BLPR problem g(Λ) as follows: 1. 2. 3. 4.

F ′ = F + (p, q) ; b′ = (b1 , b2 , . . . , bp−1 , bp + tq , bp+1 , . . . , bk ) ; m′ = (m1 , m2 , . . . , mp−1 , cp + 1, mp+1 , . . . , mk ) ; the rest parts of g(Λ) are the same as Λ .

If b is a feasible upper bounding vector of Λ then b′ is a feasible upper bounding vector of g(Λ) . Proof. Note that in g(Λ), machine p is non-free. When M ∗ < 2k ∗ , in any feasible solution to Λ, there exists a free machine pˆ which is filled with less than two jobs. We can let pˆ = p, because scheduling a job to p then making p non-free will waste the least free capacity among choices. To schedule q to p, for each free machine s = p with xsq > 0, we move xsq fraction of job q to machine p then move back from p as much as possible but no more than xsq fraction of jobs other than q . Because q has the largest length among the free jobs, we can guarantee that the length of each free machine s = p will not increase and the length of machine p will increase by at most tq . This implies there is a feasible solution to g(Λ) . ⊓ ⊔ By Theorem 3, as long as M ∗ ≥ 2k ∗ , we can always schedule a free job to a free machine but without increasing its length too much. If M ∗ < 2k ∗ , Theorem4 holds and we still can make our decision in a fairly simple way. We present our algorithm using Iterative Rounding Method, IRA, in Algorithm 1.

290

C. Zhang et al.

Algorithm 1. IRA Require: An IP ∆ Ensure: A feasible integral solution F 1: Construct natural linear programming relaxation Γ . 2: Solve Γ optimally and let y = (y1 , y2 , . . . , yk ) be the lengths of machines in the optimal solution. 3: Construct a BLPR Λ, letting y be the upper bounding vector and F = ∅ . 4: while M ∗ > 0 do 5: if M ∗ ≥ 2k∗ then 6: Λ ← f (Λ) . 7: else {M ∗ < 2k∗ } 8: Λ ← g(Λ) . 9: end if 10: end while 11: return F .

Finding a basic solution to a linear program can be done in polynomial time by using the ellipsoid algorithm [5] then converting the solution found into a basic one [4]. Together with the following observation Lemma 3. At Line 3, y is a feasible upper bounding vector of Λ .

⊓ ⊔

the correctness of IRA follows from Theorem 3 and 4. Corollary 3. Algorithm IRA always terminates in polynomial time.

⊓ ⊔

The analysis of the performance of IRA is simple with the help of upper bounding vector b, noting that in most of the time when a component of b is increased, the increment is at most half of the length of job scheduled to the same machine. We now show that IRA is a 3-approximation algorithm. Theorem 5. IRA is a 3-approximation algorithm. Proof. Let A denote the makespan in the solution produced by IRA, OPT denote the makespan in the optimal solution to ∆ . Consider any machine p with length A in the solution produced by IRA, it’s filled with m ˆ ≤ mp jobs q1 , q2 , . . . , qm ˆ in sequence. Note that once bp is increased at Line 8, machine p will no longer be free. So exactly one of the following two statements is true: ˆ times at Line 6. 1. bp is increased m ˆ − 1 times at Line 6, and is increased once at Line 8. 2. bp is increased m Thus we have  tq  tq u u , + tqmˆ } 2 2 1≤u 0), v is a descendant (or an ancestor) of and at distance |k(v)| from the corresponding center in the k-tree. We consider the optimum spanning k-tree forest Tv∗ for every subtree rooted at v, denoted by Tv , under the condition the label of v, −k ≤ k(v) ≤ k. Let wi (Tv ) denote the weight of the optimum spanning k-tree forest Tv∗ for the subtree Tv while v is labelled by k(v) = i. We have the following algorithm. Algorithm 1. Given a tree T = (V, E) with a nonnegative edge weight function w, do a postorder traversal of T , 1. Initialize wk(v) (Tv ) = 0, −k ≤ k(v) ≤ k, for every leaf v in T ; 2. For each vertex v with its children v1 , . . . , vt , we divide k(v) into four cases: t  2-1. wk(v) (Tv ) = maxi {wi (Tvj )}, if k(v) = −k; j=1

2-2. wk(v) (Tv ) =

t  j=1

max{ w(v, vj ) + wk(v)−1 (Tvj ), maxi {wi (Tvj )} } −

minj { max{ w(v, vj ) + wk(v)−1 (Tvj ), maxi {wi (Tvj )} } −w(v, vj ) − wk(v)−1 (Tvj )}, if −k < k(v) ≤ 0;  2-3. wk(v) (Tv ) = maxj ′ { w(v, vj ′ ) + wk(v)−1 (Tvj′ ) + max{ w(v, vj ) + j =j ′

w−k(v)−1 (Tvj ), maxi {wi (Tvj )} } }, if 0 < k(v) < k; 

2-4. wk(v) (Tv ) = maxj ′ { w(v, vj ′ ) + wk(v)−1 (Tvj′ ) +

j =j ′

maxi {wi (Tvj )} }, if

k(v) = k; 3. Output maxi {wi (Tv )}, if v is the root of T ; Theorem 2. Spanning k-tree forest problem in a tree T = (V, E) can be solved in linear time, for any integer constant k. Proof. For the correctness of Algorithm 1, wk(v) (Tv ) have to be verified for the optimum spanning k-tree forest Tv∗ of Tv under all the conditions −k ≤ k(v) ≤ k. By induction on the given postorder traversal of T , the initial case in Step 1 is obvious. Suppose the induction hypothesis holds that all the children v1 , . . . , vt of a vertex v have correct wk(vj ) (Tvj ), 1 ≤ j ≤ t, −k ≤ k(vj ) ≤ k. We consider the cases of wk(v) (Tv ) as follows.

296

C.-S. Liao and L. Zhang

1. If k(v) = −k, that is, v can be considered as an isolated vertex for the optimum Tv∗ . Thus all the children v1 , . . . , vt and v can not lie in the same k-tree in Tv∗ with respect to k(v), and Step 2-1 is straightforward. 2. Consider −k < k(v) ≤ 0, that is, every child vj could be possibly a child of v in a k-tree in Tv∗ and there should be at least one child as a child of v in Tv∗ . First, the second term of the formula in Step 2-2, minj { max{ w(v, vj ) + wk(v)−1 (Tvj ), maxi {wi (Tvj )} } −w(v, vj )−wk(v)−1 (Tvj )} is nonnegative. Assume there is a child vj with w(v, vj ) + wk(v)−1 (Tvj ) ≥ maxi {wi (Tvj )}. It implies that the second term would be zero and there would be at least one child of v with the label k(v) − 1 lying in the k-tree containing v in Tv∗ with respect to k(v). Therefore, for each child vj of v, if w(v, vj ) + wk(v)−1 (Tvj ) ≥ maxi {wi (Tvj )}, then let it be the child of v in a k-tree in Tv∗ , i.e., k(vj ) = k(v) − 1 < 0; otherwise, vj and v lie in the two different k-trees in Tv∗ , and vj is the leaf or center in its k-tree. On the other hand, if there is no child vj with w(v, vj ) + wk(v)−1 (Tvj ) ≥ maxi {wi (Tvj )}, it implies that the second term would be positive. Consequently, we select vj with the smallest maxi {wi (Tvj )} − w(v, vj ) − wk(v)−1 (Tvj ) to maximize wk(v) (Tv ) since the first term is fixed, and meanwhile let vj be the child of v in a k-tree in Tv∗ , i.e., k(vj ) = k(v) − 1 < 0, and other children belong to other distinct k-trees in Tv∗ . 3. Consider 0 < k(v) < k, that is, exactly one child vj of v should be parent of v in a k-tree in Tv∗ , i.e., k(vj ) = k(v) − 1 ≥ 0, and the other children could be the children of v with the label −k(v) − 1 (where | − k(v) − 1| = k(v) + 1) in the same k-tree or lying in other different k-trees in Tv∗ . Step 2-3 considers every case that vj ′ , 1 ≤ j ′ ≤ t, is the parent of v in a k-tree in Tv∗ , i.e., k(vj ′ ) = k(v) − 1 ≥ 0. In addition, for each other child vj = vj ′ , if w(v, vj ) + w−k(v)−1 (Tvj ) ≥ maxi {wi (Tvj )}, then let it be the child of v in a k-tree in Tv∗ , i.e., −1 > k(vj ) = −(k(v) + 1) = −k(v) − 1 ≥ −k; otherwise, vj and v lie in the two different k-trees in Tv∗ , and vj is the leaf or center in its k-tree. 4. If k(v) = k, it is similar to the third case, that is, exactly one child vj of v should be parent of v in a k-tree in Tv∗ , i.e., k(vj ) = k(v) − 1 ≥ 0, but all the other children should belong to other different k-trees in Tv∗ . Thus, the proof of correctness is complete. Regarding the running time, Algorithm 1 takes O(k·tv ) time when we consider each vertex v with tv children. Based on the postorder traversal of T = (V, E),  the total running time is v O(k ·tv ) = O(k|V |) time, for any integer constant k.  We remark that Algorithm 1 can be modified to output the optimum spanning k-tree forest T ∗ rather than the optimum weight only. Based on the backtracking technique from the root of T , we remove every edge (v, u) from T to obtain T ∗ if |k(v)| = |k(u) + 1| and u is a child of v. Besides, the center of a k-tree can be also located at a vertex u when k(u) = 0, or k(u) < 0 and (v, u) was removed from T .

Approximating the Spanning k-Tree Forest Problem

2.2

A

k -Approximation k+1

297

Algorithm for General Graphs

The main idea of our approximation algorithm for spanning k-tree forest problem in general graphs is similar to the shifting technique of Hochbaum and Maass [13]. First we have a maximum spanning tree T in a given graph G = (V, E). It can be obtained by the well-known Kruskal’s or Prim’s algorithm in polynomial time. Suppose we have the maximum spanning tree T with height h rooted at r (root r with the initial height zero). Without loss of generality, we assume h ≥ k + 1; otherwise, T is a k-tree and certainly optimum spanning k-tree forest. Let T i , 0 ≤ i ≤ k, be the collection of all the subtrees which do not contain edges (u, v) with height ℓ−1 to ℓ and ℓ ≡ i mod (k +1), ℓ ≥ 1. Then T i is a union of subtrees, where each subtree has height at most k, that is, each one is a k-tree. Therefore every T i is a spanning k-tree forest, 0 ≤ i ≤ k. We introduce our approximation algorithm as follows. Algorithm 3. Given a graph G = (V, E) with a nonnegative edge weight function w, 1. Find a maximum spanning tree T for G; 2. Compute the optimum k-tree forest T ∗ for T based on Algorithm 1; 3. Output w(T ∗ ); Theorem 4. Spanning k-tree forest problem in a graph G = (V, E) can be apk proximated within k+1 -factor in polynomial time, for any integer constant k. Proof. Let O′ be the optimum weight among T i , 0 ≤ i ≤ k, with respect to amaximum spanning tree T for G, i.e., O′ = max{w(T i )}, where w(T i ) = ′ e∈T i w(e). We have (k + 1) · O ≥ k · w(T ) since every edge in T occurs k times i among k + 1 T ’s. In addition, let O∗ be the weight of the optimum spanning ktree forest for G and it is obvious w(T ) ≥ O∗ since edges (of nonnegative weight) can be added into the optimum spanning k-tree forest to form a spanning tree for G. Because T ∗ is the optimum spanning k-tree forest for T by Theorem 2 k k and thus w(T ∗ ) ≥ O′ , it can be obtained that w(T ∗ ) ≥ O′ ≥ k+1 w(T ) ≥ k+1 O∗ . k Thus spanning k-tree forest problem can be approximated within k+1 -factor in general graphs. 

3

Approximation Algorithm for Directed Graphs

Before exploring the directed graph model of the maximum spanning k-tree forest problem, We first briefly introduce the maximum directed spanning forest, i.e., the so-called optimum branching. Chu and Liu [7], Edmonds [8], and Bock [1] have independently given efficient algorithms for finding an optimum branching T in a directed graph G = (V, E). The algorithms of Chu-Liu and Edmonds are virtually identical; the Bock algorithm is similar but stated on matrices rather than on graphs. Furthermore Karp [14] gave a combinatorial proof of Edmonds’ algorithm and Tarjan [2,17] gave an implementation of the algorithm that runs in faster O(|E| log |V |) time. Given a directed graph G = (V, E), the main idea is described as follows.

298

C.-S. Liao and L. Zhang

1. For each vertex v ∈ V do −−−→ Select the incoming edge e = (u, v) of v with the maximum edge weight into T; 2. While T contains a directed cycle C do (a) Contract the vertices of the directed cycle C into a pseudo-vertex vc ; −−−→ (b) Modify the edge weight of every incoming edge (u, x) of C accordingly, −−−−→ −−−→ −−−→ w(u, vc ) = w(u, x) − w(y, x) + min{w(e); e ∈ C}, where x, y in C and u outside C; −−−−→ −−−−−→ (c) Select the incoming edge (u∗ , vc ) of vc (i.e., (u∗ , x∗ )) with the maximum −−− − − → −−−−−→ positive weight into T instead of (y ∗ , x∗ ), where (y ∗ , x∗ ) ∈ C. That is, −−−−−→ −−−−→ − −−−− → T \{(y ∗, x∗ )}∪{(u∗ , x∗ )}. If w(u, vc ) ≤ 0, ∀u, then remove the edge e ∈ C with the minimum w(e) from T ; 3. Output the optimum branching T of G; We then consider the directed spanning k-tree forest problem for out-rooted (directed) edge-weighted trees in a bottom-up manner and associating every vertex v with a label k(v) similarly. Suppose T = (V, E) is an out-rooted edgeweighted tree in which every edge e ∈ E is associated with a nonnegative edge weight w(e). For each subtree out-rooted at v, Tv , we only consider the optimum spanning k-tree forest Tv∗ under the condition −k ≤ k(v) ≤ 0, since T is an outrooted tree. Similarly, let wi (Tv ) denote the weight of the optimum directed spanning k-tree forest Tv∗ for the subtree Tv while v is labelled by k(v) = i. Given an out-rooted tree T = (V, E) with a postorder traversal, we initialize wk(v) (Tv ) = 0, −k ≤ k(v) ≤ 0, for each leaf v in T . We refer to Algorithm 1 and have the following lemma immediately. Lemma 1. In a postorder traversal of T = (V, E), we compute wk(v) (Tv ) in two cases for every vertex v with its children v1 , . . . , vt , 1. If k(v) = −k, wk(v) (Tv ) =

t 

j=1 t 

2. If −k < k(v) ≤ 0, wk(v)(Tv ) =

maxi {wi (Tvj )}; −−−→ max{ w(v, vj ) + wk(v)−1 (Tvj ), maxi {wi (Tvj )}

j=1

}− −−−→ −−−→ minj{ max{ w(v, vj )+wk(v)−1 (Tvj ), maxi {wi(Tvj)} } −w(v, vj )−wk(v)−1 (Tvj )}; Proof. The proof is similar to Theorem 2 and omitted.



The computation cost is O(k|V |) for any integer constant k, based on Theorem 2. We also remark that it can be modified to output the maximum directed spanning k-tree forest using the backtracking technique. Theorem 5. Directed spanning k-tree forest problem can be solved in an outrooted tree in linear time, for any integer constant k.

Approximating the Spanning k-Tree Forest Problem

299

The idea of our approximation algorithm for directed spanning k-tree forest problem in general directed graphs is similar to Algorithm 3. The approximation k ratio k+1 can be also obtained in the similar shifting scheme to Theorem 4. Algorithm 6. Given a directed graph G = (V, E) with a nonnegative edge weight w, 1. Find an optimum branching T of G; 2. Find the maximum directed spanning k-tree forest T ∗ with respect to each component of T by Lemma 1; 3. Output w(T ∗ ); Theorem 7. Directed spanning k-tree forest problem in a directed graph G = k -factor in polynomial time, for any integer (V, E) can be approximated within k+1 constant k.

4

The Weighted Distance Model

The weighted distance between any two vertices is defined to be the sum of the weights for edges in the shortest path between them if G is edge-weighted. We consider the weighted distance model of spanning k-tree forest problem in this section. Given an edge-weighted graph G = (V, E) in which each edge e ∈ E is associated with a nonnegative edge weight w(e), we first ignore the edges of weight larger than k because these edges will not be included in any feasible solutions. Hence, without loss of generality we assume all the edges have weight no larger than k in the given graph G = (V, E). Our approach in the previous sections can be applied to the weighted distance model of both undirected and directed graphs if every edge weight w(e) and k are all nonnegative integers. We can simply modified the above algorithms by replacing wk(v)−1 (Tvj ) and w−k(v)−1 (Tvj ) by wk(v)−w(v,vj ) (Tvj ) and w−k(v)−w(v,vj ) (Tvj ) respectively, where vj is a child of v. Therefore we suppose the edge weight function is nonnegative real and the approximation algorithm is described as follows. Algorithm 8. Given a graph G = (V, E) with a nonnegative real edge weight function w and w(e) ≤ k, ∀e ∈ E, 1. Find a maximum spanning tree T if G is undirected and an optimum branching T if G is directed; 2. Find the maximum spanning star forest T ∗ with respect to each component of T by Algorithm 1 or Lemma 1; 3. Output w(T ∗ ); It is similar to find the maximum spanning star forest T ∗ as we let the label k(v) belong to {−1, 0, 1}, ∀v ∈ V . Every star of T ∗ is certainly a k-tree in the weighted distance model because every edge has weight less than or equal to

300

C.-S. Liao and L. Zhang

k. In addition, since we can also divide the maximum spanning tree T (or the optimum branching T ) into two alternating spanning star forests based on the similar shifting scheme, it is obvious that w(T ∗ ) ≥ 12 w(T ) ≥ 12 w(O∗ ), where O∗ is the optimum spanning k-tree forest in the weighted distance model. Theorem 9. The weighted distance model of spanning k-tree forest problem can be approximated within 0.5-factor in polynomial time in both undirected and directed graphs, for any nonnegative real edge weight function.

5

Conclusion

In this paper, we generalize the spanning star forest problem into the spanning k-tree forest problem and then investigate it for not only undirected graphs, but also weighted and directed graphs. We present a k/(k + 1)-approximation algorithm for the problem in the weighted and directed cases. In the weighted distance model, we give a 0.5-approximation algorithm. In future, it would be interesting to study the following research problems: 1. Does the spanning k-tree forest problem have better ratio approximation algorithm for undirected graphs? 2. In the weighted distance model, is it possible to have an approximation algorithm of ratio better than 0.5?

References 1. Bock, F.: An algorithm to construct a minimum directed spanning tree in a directed network. In: Developments in Operations Research, pp. 29–44. Gordon and Breach, New York (1971) 2. Camerini, P.M., Fratta, L., Maffioli, F.: A note on finding optimum branchings. Networks 9, 309–312 (1979) 3. Chakrabarty, D., Goel, G.: On the Approximability of Budgeted Allocations and Improved Lower Bounds for Submodular Welfare Maximization and GAP. In: Proceedings of the 49th IEEE Symposium on Foundations of Computer Science, FOCS 2008, pp. 687–696 (2008) 4. Chang, G.J.: Labeling algorithms for domination problems in sun-free chordal graphs. Discrete Appl. Math. 22, 21–34 (1988/1989) 5. Chen, N., Engelberg, R., Nguyen, C.T., Raghavendra, P., Rudra, A., Singh, G.: Improved approximation algorithms for the spanning star forest problem. In: Charikar, M., Jansen, K., Reingold, O., Rolim, J.D.P. (eds.) RANDOM 2007 and APPROX 2007. LNCS, vol. 4627, pp. 44–58. Springer, Heidelberg (2007) 6. Cockayne, E.J., Goodman, S.E., Hedetniemi, S.T.: A linear algorithm for the domination number of a tree. Inform. Process. Lett. 4, 41–44 (1975) 7. Chu, Y.J., Liu, T.H.: On the shortest arborescence of a directed graph. Science Sinica 14, 1396–1400 (1965) 8. Edmonds, J.: Optimum branchings. J. Research of the National Bureau of Standards 71B, 233–240 (1967) 9. H˚ astad, J.: Some optimal inapproximability results. J. ACM 48, 798–859 (2001)

Approximating the Spanning k-Tree Forest Problem

301

10. Haynes, T.W., Hedetniemi, S.T., Slater, P.J.: Domination in Graphs: Advanced Topics. Marcel Dekker, Inc., New York (1998) 11. Henning, M.A., Oellermann, O.R., Swart, H.C.: Bounds on distance domination parameters. J. Combin. Inform. System. Sci. 16, 11–18 (1991) 12. Henning, M.A., Oellermann, O.R., Swart, H.C.: The diversity of domination. Discrete Math. 161, 161–173 (1996) 13. Hochbaum, D.S., Maass, W.: Approximation schemes for covering and packing problems in image processing and VLSI. J. ACM 32, 130–136 (1985) 14. Karp, R.M.: A simple derivation of edmonds’ algorithm for optimum branchings. Networks 1, 265–272 (1971) 15. Liao, C.S., Chang, G.J.: k-tuple domination in graphs. Inform. Process. Lett. 87, 45–50 (2003) 16. Nguyen, C.T., Shen, J., Hou, M., Sheng, L., Miller, W., Zhang, L.: Approximating the spanning star forest problem and its applications to genomic sequence alignment. SIAM J. Comput. 38, 946–962 (2008); also appeared in Proc. of SODA 2007, pp. 645–654 (2007) 17. Tarjan, R.E.: Finding optimum branchings. Networks 7, 25–35 (1977) 18. Slater, P.J.: R-Domination in Graphs. J. ACM 23, 446–450 (1976) 19. Yannakakis, M., Gavril, F.: Edge dominating sets in graphs. SIAM J. Appl. Math. 38, 364–372 (1980)

Toward an Automatic Approach to Greedy Algorithms⋆ Yujun Zheng1,2,3 , Jinyun Xue1,3 , and Zhengkang Zuo1,2,3 1

Institute of Software, Chinese Academy of Sciences, Beijing 100080, China [email protected] 2 Graduate University of the Chinese Academy of Sciences, Beijing 100080, China 3 Provincial Key Lab. High Performance Computing, Jiangxi Normal University, Nanchang 330027, China

Abstract. The greedy approach is widely used for combinatorial optimization problems, but its implementation varies from problem to problem. In this paper we propose a mechanical approach for implementing greedy algorithmic programs. Using PAR method, a problem can be continually partitioned into subproblems in smaller size based on the problem singleton and the maximum selector, and the greedy algorithm can be mechanically generated by combining the problem-solving sequences. Our structural model supports logical transformation from specifications to algorithmic programs by deductive inference, and thus significantly promotes the automation and reusability of algorithm design. Keywords: Combinatorial optimization problems, PAR method, problem singleton, greedy algorithm.

1

Introduction

The study of algorithms is at the very heart of computer science [1], but developing correct and efficient algorithmic programs remains one of the most difficult and time-consuming tasks in the field. Today the most popular approach is using classic strategies, such as divide-and-conquer, dynamic programming, greedy, etc., to design algorithms in traditional means, which leads to low reusability of solutions and high complexity of verification. Over the last decades, the community has advocated the use of formal methods for problem specification, program derivation and verification, in which algorithms are developed together with their proof of correctness (e.g., [9,12,19,14,17]). In this paper we propose an automatic approach to greedy algorithms for combinatorial optimization problems based on PAR (partition-and-recur) [21,22], a systematic and unified methodology for algorithm development that effectively tackles the complexity of loop programs and covers a number of known design ⋆

Supported by grants from Natural Science Foundation (No. 60573080, 60773054) and International Sci. & Tech. Cooperation Program (No. 2008DFA11940) of China and Natural Science Foundation (No. 2008GQS0056) of Jiangxi Province.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 302–313, 2009. c Springer-Verlag Berlin Heidelberg 2009 

Toward an Automatic Approach to Greedy Algorithms

303

strategies. Starting from the algebraic problem specification, we continually select a maximum singleton object to partition the problem into subproblems in smaller size and with less complexity until all the subproblems can be solved directly, during which a problem reduction tree or sequence is constructed, and the greedy algorithm is generated by combining the problem recurrence relations; the algorithmic specification can also be mechanically transformed into the executable program by PAR platform [23]. In the rest of the paper, we first introduce the preliminaries of PAR method and the algebraic model for combinatorial optimization problems in Section 2. In Section 3 we present the mechanical process for problem reduction and algorithm generation, which is illustrated by case studies in Section 4. Finally we compare with related work and conclude in Section 5.

2

PAR Method and Combinatorial Optimization Problem Model

PAR is a unified and practical algorithm design method that covers a number of problem solving techniques including divide-and-conquer, dynamic programming, greedy, backtracking, etc. It consists of a recurrence-based algorithm design language Radl, an abstract programming language Apla, a systematic algorithm design method, and a set of automatic tools for program generation. According to PAR, deriving an algorithmic program can be divided into following steps: 1. Describe the functional specification of the problem. 2. Partition the problem into sub-problems with the same structure but smaller in size, until each sub-problem can be solved directly. 3. Construct the recurrence relations of problem solving sequences from the functional specification. 4. Based on the problem recurrence(s), transform the functional specification into algorithm, and develop the loop invariant of the algorithm according to our strategy [20]. 5. Based on the loop invariant and the recurrence relations, transform the algorithm into the program mechanically. The support platform of PAR provides mechanical transformation from algorithm specifications described in Radl to abstract programs described in Apla, as well as automatic transformation from Apla programs to executable programs. According to the theory of algebraic data types, a specification defines a problem by specifying a domain of problem inputs and the notion of what constitutes a solution to a given input. Formally, a problem specification has the following structure [15]: Problem Sorts D, R imports Boolean Operations I : D → Boolean; O : D × R → Boolean

304

Y. Zheng, J. Xue, and Z. Zuo

That is, the input condition I(x) constrains the input domain D and the output condition O(x, z) describes the condition under which the output domain value z ∈ R is feasible solution with respect to an input x ∈ D. Combinatorial optimization problems, most of which are defined over partial ordered sets (Poset), can be treated as extensions of problem specifications by introducing a generative function ξ to generate the solution space, a constraint function c to describe the feasibility, and an objective function f to evaluate the optimality of solutions: COP(D : [P oset → D]), R : [P oset → R]) refines P roblem Sorts ξ, c, f imports Boolean, Real, Set Operations ξ : D → Set(R); c : R → Boolean; f : R → Real Axioms (d1 , d2 : D) d1 ≤D d2 ⇒ ξ(d1 ) ⊆ ξ(d2 ) where ≤D is the ordering relation on D. Throughout this paper, we use the Eindhoven quantifier notation [6] to define a COP with input d as: P (d) ≡ Qz : c(z) ∧ z ∈ ξ(d) : f (z) where Q is the generalized quantifier of a binary optimization operator q (min or max for most problems). We also simply write P (d) = ξ, c, f when there is no ambiguity, and use p∗ (d) to denote an optimal solution of P (d) such that: P (d) = f (p∗ (d))

3 3.1

(1)

Greedy Algorithm Framework Problem Reduction

To facilitate the application of PAR, we develop a mechanical process for combinatorial optimization problem partition and solution recurrence. First, the following specifies the relations between problems on the same domain: Definition 1. P (d) = ξ, c, f is an equivalent problem of P ′ (d′ ) = ξ ′ , c′ , f

if {z|c(z) ∧ z ∈ ξ(d)} = {z|c′ (z) ∧ z ∈ ξ ′ (d′ )}. Definition 2. P ′ (d′ ) = ξ, c′ , f is a subproblem of P (d) = ξ, c, f if d′ ≤D d and c′ (z) ⇒ c(z). In particular, we call P ′ (d′ ) is a direct subproblem of P (d) if c′ = c, otherwise a derivative subproblem of P (d). And the following structures indicate a specific way of problem partition: Definition 3. The singleton of a problem structure P = D, R; ξ, c, f is a ternary tuple E; ⊕ : D × E → D, ⊗ : R × E → R such that for any x ∈ E, d ∈ D and z ∈ R, the functions ξ, c and f can be decomposed as follows:

Toward an Automatic Approach to Greedy Algorithms

305

ξ(d ⊕ x) = ξ(d) ∪ {z ⊗ x|z ∈ ξ(d) ∧ ua (z, x)}

(2)

c(z ⊗ x) ≡ c′ (z) ∧ ub (z, x)

(3)

f (z ⊗ x) = f (z) ⊙ w(x)

(4)

where c′ , ua and ub are boolean functions, and w : E → Real is the cost function. We call E the singleton domain, and ⊕ and ⊗ the D-monadic function and R-monadic function respectively. We also use ⊖ to denote the inverse operator of ⊕, i.e., for any x ∈ E, d ∈ D and d = ∅, we have (d ⊖ x) ⊕ x = d. Definition 4. π : (D − {⊥D }) → E is called a selector of P = D, R; ξ, c, f

with singleton E; ⊕, ⊗ . Given an input d ∈ D and d = ⊥D , we can use a selector to get an x = π(d) and hence have d = d′ ⊕ x. By recursively applying the procedure, d can be decomposed into the following form: d = (((⊥D ⊕ x1 ) ⊕ x2 )... ⊕ xn )

(5)

where xi ∈ E(0 < i ≤ n), and the parentheses can be omitted without causing confusion. In the sense of constructing a problem input from a set of singleton objects, we say such a d is an n-size input. Definition 5. x† is called a maximum singleton object of problem P (d) = ξ, c, f if for any xi in Equation (5) we have w(xi ) ≤ w(x† ), and π † is called a maximum selector of P = D, R; ξ, c, f if, for any d ∈ (D − {⊥D }), π † (d) always produces a maximum singleton object of P (d). A typical class of combinatorial optimization problems, such as problems to find an optimal subset of a given set, to find an optimal sublist of a given list, to find an optimal subgraph/tree of a given graph, etc., have distinct maximum singleton objects that enable us to decompose the problem input d into d′ ⊕ x† , based on which the problem can be derived as follows: P (d) ≡ Qz : c(z) ∧ z ∈ ξ(d) : f (z) ≡ [decomposition by d = d′ ⊕ x† ] Qz : c(z) ∧ (z ∈ ξ(d′ ) ∨ (z = z ′ ⊗ x† ∧ z ′ ∈ ξ(d′ ) ∧ ua (z ′ , x† )) : f (z) ≡ [distributivity] Qz : (c(z) ∧ z ∈ ξ(d′ )) ∨ (c(z) ∧ z = z ′ ⊗ x† ∧ z ′ ∈ ξ(d′ ) ∧ ua (z ′ , x† )) : f (z) ≡ [general distributivity] (Qz : c(z) ∧ z ∈ ξ(d′ ) : f (z))q(Qz ′ : c(z ′ ⊗ x† ) ∧ z ′ ∈ ξ(d′ ) ∧ ua (z ′ , x† ) : f (z ′ ⊗ x† )) ≡ [fold and decomposition] P (d′ )q(Qz ′ : c′ (z ′ ) ∧ ua (z ′ , x† ) ∧ ub (z ′ , x† ) ∧ z ′ ∈ ξ(d′ ) : f (z ′ ) ⊙ w(x† )))

306

Y. Zheng, J. Xue, and Z. Zuo

P(d) ux† P(d')

P'(d') [w(x )]

Fig. 1. Recurrence relation of P (d) in the problem reduction tree, where d = d′ ⊕ x†

Rewrite c′ (z) ∧ ua (z ′ , x) ∧ ub (z, x) as cx (z ′ ) ∧ u(x) and let P ′ (d) ≡ Qz : cx (z)∧z ∈ ξ(d) : f (z), we get the following equation that obviously characterizes the recurrence relations:  P (d′ )q(P ′ (d′ ) ⊙ w(x† )) if ux† P (d) ≡ (6) P (d′ ) else As illustrated in Fig. 1, if ux† is true, the problem recurrence is described by edges P (d) → P (d′ ) and P (d) → P ′ (d′ ) in the problem reduction tree, otherwise the recurrence is described by P (d) → P (d′ ) only. While d′ = ⊥D , we continue to partition the subproblems P (d′ ) and P ′ (d′ ) in the same manner, and construct a binary problem reduction tree whose leaf nodes represent subproblems that can be directly solved (including those can be determined infeasible in one computational step). Note that the edge P (d) → P ′ (d′ ) yields a cost of w(x† ) of the objective value, and hence indicates ⊥R ⊗ x† as a component of the possible solution. In consequence, if we get a path from the original problem node to a leaf node whose optimal objective value is directly computed as v and the corresponding optimal sub-solution is worked out as v ∗ , we can obtain a complete solution v ∗ ⊗ x1 ⊗ x2 ⊗ ... ⊗ xm with the objective value v ⊙ w(x1 ) ⊙ w(x2 ) ⊙ ... ⊙ w(xm ), where xi (0 < i ≤ m) is selected by π † . 3.2

Algorithm Generation

Based on the above formal derivation process and recurrence relation by Equation (6), we get Algorithm 1 that uses the singleton structure to continually partitions the problems and constructs the corresponding problem reduction tree. Each node of the tree is represented by a triple (d, c, v) (the problem input, the constraint function, and the objective value reached). Initially, the algorithm creates a root node for the original problem and place it in the problem set Q; while Q is not empty, it takes a node cn from Q, uses a selector π † to get a maximum singleton object x† from d, derives the sub-nodes and adds non-leaf nodes to Q. The variable rv maintains the best objective value seen so far, which will be updated at each terminal node. Let vk denotes the value of variable v on the k-th loop, the loop invariant of Algorithm 1 can be developed as follows: #(Q) ≥ 0 ∧ (rvk = rvk−1 q cnk .v) ∧ (cnk .v = cnk−1 .v q cnk−1 .v + w(x))

Toward an Automatic Approach to Greedy Algorithms

ALGORITHM: GREEDY [in D, E, N ode(d : D, c : f unc, v : real): Type; in π † : D → E; c : E → boolean; in Derive : N ode × E → (→ boolean, → boolean);in Solve : N ode → boolean; in d : D; x† : E; Q : set(N ode); cn, lef t, right : N ode; u : E → boolean; out rv : Real] BEGIN: Q = {N ode(d, c, 0)}; TERMINATION: #(Q) = 0; RECUR: cn, Q = Q(0), Q − cn; x† , d = π † (cn.d), cn.d ⊖ x† ; (u, c) = Derive(cn, x† ); lef t = Node(d, cn.c, cn.v); Q, rv q lef t.v if Solve(lef t) Q, rv = Q ∪ {lef t}, rv else  if u(x† ) N ode(d, c, cn.v ⊙ w(x† ) right = ; ∅ else  Q, rv q right.v if u(x† ) ∧ Solve(right) Q, rv = Q ∪ {right}, rv else END.

Algorithm 1. The general greedy algorithm specification in Radl program Greedy(type D, E, N ode(d : D, c : f unc, v : real); func π(d : D) : E, c(x : E) : boolean, u(x : E) : Boolean, Derive(n : N ode, x : E) : (f unc, f unc), Solve(n : N ode) : boolean) var d : D; x : E; Q : set(N ode); cn, lef t, right : N ode; u : f unc(x : E) : boolean; rv : Real; begin Q := {N ode(d, c, 0)}; rv := ∞; do(#(Q) > 0) → cn, Q := Q(0), Q − cn; x, d := π(cn.d), cn.d ⊖ x; (u, c) := Derive(cn, x); lef t := N ode(d, cn.c, cn.v); if (Solve(lef t)) → rv := rv q lef t.v; [] → Q := Q ∪ {lef t}; fi; if (u(x)) → right := N ode(d, c, cn.v ⊙ w(x)); if (Solve(right)) → rv := rv q right.v; [] → Q := Q ∪ {right}; fi; fi; od; Greedy := rv; end.

Algorithm 2. The general greedy algorithmic program in Apla

307

308

Y. Zheng, J. Xue, and Z. Zuo

Using PAR platform, Algorithm 1 can be transformed into the generic Apla program shown in Algorithm 2 based on the loop invariant. Given a concrete problem satisfying the problem structure described above, the executable algorithmic program can also be automatically generated from the abstract one by type and operation refinements [24].

4 4.1

Case Studies Matroid-Structure Based Problems

Despite their different forms, many combinatorial optimization problems for which a greedy approach provides optimal solutions share a fundamental optimality feature based on the matroid structure [7,2]. Definition 6. A matroid is an ordered pair M = (S, L) satisfying the following conditions: – S is a finite nonempty set. – L is a nonempty family of subsets of S, called the independent subsets of S such that if B ∈ L and A ⊆ B, then A ∈ L. We say that L is hereditary if it satisfies this property. – If A ∈ L, B ∈ L, and |A| < |B|, then there is some element x ∈ B − A such that A ∪ {x} ∈ L. We say that M satisfies the exchange property. Definition 7. A weighted matroid is a matroid M = (S, L, w) where w is an associated weight function that assigns each element x ∈ S a strictly positive weight w(x). An element x ∈ A is called an extension of A ∈ L if x can be added to A while preserving independence; that is, x is an extension of A if A ∪ {x} ∈ L. A is said to be maximal if it has no extensions, i.e., it is not contained in any larger independent subset of M. Given a weighted matroid M = (S, L, w), the problem to find a maximumweight independent set of the matroid can be specified as follows (where P denotes the powerset): mis(S) ≡ MAX z : z ∈ L ∧ z ∈ P(S) : w(z) In this case, we can simply select a maximum-weight element x of the matroid as the maximum singleton object and hence have: P(S ∪ {x}) = P(S) ∪ {z ∪ x|z ∈ P(S)}

(7)

(S ∪ {x}) ∈ L ≡ S ∈ L w(S ∪ {x}) = w(S) + w(x)

(8) (9)

where Equation (8) is supported by the greedy-choice property of matroid (the proof can be found in [2]). In consequence, the problem recurrence in Equation (6) is refined as:  mis(S − {x}) + w(x) if S ∈ L mis(S) ≡ (10) mis(S − {x}) else

Toward an Automatic Approach to Greedy Algorithms

309

Using IsActive(A) to denote (A ⊆ S ⇒ A ∈ L), the Algorithm 1 and Algorithm 2 are shaped into Algorithm 3 and Algorithm 4 respectively. ALGORITHM: MAX-IND-SET [in T : type; in IsActive : Set(T ) → Boolean; in S : Set(T ); x : T ; out A : Set(T )] BEGIN: A = {}; TERMINATION: #(S) = 0 RECUR: x = max(S); S=S  − {x}; A ↑ {x} if IsActive(A ∪ {x}) ; A= A else END;

Algorithm 3. The Radl algorithm for matroid problem program max-ind-set(type T ; func IsActive(A : Set(T ) : boolean); var S : Set(T ); x : T ; A : Set(T ); begin A:= {}; do (#(S) > 0) → x := max(S); S := S − {x}; if (IsActive(A ∪ {x})) → A := A ∪ {x}; fi; od; max-ind-set:=A; end. Algorithm 4. The Apla program for matroid problem For problems that can be formulated in terms of finding a maximum-weight independent subset in a weighted matroid, we can refine the generic type T and function IsActive in Algorithm 4 with constructed types and functions, and then generate the executable programs mechanically. Now we take the minimum penalty scheduling problem for example. Given a set of unit-time tasks S = {1, 2, ..., n} to be performed on one processor, and each task i is supposed to finish by an integer deadline di , otherwise a nonnegative penalty wi will be incurred (0 < i ≤ n). The minimum penalty scheduling problem is to find a schedule for S that minimizes the total penalty incurred for missed deadlines. For a subset A of S, let Nt (A) denote the number of tasks in A whose deadline is t or earlier (0 ≤ t ≤ n), and we say A is independent if it does not contain

310

Y. Zheng, J. Xue, and Z. Zuo

any tasks missing deadlines. Let L be the set of all independent sets of tasks, then the scheduling problem can be formulated as a matroid (S, L) [5]. Now simply defining the matroid element type PJob that overrides comparative operator and providing implementation of isActive that selects the latest available time for current task as follows, we get algorithmic program for the problem: define ADT PJob var ID, Last, Penalty: integer; function CompareTo(PJob job): integer begin CompareTo := Penalty - job.Penalty; end; enddef. function isActive(jobs: set(PJob), job: PJob): boolean var i: integer; times: set(integer, #(jobs)) begin if (job.Last < #(items)) → isActive := false; [] → i := job.Last; do (i > 0) → if (times[i] = 0) → times[i] := job.ID; isActive := true; fi; od; isActive := false; fi; end. 4.2

General Greedy Solutions

Our approach can also be applied to solve a large number of other problem, though in many cases the resulting greedy algorithm can not be guaranteed to achieve the optimal computational efficiency. Take the 0-1 knapsack problem as example, given a knapsack of capacity W and a set Sn = {s1 , s2 , ..., sn } of items, each si with a weight wi and a value vi (0 < i ≤ n), the problem is to select a subset of items to be packed into the knapsack so that the total value of selected items is maximized: ks(Sn ) ≡ MAX z : w(z) ≤ W ∧ z ∈ P(Sn ) : v(z) Using Item; ∪, ∪ as the problem singleton, we have: P(S ∪ x) = P(S) ∪ {z ∪ x|z ∈ P(S)} (w(S ∪ x) ≤ W ) ≡ (w(S) ≤ W − w(x)) ∧ (w(x) ≤ W ) v(S ∪ x) = v(S) + v(x)

Toward an Automatic Approach to Greedy Algorithms

311

Therefore, by providing the following implementation of Derive function and Solve function, Algorithm 2 is transformed into the algorithmic program for the 0-1 knapsack problem (the detailed result code is omitted here): function Derive(S : Set(Item), W : Real, v : Real): (func,func) var u, c:func(x : Item); begin u ← (w(x) ≤ W ); c ←≤W −w(x) ; end. function Solve(S : Set(Item), W : Real, v : Real) : Real begin if (#(S) = 1) → if (w(S(0)) ≤ W ) → v := v + x; fi; fi; end.

5

Concluding Remarks

Traditional approaches to apply greedy method typically require formulating an algorithmic structure for each individual problem. The paper presents a unified and mechanical approach for implementing greedy algorithmic programs. We develop the structural model for the combinatorial optimization problems, define the “greedy” selector for selecting maximum singleton objects to partition the problems, based on which the problem reduction trees are constructed and algorithmic programs are produced. In particular, we develop the general greedy algorithm and the shaped algorithm for matroid-based problems, which can be transformed into concrete problem-solving algorithms by generic refinements. Our approach features mechanical generation of efficient, provably-correct programs with minimum user effort. Bird [3] and Meertens [16] developed a highly generalized formalism that provides a concise notation for program calculation and, in particular, uses the so-called f usion or promotion theorems to derive efficient algorithms including greedy ones [4], but the appropriate calculation laws and theorems vary from different problem structures. Jeuring [11] has developed a number of specialized calculational theories, each contains a set of laws and theorems applicable to a specific data type, the result is with a high level of abstraction but also complex and hard to maintain. Helman [10] proposed an algebraic model that defines a problem over a finite set of conjuncts on application objects and models the solution process in terms of lateral combination operators and vertical combination operators. With this formalism, different algorithms can be viewed as utilizing computationally feasible relations to infer the orderings of conjuncts. Another important algorithmics framework was developed by the Kestrel Institute, in which a problem theory defines a problem by specifying domain of problem instances and the structure

312

Y. Zheng, J. Xue, and Z. Zuo

constituting a solution to a given problem instance, and an algorithm theory represents the structure common to a class of algorithms. Smith et al [17] presented a number of theories of design tactics and constructed taxonomies of software design theories and categorical framework for specification refinement and program generation. Nevertheless, their approach does not provide the applicability conditions and thus the strategy selection for a given problem is less mechanical. As many other high-level programming techniques, our approach is also faced with the problem of tradeoff between abstraction and efficiency. We have applied the PAR-based generic approach to unify a class of dynamic programming algorithms [24], and are currently applying it to other algorithm design strategies such as backtracking and branch-and-bound. We are also implementing specifications for extended matroid models such as supermatroids [18] and cg-matroids [8] to support a wider range of greedy solutions.

References 1. Aho, A.V., Hopcroft, J.E., Ullman, J.D.: The Design and Analysis of Computer Algorithms. Addison Wesley, Reading (1974) 2. Alsuwaiyel, M.H.: Algorithms Design Techniques and Analysis. World Scientific Publishing, Singapore (1999) 3. Bird, R.S.: An Introduction to the Theory of Lists. In: Broy, M. (ed.) Logic of Programming and Calculi of Discrete Design. NATO ASI. Ser. F, vol. 36, pp. 5–42 (1987) 4. Bird, R.S., Moor, O.D.: From Dynamic Programming to Greedy Algorithms. In: Moller, B., Partsch, H.A., Schuman, S.A. (eds.) Formal Program Development. LNCS, vol. 755, pp. 43–61. Springer, Heidelberg (1993) 5. Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithm, 2nd edn. McGraw-Hill, New York (2001) 6. Dijkstra, E.W., Scholten, C.S.: Predicate Calculus and Program Semantics. Texts and Monographs in Computer Science. Springer, New York (1990) 7. Edmonds, J.: Matroids and the Greedy Algorithm. Math. Prog. 1, 171–236 (1971) 8. Fujishigey, S., Koshevoyb, G.A., Sano, Y.: Matroids on Convex Geometries (cgmatroids). Discrete Math. 307, 1936–1950 (2007) 9. Gries, D.: The Science of Programming. Springer, New York (1981) 10. Helman, P.: An Algebra for Search Problems and Their Solutions. In: Kanal, L., Kumar, V. (eds.) Search in Artificial intelligence, pp. 28–90. Springer, Berlin (1988) 11. Jeuring, J.: Theories for Algorithm Calculation. PhD thesis, Faculty of Science, Utrecht University (1993) 12. Kaldewaij, A.: Programming: The Derivation of Algorithms. Prenctice-Hall, Englewood Cliffs (1990) 13. Lawler, E.L.: Combinatorial Optimization: Networks and Matroids. Holt, Rinehart and Winston, New York (1976) 14. Luan, S.M., Li, W.: An Incremental Approach to Automatic Algorithm Design. J. Comput. Sci. & Technol. 14, 314–319 (1999) 15. Lowry, M.R.: Algorithm Synthesis Through Problem Reformulation. PhD Thesis, Stanford University (1989) 16. Meertens, L.: Algorithmics towards Programming as a Mathematical Activity. In: Bakker, J.W., Vliet, J. (eds.) CWI Symposium on Mathematics and Computer Science, pp. 289–334. North-Holland, Amsterdam (1986)

Toward an Automatic Approach to Greedy Algorithms

313

17. Smith, D.R.: Designware: Software Development by Refinement. In: 8th International Conference on Category Theory and Computer Science, Edinburgh, pp. 3–21 (1999) 18. Tardos, E.: An Intersection Theorem for Supermatroids. J. Combin. Theory, Ser. B 50, 150–159 (1990) 19. Wachter, R., Reif, J.H., Paige, R.A. (eds.): Parallel Algorithm Derivation and Program Transformation. Kluwer Academic Publishers, New York (1993) 20. Xue, J.Y.: Two New Strategies for Developing Loop Invariants and Their Application. J. Comput. Sci. & Technol. 8, 95–102 (1993) 21. Xue, J.Y.: A Unified Approach for Developing Efficient Algorithmic Programs. Journal J. Comput. Sci. & Technol. 12, 103–118 (1997) 22. Xue, J.Y.: A Practicable Approach for Formal Development of Algorithmic Programs. In: 1st International Symposium on Future Software Technology, Nanjing, China, pp. 158–160 (1999) 23. Xue, J.Y.: PAR Method and its Supporting Platform. In: 1st International Workshop of Asian Working Conference on Verified Software, Macao, China, pp. 11–20 (2006) 24. Zheng, Y.J., Shi, H.H., Xue, J.Y.: Toward a Unified Implementation for Dynamic Programming. In: 8th International Conference on Young Computer Scientists, Beijing, China, pp. 181–185 (2005)

A Novel Approximate Algorithm for Admission Control Jinghui Zhang, Junzhou Luo⋆ , and Zhiang Wu School of Computer Science and Engineering Southeast University, Nanjing 210096, China {zhang jinghui,jluo,zawu}@seu.edu.cn

Abstract. Admission control is the problem of deciding for a given set of requests which of them to accept and which to reject, with the goal of maximizing the profit obtained from the accepted requests. The problem is considered in a scenario with advance reservations where multiple resources exist and users can specify several resource request alternatives. Each alternative is associated with a resource capacity requirement for a time interval on one of the multiple resources and a utility. We give a novel (1 + α)-approximation admission control algorithm with respect to the maximal utility and derive the approximation ratio for different request scenarios. We also design non-guaranteed greedy heuristics. We compare the performance of our approximation algorithm and greedy heuristics in aspect of utility optimality and timing in finding solutions. Simulation results show that on average our approximation algorithm appears to offer the best trade-off between quality of solution and computation cost. And our (1 + α)-approximation algorithm shows its intrinsic stability in performance for different utility functions. Keywords: admission control, approximate algorithm, local ratio, multiple resources.

1 Introduction Problem Statement and Motivation. In this paper, we consider admission control in a scenario with advance reservations, multiple resources and request alternatives. Advance reservations [11,6] and request alternatives are natural concepts that are attractive for the resource provider as well as for users. For the provider, they increase the flexibility and the potential of optimizing the profit obtained from the accepted requests. For the users, advance reservations that are confirmed ahead of time provide a guarantee of the desired quality of service. By specifying several alternatives, the user can increase the probability that the provider accepts the request. The challenge in solving our problem lies in the observation that we deal with admission control for multiple ⋆

This work is supported by National Natural Science Foundation of China under Grant No. 60773103 and 90412014, China Specialized Research Fund for the Doctoral Program of Higher Education under Grant No. 200802860031, Jiangsu Provincial Natural Science Foundation of China under Grant No. BK2007708 and BK2008030, Jiangsu Provincial Key Laboratory of Network and Information Security under Grant No. BM2003201, and Key Laboratory of Computer Network and Information Integration, Ministry of Education of China, under Grant No. 93K-9.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 314–325, 2009. c Springer-Verlag Berlin Heidelberg 2009 

A Novel Approximate Algorithm for Admission Control

315

resources whose capacity can be shared by multiple requests over different time intervals. In addition, each request can have multiple different alternatives. If we impose constraint that keeps capacity of any resource always allocated indivisibly, our problem turns out to be the NP-hard interval scheduling problem [7]. Therefore we will expect the computational complexity to be very high if the optimal solution is found by exhaustive manner. Previous Work. To our best knowledge, we are not aware of any previous work addressing the admission control problem in our formulation (with advance reservations, multiple resources and request with multiple alternatives), but admission control in networks with bandwidth reservation has been studied by many authors like in [8,1,10]. They extended the α-approximation algorithm in [2,3] from its application in the single link bandwidth allocation problem (BAP) with advance reservation to various simple network link topology (star, tree, ring, etc.). Distinctive from their extension in aspect of routing, our problem can be regarded as an extension to BAP with multiple bandwidth resources but no routing issue involved. And this results in additional complexity of resource selection among multiple resources in admission control. The other work highly relevant to ours is by Cohen in [5]. Given any α-approximation algorithm for the single knapsack packing (KP) problem, Cohen’s algorithm is a (1 + α)-approximation algorithm for the multiple knapsack packing (MKP) problem. Our Contribution. We make the following contributions in this paper: – We give clear proof for our (1 + α)-approximation algorithm aiming at admission control for multiple resources, where α is the approximation ratio of admission control for single resource and α be different for different request scenarios. – We give claims of the specific approximation ratio of our algorithm for admission control for multiple resources under different request scenarios, resulting from a combination with the pre-existing ”local ratio” based α-approximation algorithm for single resource admission control. – We present the first implementation of the (1 + α)-approximation algorithm and compare its performance with non-guaranteed heuristics in our simulation. The performance of our approximation algorithm is proved to be independent from utility function differences.

2 Utility-Oriented Admission Control Model for Multiple Resources and Requests with Alternatives For general purpose, we use the notations: request and task, request alternative and task option, interchangeably. Formally, Tasks (requests) are denoted by a set T = {Ti }, i ∈ {1, 2, · · · , m}. m is the number of tasks collected over time involved in admission control. Any task i is represented as a set Ti = {Oij }, j ∈ {1, 2, · · · , ri }, where ri is the number of options of task i. Each option (alternative) Oij is characterized by a five-parameter tuple {ridij , rcapij , tsij , teij , uij }, where: 1) ridij is the identity of the resource in need. 2) rcapij is the required portion of available capacity on resource ridij . 3) tsij and teij are start time and end time in need of ridij for rcapij . 4) uij

316

J. Zhang, J. Luo, and Z. Wu

denotes the utility or profit of this option. Note we deal with the discrete case of the problem, in other words, rcapij , tsij , teij are all integral. Resources available are characterized by a set R = {Rk }, k ∈ {1, 2, · · · , n}, where n is the number of available resources. Any resource Rk is characterized by {Ck , T Sk , T Ek }. Ck is the available capacity of resource k, which may be partially allocated to different tasks over the period [T Sk , T Ek ). Utility measurement are assumed hard, in that utility uij is perceived only if all the four QoS related factors ridij , rcapij , tsij , teij in admission control are approved. An admission control solution is a collection of task options. It is feasible if and only if: (1) it contains at most one option of every task, and (2) for all time instants t, the capacity requirements of the task options in the solution whose time interval contains t does not exceed the total capacity of the corresponding resource. The optimal admission control solution is to find a feasible schedule that maximizes the total profit accrued by task options in the solution. This problem can be formulated mathematically as an Integer Programming problem as follows: max

ri m  

uij xij

(1)

i=1 j=1

Subject to: m 

j=1,···  ,ri

rcapij xij ≤ Ck ,

i=1 t∈[tsij ,teij ),ridij =k

t ∈ [T Sk , T Ek ), ri  xij ≤ 1,

k ∈ [1, n]

(2)

i ∈ [1, m]

(3)

j ∈ [1, ri ]

(4)

j=1

xij ∈ {0, 1},

i ∈ [1, m],

(1) represents that the aim for admission control is to maximize the utility of the accepted options. (2) denotes that for any time t ∈ [T Sk , T Ek ), the total capacity requirements of all the task options in the schedule whose rid is k and runtime [ts, te) contains time instant t do not exceed available capacity Ck of the requested resource k. (3) shows at most one option of each task is accepted. (4) expresses xij is a binary integer of value 0 or 1.

3 Algorithms 3.1 Approximation Algorithm Preliminaries: the Local Ratio Technique. Our approximation algorithm is based on the local ratio technique, which was developed and extended by Bar-Yehuda [3,2]. The power of the local ratio technique is based on the following theorem. Theorem 1. Let F be a set of constraints and let p, p1 and p2 be profit functions such that p = p1 + p2 . Then, if x is an r-approximation solution with respect to (F, p1 ) and with respect to (F, p2 ), it is also an r-approximation solution with respect to (F, p).

A Novel Approximate Algorithm for Admission Control

317

Proof. [2,3] Let x∗ , x∗1 and x∗2 be optimal solutions for (F, p), (F, p1 ) and (F, p2 ) respectively. Then p · x = p1 · x + p2 · x ≥ r · p1 · x∗1 + r · p2 · x∗2 ≥ r · (p1 · x∗ + p2 · x∗ ) = r · p · x∗ . (1 + α)-Approximation Admission Control Algorithm for Multiple Resources. Let m be the number of tasks and n be the number of resources. We use an m ∗ n matrix to  denote all of the task options. Each element of the matrix is represented by aik = (Oij ∧ ridij = k), i ∈ [1, m], k ∈ [1, n]. And |aik | represents task  option . Therefore a (q ∈ [1, |a |]) identifies each option and aikq = numbers of a ik ikq ik  Oij , i ∈ [1, m], k ∈ [1, n], q ∈ [1, |aik |], j ∈ [1, ri ]. We assume SRAC(r, Ar , pr ) is an admission controlalgorithm for any single resource r ∈ [1, n], namely, for a set Ar of all task options air (i ∈ [1, m]) on resource r. p[i, r, q] indicates the profit of option airq with respect to the profit vector pr of resource r. The approximation ratio of SRAC(r, Ar , pr ) is assumed α. We now construct a (1 + α)-approximation algorithm M RAC(n) for the admission control problem for multiple resources. Our algorithm extends Cohen’s in [5] in two aspects: 1) extension from one-dimensional multiple knapsack packing to two-dimensional admission control for multiple resources. 2) tasks with multiple options are explicitly supported. M RAC(n) needs to only invoke the recursive N extRAC(r, Ar , pr ) (Algorithm 1) with r = 1. Note the difference between selected taskoptionsSr and candidate task options Sr on resource r in Algorithm 1: n Sr = Sr+1 (Sr \ i=r+1 Si ). ”\” means the exclusive option selection for a task, namely, at most one option of a task will be finally selected. Algorithm 1. N extRAC(r, Ar , pr ) 1 2

3 4 5 6 7 8 9 10 11

Run SRAC(r, Ar , pr ) on resource r using pr as profit function and Sr be the candidate task options running on resource r; Decompose the profit function pr into two profit functions pr1 and pr2 such that for every i ∈ [1, m], k ∈ [1, n], p ∈ [1, |aik |], ⎧ r p [i, r, q] if (for r, ∃q ∈ [1, |air |], airq ⎪ ⎪ ⎨ ∈ Sr ) and k > r r p1 [i, k, p] = pr [i, r, p] if k = r ⎪ ⎪ ⎩ 0 otherwise pr2 [i, k, p] = pr [i, k, p] − pr1 [i, k, p]; if r < n then set pr+1 = pr2 , and remove the column of resource r from pr+1 ; Perform N extRAC(r + 1, Ar+1 , pr+1 ); Let Sr+1 be the returned task option selected running on resource r + 1;   Let Sr be Sr+1 (Sr \ n i=r+1 Si ); return Sr ; else return Sr = Sr

318

J. Zhang, J. Luo, and Z. Wu k =1

O 11 O 21 O 12 R 1

O 22

R2

O 31 O 13

k =1

O 13

i= 1

15 10

2

25

O 21 O 22

2

O 31 O 32

3

R3

O 32

3

2

O 11 O 12

i= 1

k =1 i= 1

15 10

2

25

2

k =1

3

15

0

2

0

25 0

3

0

k =2

2 3

k =2

5 20 20

P 12 S 3=({o 32}),

2

0

3

0

i= 1

-9

P 22

3

20 25

2 P S 2={o 31}

1

5

-9

3

i= 1

0

2

5

3 3 P S 3={o 32} P 1

S 2=({},{o 32}),

k =3

k =3 i= 1 2

2

5

3

25

k =3

3

-9

i= 1

5

2

20

3

-9

i= 1

5

P2

3

0

i= 1

k =2

3

-9

P 11

25

20 1

2

3

30

P S 1={o 11,o 21}

0

i= 1

6

3

{a ik}

3

2

3

0

P2

3

S 1=({o 11,o 21},{},{o 32})

Fig. 1. An example of (1 + α)-approximation admission control algorithm for multiple resources

Figure 1 shows an illustrative example with 3 resources R1 , R2 , R3 and 3 tasks T1 = {O11 , O12 , O13 }, T2 = {O21 , O22 } and T3 = {O31 , O32 }. It can be easily found that after reorganization options of task T1 on R1 , R2 , R3 as a11 = {O11 , O12 }, a12 = {}, a13 = {O13 }. For T2 and T3 , options are distributed as a21 = {O21 }, a22 = {O22 }, a23 = {} and a31 = {}, a32 = {O31 }, a33 = {O32 }, respectively. With respect to the resource capacity requirements of those task options, we learn that O22 and O31 on R2 , O32 and O13 on R3 intersect with each other, respectively. For profit function we can see the initial profit matrix p1 in Figure 1. p1 [1, 1, 1] = p1 (O11 ) = 15, p1 [1, 1, 2] = p1 (O12 ) = 10, p1 [2, 1, 1] = p1 (O21 ) = 25, p1 [2, 2, 1] = p1 (O22 ) = 30, p1 [3, 2, 1] = p1 (O31 ) = 20, p1 [1, 3, 1] = p1 (O13 ) = 6, p1 [3, 3, 1] = p1 (O32 ) = 25. The (1 + α)-approximation admission control algorithm for multiple resources and request alternatives in Figure 1 works as follows: with n=3 our (1 + α)-approximation algorithm M RAC(n) invoke Algorithm 1 with r = 1 as a starting point. With r = 1, SRAC(1, A1 , p1 ) using profit matrix p1 is employed for admission control on resource R1 and task options O11 and O21 are selected as the set S 1 of candidate options on resource R1 . Consequently, the profit of option O13 for the same task T1 on resource R3 , has the same profit as O11 in p11 with respect to p1 . Option O22 , which has O21 for the same task T2 selected as candidate on resource R1 , acts likewise. According

A Novel Approximate Algorithm for Admission Control

319

to the definition of pr1 in step 2 of Algorithm 1, we get p11 [1, 1, 1] = p11 (O11 ) = 15, p11 [1, 1, 2] = p11 (O12 ) = 10, p11 [2, 1, 1] = p11 (O21 ) = 25, p11 [2, 2, 1] = p11 (O22 ) = 25, p11 [3, 2, 1] = p11 (O31 ) = 0, p11 [1, 3, 1] = p11 (O13 ) = 15, p11 [3, 3, 1] = p11 (O32 ) = 0. As for p12 = p1 − p11 , after calculation we get p12 [1, 1, 1] = p12 (O11 ) = 0, p12 [1, 1, 2] = p12 (O12 ) = 0, p12 [2, 1, 1] = p12 (O21 ) = 0, p12 [2, 2, 1] = p12 (O22 ) = 5, p12 [3, 2, 1] = p12 (O31 ) = 20, p12 [1, 3, 1] = p12 (O13 ) = −9, p12 [3, 3, 1] = p12 (O32 ) = 25. As p12 = p1 − p11 and after removing the 0 profit column in p12 for resource R1 that has been done, we get profit matrix p2 for resource R2 . p2 [2, 2, 1] = p2 (O22 ) = 5, p2 [3, 2, 1] = p2 (O31 ) = 20, p2 [1, 3, 1] = p2 (O13 ) = −9, p2 [3, 3, 1] = p2 (O32 ) = 25. Now SRAC(2, A2 , p2 ) using profit matrix p2 is employed for admission control on resource R2 . Being carried out in such a way, we will obtain candidate options on resource R1 , R2 , R3 as S 1 = {O11 , O21 }, S 2 = {O31 }, S 3 = {O32 }. Returning from the recursive process, as O32 ∈ S3 is selected on resource R3 , O31 ∈ S 2 as candidate on resource R2 for the same task T3 will not be selected. The final solution will be: S1 = ({O11 , O21 }, {}, {O32}) and the utility by our (1 + α)-approximation algorithm is then p(O11 ) + p(O21 ) + p(O32 ) = 15 + 25 + 25 = 65, while the utility of the optimal solution is p(O11 )+p(O22 )+p(O32 ) = 15+30+25 = 70. To simplify the example, at each step algorithm SRAC(r, Ar , pr ) chooses the optimal solution with respect to pr . Claim 1. If SRAC(r, Ar , pr )(r ∈ [1, n]) is α-approximation, then M RAC(n) is (1 + α)-approximation. Proof. For the following proof we use the notation p(S) to denote the profit gained by admission control solution S with respect to profit function p. The proof is by induction on the number of resources available when the algorithm is invoked. When there is only one single resource n left, admission control solution Sn returned by the SRAC(n, An , pn ) is assumed α-approximation with respect to pn , which can be relaxed to a (1 + α)-approximation. We note here SRAC(r, Ar , pr ) is α-approximation for multiple-option tasks. For the inductive step, assume that Sr+1 is a (1 + α)approximation with respect to pr+1 , and we shall prove that Sr is also a (1 + α)approximation with respect to pr . We will prove it from the perspective of pr1 and pr2 , respectively. Regarding pr2 , we can see that task options selected in Sr does not make any more additional contributions to pr+1 other than those task options also in Sr+1 . The reason is that the profit column of pr2 concerned with task options in Sr \Sr+1 are all 0, and we know that pr2 is identical to pr+1 , except for the column with 0 profit. Therefore, Sr , which includes Sr+1 as a subset, is also a (1 + α)-approximation with respect to pr2 . Regarding pr1 , we see the profit contribution come from task options (1) a column for resource r, which is the same as the profit column in pr . Applying SRAC(r, Ar , pr ) on resource r, Sr is an α-approximation with respect to (1). Therefore the best possible solution with respect to (1) will be at most α ∗ pr1 (Sr ). (2) for any task i which has option airq selected as candidates in Sr on resource r, all of its options aikq on resource k > r has the same profit pr [i, r, q] with respect to pr1 . And regarding (2) the best possible solution will contribute at most pr1 (Sr ) for that at most one option of a task will be selected and all those options on resource k > r has the same profit. Since the maximal possible profit regarding pr1 from (1) and (2) is (1 + α) ∗ pr1 (Sr ), we see that Sr is a (1 + α)-approximation with respect to pr1 . And task options in Sr and Sr contribute the same profit to pr1 , namely, pr1 (Sr ) = pr1 (Sr ), Sr is also a (1 + α)-approximation with

320

J. Zhang, J. Luo, and Z. Wu

respect to pr1 . By Theorem 1, as Sr is (1 + α)-approximation with respect to both pr1 and pr2 and pr = pr1 + pr2 , Sr is (1 + α)-approximation with respect to pr . α-Approximation Admission Control Algorithm for Single Resource. From previous section SRAC(r, Ar , pr ), r ∈ [1, n] is assumed to be an α-approximation. For completeness we describe the α-approximation SRAC(r, Ar , pr ) as Algorithm 2 used as a subroutine of Algorithm 1. This pre-existing algorithm is proved in detail in [2,3], where they used the local ratio technique to solve BAP. Notice α is determined by w in Algorithm 2 and w is different for different task scenarios as described as follows. Algorithm 2. SRAC(r, Ar , pr ) 1 2 3 4 5 6

7 8 9 10 11

if Ar = ∅ then return ∅; if there exists airq , i ∈ [1, m], q ∈ [1, |air |] such that pr [i, r, q] < 0 then return SRAC(r, Ar \ airq , pr ) else Let airq be the task option with minimum end-time in Ar . Decompose the profit function pr into two profit functions pr1 and pr2 such that for every i ∈ [1, m], j ∈ [1, m], p ∈ [1, |ajr |], q ∈ [1, |air |], ⎧ r p [i, r, q] if j = i ⎪ ⎪ ⎨ w ∗ pr [i, r, q] if j = i and ajrp r p1 [j, r, p] = intersect with airq ⎪ ⎪ ⎩ 0 otherwise pr2 [j, r, p] = pr [j, r, p] − pr1 [j, r, p]; Sr ←SRAC(r, Ar , pr2 ); if Sr airq is feasible then  return Sr = Sr airq ; else return Sr = Sr ;

Combining M RAC( n) and SRAC( r, Ar , pr ) . According to different α value for different task scenarios in single resource admission control problem in [2,3], We obtain the following claims of specific approximation ratio (1+α) for admission control for multiple resources. For option Oij = {ridij , rcapij , tsij , teij , uij }, with ridij = k, let dij = rcapij /Ck denote the required capacity portion of corresponding resource. We call a task option wide if dij > 1/2 and narrow if dij ≤ 1/2. Claim 2. In a task scenario where each task has only one option and all task options are wide, M RAC(n) achieves a 1-approximation. (α = 1 with w = 1 in Algorithm 2) Claim 3. In a task scenario where each task has only one option and all task options are narrow, M RAC(n) achieves a 2-approximation. (α = 2 with w = djrp /(1 − dirq ) in Algorithm 2)

A Novel Approximate Algorithm for Admission Control

321

Claim 4. In a task scenario where each task has only one option and task option width are mixed, M RAC(n) achieves a 3-approximation. (α = 3) Claim 5. In a task scenario where each task has a number of options and all task options are wide, M RAC(n) achieves a 3-approximation. (α = 2 with w = 1 in Algorithm 2) Claim 6. In a task scenario where each task has a number of options and all task options are narrow, M RAC(n) achieves a 4-approximation. (α = 3 with w = 2 in Algorithm 2) Claim 7. In a task scenario where each task has a number of options and task option width are mixed, M RAC(n) achieves a 6-approximation. (α = 5) 3.2 Greedy Algorithms Task-side Greedy. Opportunistic Load Balancing (OLB) tentatively select one option for each task in an arbitrary order, to assign to the resource that is expected to be available during the time interval of the option and not to violate the resource capacity constraint, regardless of the task option’s utility. Maximal Optional Utility (MOU) selects the option with maximal utility for each task, regardless of the fact that time interval and resource capacity constraints of the option may be violated. One disadvantage of this approach is that once the option with maximal utility of each task is rejected for violating time or resource constraints, the task will be rejected. Maximal Gainable Utility (MGU) is to combine the benefits of OLB and MOU, namely, to pick option of each task that will gain as maximal utility as possible and not to violate constraints. MaxMax is based on MGU. However, Max-Max considers all unmapped tasks during each mapping decision and MGU only considers one task at a time. Sufferage is much like Max-Max except that the utility of an option is replaced by the sufferage utility between an option and its secondary option. Note the above greedy algorithms are adapted from approaches employed in [4,9], where their goal is to map independent tasks onto heterogeneous computing systems with minimal task finish time. The major difference from ours here lies in that our problem has two-dimensional constraints while theirs do not. Resource-side Greedy. R-OLB is much like OLB except that we now focus on the resource side and try to select options for a resource among all task options on the resource other than among options of the same task. R-MGU, R-Sufferage are also much the same as MGU and Sufferage respectively, except that the focus is on the resource side now.

4 Performance Evaluation To evaluate the performance of these algorithms we test them on randomly generated problem instances using the simulation environment implemented in C++. We used two measurements to compare their efficiency: the optimality of the solution returned by the algorithms and the running time required to finish it.

322

J. Zhang, J. Luo, and Z. Wu

4.1 Assumptions Tasks to be accepted are assumed to be collected over the time period [0, 12) and task arrival follows a poisson distribution with mean arrival rate λ from 20 to 300 in our simulation. Resource capacity requirement of each task follows a bimodal distribution. Based on a reference resource, short(long) tasks have a length of mean value 5(35) time units with a standard deviation of 2(5) units. Half of the tasks are short tasks, half are long. We generate on average 5 options for each task and the width may be narrow (dij ≤ 1/2) or wide (dij > 1/2). The number of available resources is fixed as n = 20 and available capacity Ck of resources k ∈ [1, 20] are assumed to follow a discrete uniform distribution between [1, 40] units. And the reservable time window [T Sk , T Ek ) for resource k ∈ [1, n] are uniformly set to be [0,12). Two utility functions are assumed: 1) proportional uij = (teij −tsij )∗rcapij 2) normalized uij = S((teij −tsij )∗rcapij ) 2 − 1. We use GNU Linear Programming kit (GLPK) to solve and S(x) = exp(−0.5x)+1 the relaxed linear programming formulation of our problem and use the result as a reference optimality value. 4.2 Optimality Results Figure 2(a), 3(a) correspond to task scenario of Claim 2 that claims our approximate algorithms is 1-approximation, namely, the optimal algorithm. The result proves the correctness of Claim 2, irrespective of utility functions or task numbers. The notable difference between Figure 2(a) and 3(a) lies in that next-best algorithms are different, R-Sufferage for normalized utility function and MaxMax(Sufferage) for proportional utility function. MaxMax suffers from sacrificing too much resource for tiny surplus in normalized utility function. Figure 2(b), 3(b) show the performance of algorithms for the task scenario of Claim 3. Though our algorithm is claimed to be 2-approximation, the result suggests it is practically the optimal among all those algorithms for normalized utility function (Figure 2(b)) and one of the three best for proportional utility function (Figure 3(b)). Observing the only difference between Figure 3(b) and 2(b) is utility function, we can see the sharp performance drop of MaxMax and R-MGU from best for proportional utility function to worst for normalized utility function. Figure 2(c), 3(c) show the performance of our 3-approximation algorithm for Claim 4. For n = 20 the upward trend of the curve for the 3-approximation algorithm

(a) d>1/2

(b) d≤1/2

(c) mixed

Fig. 2. Normalized utility function, n=20, single-option task

A Novel Approximate Algorithm for Admission Control

(a) d>1/2

(b) d≤1/2

(c) mixed

Fig. 3. Proportional utility function, n=20, single-option task

(a) d>1/2

(b) d≤1/2

(c) mixed

Fig. 4. Normalized utility function, n=20, multiple-option task

(a) d>1/2

(b) d≤1/2

(c) mixed

Fig. 5. Proportional utility function, n=20, multiple-option task

Fig. 6. Timing result, n=20, multiple-option task, mixed width

323

324

J. Zhang, J. Luo, and Z. Wu

suggest that its performance improves with a more heavy workload. And we can still see the sharp performance change of MaxMax for utility function differences. Figure 4(a), 5(a) suggest our 3-approximation algorithm under the task scenario of Claim 5 is in fact the optimal for both utility functions. And R-Sufferage is the next-best optimal for normalized utility function and MaxMax and R-MGU is next-best optimal for proportional utility function. We can still find the sharp performance change of heuristics MaxMax, R-MGU and R-Sufferage between two different utility functions in Figure 4(a) and 5(a) for their vulnerable adaptivity. Figure 4(b) show our 4-approximation algorithm is optimal for normalized utility function under the task scenario of Claim 6. And Figure 5(b) shows it achieves less utility than MaxMax, Sufferage and R-MGU for proportional utility function. However, it achieves at least 75% utility of the optimal fractional solution in its worst performance for proportional utility function. Therefore we could guess the practical performance of our approximate algorithm will be above the theoretical optimality on average. Figure 4(c), 5(c) reflect the performance of algorithms under the most general task scenario claimed by Claim 7. Figure 4(c), 5(c) shows that our 6-approximation algorithm is practically optimal for normalized utility function and one of the three best algorithms for proportional utility function. And what impresses us is that our approximate algorithm achieves at least 70% of utility of the optimal fractional solution, which is far above the theoretical optimality of 1/6 optimal for this most general task scenario. Therefore, if the task has multiple options and task width and utility function are unknown, our (1 + α)-approximation algorithm will be the best choice. 4.3 Timing Results Due to space limit, we only show the timing results for task scenario of Claim 7, which is the most general and time consuming case for all of the algorithms. Figure 6 reflect the time to find a solution with the resource number n = 20. We can see GLPK in finding a relaxed linear programming solution needs the longest time. And our approximation algorithm takes about 2 seconds if n = 20 and task arrival rate λ = 300. Though our (1 + α)-approximation takes more time than greedy heuristics, we think it a quite rewarding trade off for the quality of solution it finds.

5 Conclusion Regarding all those given request scenarios and two different utility functions, we can see that our (1 + α)-approximation algorithm is on average the best candidate admission control algorithm for multiple resources and requests with alternatives, not only for its stable performance that stems from its intrinsic approximation ratio for different request scenarios, but also for its favorable practical performance well above the theoretical optimal ratio. The major weakness of heuristics like MaxMax, R-Sufferage lies in the vulnerable adaptivity to different utility functions. In conclusion our simulation results show that our (1 + α)-approximation algorithm appears to offer the best trade-off between quality of solution and computation cost. It will be a good choice for most admission control cases for multiple resources, especially for those cases utility functions or request width are unknown.

A Novel Approximate Algorithm for Admission Control

325

References 1. Adamy, U., Erlebach, T., Mitsche, D., Schurr, I., Speckmann, B., Welzl, E.: Off-line admission control for advance reservations in star networks. In: Persiano, G., Solis-Oba, R. (eds.) WAOA 2004. LNCS, vol. 3351, pp. 211–224. Springer, Heidelberg (2005) 2. Bar-Noy, A., Bar-Yehuda, R., Freund, A., Naor, J(S.), Schieber, B.: A unified approach to approximating resource allocation and scheduling. J. ACM 48(5), 1069–1090 (2001) 3. Bar-Yehuda, R., Bendel, K., Freund, A., Rawitz, D.: Local ratio: A unified framework for approximation algorithms in memoriam: Shimon even 1935-2004. ACM Comput. Surv. 36(4), 422–463 (2004) 4. Braun, T.D., Siegel, H.J., Beck, N., B¨ol¨oni, L., Maheswaran, M., Reuther, A.I., Robertson, J.P., Theys, M.D., Yao, B., Hensgen, D.A., Freund, R.F.: A comparison of eleven static heuristics for mapping a class of independent tasks onto heterogeneous distributed computing systems. J. Parallel Distrib. Comput. 61(6), 810–837 (2001) 5. Cohen, R., Katzir, L., Raz, D.: An efficient approximation for the generalized assignment problem. Inf. Process. Lett. 100(4), 162–166 (2006) 6. Guerin, R.A., Orda, A.: Networks with advance reservations: the routing perspective. In: INFOCOM 2000, vol. 1, pp. 118–127 (2000) 7. Kovalyov, M.Y., Ng, C.T., Cheng, T.C.E.: Fixed interval scheduling: Models, applications, computational complexity and algorithms. European Journal of Operational Research 178(2), 331–342 (2007) 8. Lewin-Eytan, L., Naor, J(S.), Orda, A.: Routing and admission control in networks with advance reservations. In: Jansen, K., Leonardi, S., Vazirani, V.V. (eds.) APPROX 2002. LNCS, vol. 2462, pp. 215–228. Springer, Heidelberg (2002) 9. Maheswaran, M., Ali, S., Siegel, H.J., Hensgen, D., Freund, R.F.: Dynamic mapping of a class of independent tasks onto heterogeneous computing systems. Journal of Parallel and Distributed Computing 59, 107–131 (1999) 10. Rawitz, D.: Admission control with advance reservations in simple networks. Journal of Discrete Algorithms 5, 491–500 (2007) 11. Wischik, D., Greenberg, A.: Admission control for booking ahead shared resources. In: INFOCOM 1998, vol. 2, pp. 873–882 (1998)

On the Structure of Consistent Partitions of Substring Set of a Word Meng Zhang, Yi Zhang, Liang Hu⋆,⋆⋆ , and Peichen Xin College of Computer Science and Technology Jilin University, Changchun 130012, China {zhangmeng,hul}@jlu.edu.cn [email protected] [email protected]

Abstract. DAWG is a key data structure for string matching and it is widely used in bioinformatics and data compression. But DAWGs are memory greedy. Weighted directed word graph (WDWG) is a spaceeconomical variation of DAWG which is as powerful as DAWG. The underlay concept of WDWGs is a new equivalent relation of the substrings of a word, namely the minimal consistent linear partition. However, the structure of the consistent linear partition is not extensively explored. In this paper, we present a theorem that gives insight into the structure of consistent partitions. Through this theorem, one can enumerate all the consistent linear partitions and verify whether a linear partition is consistent. It also demonstrates how to merge the DAWG into a consistent partition. In the end, we give a simple and easy-to-construct class of consistent partitions based on lexicographic order.

1

Introduction

Given a text string, full-text indexes are data structures that can be used to find any substring of the text quickly. Many full-text indexes have been proposed, for example suffix trees [8,14], DAWGs(Directed Acyclic Word Graph) [2], CDAWGs(Compact DAWG) [3] and suffix arrays [12,9]. DAWG is a data structure studied by A. Blumer J. Blumer, Hausser, Ehrenfeucht, Crochemore, Chen, Seiferas [2,4,3]. It is the minimal automaton accepting the set of suffixes of a string [4]. It has close relation to suffix tree in nature, i.e., the states of DAWG are corresponding to nodes of suffix tree for the reverse string. DAWG is the key data structure for string matching [7,5], and its varieties are used in various applications [10,11,16]. The major drawback that limits the applicability of DAWGs is the space complexity, the size of DAWGs is much larger than the original text. Weighted Directed Word Graph (WDWG) [17] is an effort to solve this problem by a weighed automaton approach. It is as powerful as the DAWG, but more space ⋆ ⋆⋆

Corresponding author. Supported by National Natural Science Foundation of China No.60873235.

X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 326–335, 2009. c Springer-Verlag Berlin Heidelberg 2009 

On the Structure of Consistent Partitions of Substring Set of a Word

327

economical. A WDWG for w has at most |w| states and 2|w| − 1 weighted edges, while the DAWG for w has at most 2|w| − 2 states and 3|w| − 4 edges. The underlay concept supporting WDWG is the minimal consistent linear partition for the set of subwords of a string. In [17], an on-line construction is given for WDWGs as well as the minimal consistent linear partitions. However, the structure of the minimal consistent linear partitions is not well understood. What properties make a partition be consistent and minimal is not revealed yet. In this paper, we give an answer to this problem. A partition of the subwords of w is a series of disjoint subsets whose union set is the set of subwords of w. We say a partition is linear if every subword in any element of the partition is a suffix of the longest subword in this element. A linear partition is consistent if the following property is held: for any strings u, v in an element of the partition and a letter α, uα and vα don’t belong to the different elements in the partition. The minimal linear partitions are linear partitions which have the least number of elements. We first prove that the minimal linear partition is the quotient of DAWG, then present a theorem that demonstrates how to merge the DAWG into a consistent partition. Through the theorem, the minimal consistent linear partitions can be built directly from the DAWG following a very simple rule, and all the possible minimal consistent linear partitions can be enumerated. We present a class of rather simple consistent partition based on lexicographic order. The paper is organized as follows. Section 2 gives the introduction of DAWG. Section 3 introduces the concept of linear consistent partition and WDWG. We then prove the existence of the minimal consistent linear partitions in Section 4 and reveal the structure of the consistent linear partitions in Section 4, 5. The results together with some open issues are discussed in Section 6.

2

Basic Definitions

Let Σ be a nonempty alphabet and Σ ∗ the set of words over Σ, with ε as the empty word. Let w be a word in Σ ∗ , |w| denote its length, and w[i] its ith letter. If w = xyz for words x, y, z ∈ Σ ∗ , then x is a prefix of w, y is a subword of w, and z is a suffix of w. Denote wr the reverse word of w. P ref (w) denotes the set of all prefixes of w, Suf f (w) denotes the set of all suffixes of w and F act(w) the set of its subwords. Let S ⊂ Σ ∗ . For any string u ∈ Σ ∗ , let u−1 S = {x | ux ∈ S}. The syntactic congruence associated with Suf f (w) is denoted by ≡Suf f (w) and is defined, for x, y, w ∈ Σ ∗ , by x ≡Suf f (w) y ⇐⇒ x−1 Suf f (w) = y −1 Suf f (w). We call classes of subwords the congruence classes of the relation ≡Suf f (w) . Let [u]w denote the congruence class of u ∈ Σ ∗ under ≡Suf f (w) . The longest element in [u]w is called its representative, denoted by r([u]w ). Definition 1.  [2] The DAWG for  w is a directed acyclic graph with set of states V (w) = [u]w | u ∈ F act(w) and set of edges E(w) = {([u]w , a, [ua]w ) | u, ua ∈ F act(w), a ∈ Σ}, denoted by DAW G(w). [ε]w is the root of DAW G(w).

328

M. Zhang et al.

0

1 7

a b a b b a 6

a

a b a b 3' 3

4

a a b

b 2

2'

a

b

b

0 a

1 b 2' 2 a a 3' 3 b b b 4 b 5 a a 6

b a

a 5

a b a b

7

Fig. 1. w = ababbaa. The right is the DAWG for w. The left is the corresponding tree formed by suffix links (dotted edges) and nodes (boxes) of the DAWG. The vertical thick line represents [ε]w . Through this tree, the subwords accepted by a state can be enumerated by concatenating each suffixes of the string in the corresponding box and the strings in the boxes in the suffix chain of the state. For example, the set of subwords accepted by state 5 is {bb, abb, babb, ababb}.

An edge labelled by letter a is called an a-edge. The edges in DAWGs are divided into two categories. The edge (p, a, q) is called solid if r(p)a equals r(q), otherwise secondary. Let p = [ε]w , denote f ail(p) the state whose representative v is the longest suffix of r(p) such that v not ≡Suf f (w) r(p). The pointer from p to f ail(p) is called a suffix link. The sequence p, f ail(p), f ail2(p), . . . is finite and ends at the root, called the suffix chain of p, denoted by SC(p). Let t be a prefix of w, if t is not a suffix of any prefix of w, then t is a prime prefix of w. For wa, any prime prefix of w, which is not a suffix of wa, is a prime prefix of wa. Denote the number of prime prefixes of w by ϕ(w).

3

Consistent Linear Partition and Weighted Directed Word Graph

Let u be a suffix of v. We use the following notions: [u, v]={t | t is a suffix of v and |u| ≤ |t| ≤ |v| }, [u, v)={t | t is a suffix of v and |u| ≤ |t| < |v| }, (u, v]={t | t is a suffix of v and |u| < |t| ≤ |v| }. Call these sets intervals. For an interval I, denote the longest string in I by end(I), the shortest one by short(I). F act(w) can be partitioned into a set of disjoint intervals. DAWG and    suffix  trie [13] are such partitions. A state s of DAWG is the interval r f ail(s) , r(s) . The set of disjoint subsets of F act(w) whose union set is F act(w) is called a partition of F act(w). If all the elements in a partition P are intervals, then P is called a linear partition of F act(w). Let I ∈ P , u ∈ I, I is denoted by [u]P .

On the Structure of Consistent Partitions of Substring Set of a Word

329

a a/1

a b a b b a a

Ι 7 = [ε, ababbaa]

I7 a a /6

a b a b

Ι 6 = [bba, ababba]

I6

b

a b

Ι 3 = [ba, aba]

b/1

I3 b

a a/2

a

b/3

Ι 4 = [b, abab]

a b a b b

Ι 5 = [bb, ababb]

a/5

I4 b /4

a b a b

I5

Fig. 2. The right is a WDWG for ababbaa. The left is the corresponding consistent partition and suffix links, where the weight of each edge is the length of string from which the edge leaves the box.

Any subword u can be indexed by the pair (I, |u|) due to the linear property of P . An example of the partitions is illustrated in Fig. 2. For K ∈ Σ ∗ , denote the set Ka∩F act(w) by Ka/w. A special family of linear partitions is defined as follow. Definition 2. [17] Let P be a partition. The pair (I, α) ∈ P ×Σ is a consistent pair, if there exists one and only one interval in P , say J, such that Iα/w ⊆ J. If any (I, α) such that Iα/w = ∅ is a consistent pair, then P is a consistent partition. DAWGs are obviously consistent partitions. However, not all the partitions are consistent. We define the WDWG based on the consistent linear partition. Definition 3. [17] The Weighted Directed Word Graph (W DW G) for w over a consistent linear partition P is the weighted directed graph with node set P , and edge set (I, a, L, J) | I, J ∈ P , Ia/w  = ∅ and Ia/w ⊆ J; ∀t ∈ I, if |t| ≤ L then ta ∈ J, otherwise ta ∈ / F act(w) , denoted by W DW GP (w). [ε]P is the root of W DW GP (w), denoted by R. A WDWG for w = ababbaa is illustrated in Fig. 2. DAWG can be viewed as a WDWG where the weight of each edge out of a state s is |r(s)|. Indexing by WDWG. Define  an automaton ST (Q, E, T, i) based on  W DW GP (w) as follows: Q = (I, l) | I ∈ P, |short(I)| ≤ l ≤ |end(I)| , E = (I, l), a, (J,l + 1) | (I, l), (J, l + 1) ∈ Q, a ∈ Σ and there exists an edge (I, a, L, J), l ≤ L , T = Q and i = (R, 0). Apparently, the automaton is equivalent to the suffix trie for w. Based on a WDWG of w, the following procedure can recognize whether a string is a subword of w.

330

M. Zhang et al.

——————————————————————— Algorithm. W DW G Scan(x) Input: x is the input word. 1 (I, L) ← (R, 0) 2 while L < |x| do 3 if I has an edge (I, x[L], L′ , J) then 4 if L ≥ L′ then 5 return x is not a subword of w 6 end if 7 (I, L) ← (J, L + 1) 8 else 9 return x is not a subword of w 10 end if 11 end while 12 return x is a subword of w ———————————————————————

4

Minimal Consistent Linear Partitions

In this section, we are interested in the partitions with the least number of intervals, namely minimal consistent linear partitions of F act(w). The existence and the structure of this class of partition is revealed in this section. Denote the number of intervals in a linear partition P by |P |. Lemma 1. For a linear partition P of F act(w), |P | ≥ ϕ(w). Proof. For any prime prefix of w, say p, there is an interval I such that end(I) = p in any P . Hence, |P | > ϕ(w). Let v1 , . . . , vϕ(w) be an arbitrary order of prime prefixes of w. We first construct interval J1 = [ε, v1 ] for v1 . Next for each vi , i > 1, construct an interval Ji in order. That is Ji = [u, vi ] where u is the longest suffix of vi that not belongs to J1 , . . . , Ji−1 . Since every subword of w is in an interval of P , P = {J1 , . . . , Jϕ(w) } is a partition of F act(w). Therefore, |P | ≥ ϕ(w). ⊓ ⊔ A linear partition of F act(w) is minimal , if the number of intervals in it is ϕ(w). For a prime prefix p, denote the interval which p belongs to by I|p| . An example of minimal linear partitions is illustrated in Fig. 2. The following is a property of minimal linear partitions. Lemma 2. In any minimal linear partition, all the strings in a DAWG state are in the same interval of the partition. Proof. Let P be a minimal linear partition. Assume that there is a state s of DAW G(w) such that the subwords in s are not in a single interval in P . Let u and au be two subwords in s that are in two different intervals, say I, J accordingly. Since u is not the longest string in s, every occurrence of u in w

On the Structure of Consistent Partitions of Substring Set of a Word

331

must be preceded by the same letter a. For au ∈ / I, so, end(I) = u. Since u is not a prime prefix of w, P is not a minimal linear partition. This contradicts the assumption that P is minimal. ⊓ ⊔ It follows from Lemma 2 that the interval [x, p] of a minimal linear partition is the union of a set of DAWG states. Apparently, these states are in the suffix chain from [p]w to [x]w . For a state s of DAW G(w), denote by F s(s) the set of states whose suffix link is s, called the fail set of s. ζ is an order function of DAW G(w), if ζ is a map from V (w) to V (w) such that if F s(s) = ∅ then ζ(s) is undefined, otherwise ζ(s) ∈ F s(s). ζ(s) is called the electee child of s. For example, in Fig. 1, for state 1, F s(1) = {7, 3′}, and according to the partition on the right, ζ(1) = 7. If F s(s) = ∅ then end(s) is a prime prefix of w and vice versa. For an order function ζ, define the set seed(ζ) = {s ∈ V (w) | ζ(s) is undefinded.}. Obviously, |seed(ζ)| = ϕ(w). Denote by topζ (s) the first state t in the suffix chain of s such   that t = ζ f ail(t) .     (s) , end(s) can be For each s ∈ seed(ζ), an interval I(s) = short top ζ    derived. Let P (ζ) = s∈seed(ζ) I(s) . Intervals in P (ζ) are disjoint, for each state of DAWG belongs to one and only one interval of P (ζ). For the same reason,  s∈seed(ζ) I(s) = F act(w). We have that P (ζ) is a minimal linear partition, since |seed(ζ)| = ϕ(w). For example, according to Fig. 2 and Fig. 1, I4 = 4 ∪ 2 ∪ 2′ , 2′ is the top state of 4. By Lemma 2, we can associate a minimal linear partition P with an order function. Define a function ζ as: if F s(s) = ∅ then leave ζ(s) undefined; otherwise ζ(s) = s′ if f ail(s′ ) = s and s′ and s are in the same interval. We have that P (ζ) = P . To summarize: Proposition 1. There is an one-to-one correspondence between minimal linear partitions and order functions. We next focus on the order functions which is corresponding to the consistent partitions. The following lemma gives a useful property of DAWG. Lemma 3. Let sA , sB be states of DAW G(w), f ail(sA ) = sB , (sA , a, dA ) and e = (sB , a, dB ) be edges of DAW G(w). If e is solid, then f ail(dA ) = dB . Otherwise, dA = dB . Proof. Let e be solid, sA = [u, v], sB = [x, y]. For f ail(sA ) = sB , we have that y is the longest suffix of v that is not in sA . dA = dB , since e is solid. So ya is not in dA . Therefore, ya is the longest suffix of va that is not in dA . For ya ∈ dB , f ail(dA ) = dB . Let e be secondary. It implies that there exists one subword bya of w, b ∈ Σ, and ya and bya are in the same state. ua is a subword of w, for sA has an edge (sA , a, dA ). bya = ua, for y is the suffix of u such that |u| = |y| + 1. Then ya and ua are in the same state. Thus dA = dB . ⊓ ⊔ The following theorem is the main result of the structure of the consistent partitions, which gives the property that makes an order function yield a consistent partition.

332

M. Zhang et al.

ζ(s)

.. .

s

.. . a .. .

ζ(d) .. .

a d

Fig. 3. An illustration of Theorem 1. The graph is a sketch of a consistent partition P (ζ). If (s, a, d) is a solid edge and ζ(s) has an a-edge, say e, then ζ(d) is the destination of e (e is not necessarily a solid edge). If ζ(s) has no a-edge, then ζ(d) can equal any state in F s(d) while P (ζ) keeps consistent.

Theorem 1. Let ζ be an order function of DAW G(w). P (ζ) is a consistent partition, if and only if for any solid edge (s, a, d) of DAW G(w), if s′ = ζ(s) has an a-edge, say (s′ , a, d′ ), then ζ(d) = d′ . Proof. Let ζ be an order function of DAW G(w) satisfying that for any solid edge (s, a, d) of DAW G(w), if s′ = ζ(s) has an a-edge, say (s′ , a, d′ ), then ζ(d) = d′ . We go to prove that P (ζ) is a consistent partition. Let (I, a) ∈ P (ζ) × Σ such that Ia/w = ∅. In interval I, let s1 , s2 , . . . , sk be the DAWG states out of which there is an a-edge and |r(s1 )| > |r(s2 )| > . . . > |r(sk )|, the a-edges of these states be (s1 , a, d1 ), . . . , (sk , a, dk ). According to Lemma 3, we have di = di+1 if (si+1 , a, di+1 ) is secondary, otherwise f ail(di ) = di+1 , for 1 ≤ i ≤ k. In the latter case, (si+1 , a, di+1 ) is solid and si has an a-edge, therefore ζ(di+1 ) = di . Thus di , di+1 are in the same interval. That is either di , di+1 are in a same interval or di = di+1 . So Ia/w is in an interval. Therefore (I, a) is a consistent pair. Then we have that any pair (I, a) ∈ P (ζ)×Σ is consistent. P (ζ) is a consistent partition. For the converse side, suppose that P (ζ) is a consistent partition, and for an interval I in P (ζ), let state s ⊆ I, (s, a, d) be a solid edge out of s. Let s′ = ζ(s), suppose that s′ has an a-edge (s′ , a, d′ ). By Lemma 3, f ail(d′ ) = d. For P (ζ) is a consistent partition, d′ and d are in the same interval. We have ζ(d) = d′ . All work has been accounted for, and the theorem is proved. ⊓ ⊔ Fig. 3 gives an illustration of Theorem 1. By Theorem 1, we can construct a consistent partition from a DAWG. Consistent partitions can be generated by a depth-first traversal of the spanning tree [2] formed by the states and the solid edges of the DWAG. In the traversal, the electee child of the current visiting state is set only according to the

On the Structure of Consistent Partitions of Substring Set of a Word

333

electee child of its father in the spanning tree. Any consistent minimal linear partition can be built in this way. The WDWG for the consistent partition can be constructed by merging the edges from the DAWG states in each interval. If we extend the definition of the order function such that even if F s(s) = ∅, ζ(s) is allowed to be undefined. Then the resulting partitions of the extended order functions are not always minimal. But they can be consistent if their order functions satisfy the condition of Theorem 1. DAWG is an example of such consistent partitions whose extended order function is undefined for every state.

5

Lexicographic Linear Partition

In this section, we introduce a class of simple consistent partitions by Theorem 1. For each DAWG state s, define µ(s) the  first character of the shortest string in s. Define the set SonCharSet(s) = µ(r) | r ∈ F s(s) , and SonCharSet(s, a) = {µ(r) | r ∈ F s(s) and r has an a-edge}. According to the definition of SonCharSet, the following is immediate. Lemma 4. For any state s of DAW G(w), let (s, a, d) be a solid edge out of s, there is SonCharSet(d) = SonCharSet(s, a). Let ζ be an order function of DAW G(w). Define Selectζ (s) as follows: $  if ζ(s) is undefined; Selectζ (s) = µ ζ(s) otherwise.

Since the µ values of different states in F s(s) are different, ζ(s) can be known if Selectζ (s) is given. Definition 4. A lexicographic order function of DAW G(w) is an order function ℓ of DAW G(w) such that for any state s, Selectℓ (s) is the lexically smallest in SonCharSet(s) according to an arbitrary lexical order over Σ ∪ {$}, where $ is the maximal letter. P (ℓ) is a lexicographic linear partition of F act(w). For any state s of DAW G(w), let (s, a, d) be a solid edge out of s and let ℓ(s) have an a-edge (ℓ(s), a, d′ ). We have Selectℓ(s) ∈ SonCharSet(d). By Lemma 4, SonCharSet(d) ⊆ SonCharSet(s). So Selectℓ(s) is also the lexically smallest letter in SonCharSet(d). Then according  ℓ(d) =   to definition 4, Select Selectℓ(s). Let Selectℓ (s) = β. For ℓ(s) = βr(s) w , d′ = [βr(s)a]w = βr(d) w . Therefore, ℓ(d) = d′ . By Theorem 1, we have the following: Corollary 1. Any lexicographic linear partition of F act(w) is consistent. A consistent linear partition is not always a lexicographic linear partition. Building a lexicographic linear partition from a DAWG is fairly simple. The electee child of each state can be set independently according to a same lexicographic order. By slightly modifications of the algorithm in [17], the on-line construction of the linear lexicographic partitions can be derived, which is somewhat simpler than that of general consistent partitions.

334

6

M. Zhang et al.

Conclusions and Further Researches

We have revealed the structure of minimal consistent linear partitions in this paper. There are still many interesting issues, such as searching for the consistent orders that yield WDWGs with minimum number of edges. There is also relation between WDWGs and the factor oracles [1]. Despite the weight of edges, a WDWG is an automaton that can at least accept all the subwords of a word but is not always acyclic. The factor oracles are corresponding to a kind of partition of subwords of a word which is not necessarily linear. The latest research [6] has revealed some properties of these partitions. The result of this paper can be extended to be used in the building of the best oracles which accept the minimal language. There is also work to be done to reveal the factor oracles with the minimal space.

References 1. Allauzen, C., Crochemore, M., Raffinot, M.: Efficient Experimental String Matching by Weak Factor Recognition. In: Amir, A., Landau, G.M. (eds.) CPM 2001. LNCS, vol. 2089, pp. 51–72. Springer, Heidelberg (2001) 2. Blumer, A., Blumer, J., Haussler, D., Ehrenfeucht, A., Chen, M.T., Seiferas, J.: The smallest automation recognizing the subwords of a text. Theoretical Computer Science 40, 31–55 (1985) 3. Blumer, A., Blumer, J., Haussler, D., McConnell, R., Ehrenfeucht, A.: Complete inverted files for effcient text retrieval and analysis. Journal of the ACM 34(3), 578–595 (1987) 4. Crochemore, M.: Transducers and repetitions. Theoretical Computer Science 45, 63–86 (1986) 5. Crochemore, M., Czumaj, A., Gasieniec, L., Lecroq, T., Plandowski, W., Rytter, W.: Fast Practical Multi-Pattern Matching. Inf. Process. Lett. 71(3-4), 107–113 (1999) 6. Crochemore, M., Ilie, L., Seid-Hilmi, E.: The Structure of Factor Oracles. Int. J. Found. Comput. Sci 18(4), 781–797 (2007) 7. Charras, C., Lecroq, T.: Exact string matching algorithms (1997), http://www-igm.univ-mlv.fr/~ lecroq/string/ 8. Gusfield, D.: Algorithms on Strings Trees and Sequences. Cambridge UniversityPress, New York (1997) 9. Grossi, R., Vitter, J.: Compressed suffix arrays and suffix trees with applications to text indexing and string matching. In: Proceedings of the 32nd ACM Symposium on Theory of Computing (2000) 10. Inenaga, S., Shinohara, A., Takeda, M., Arikawa, S.: Compact Directed Acyclic Word Graphs for a Sliding Window. Journal of Discrete Algorithms 2(1), 33– 51 (2004); Laender, A.H.F., Oliveira, A.L. (eds.) SPIRE 2002. LNCS, vol. 2476. Springer, Heidelberg (2002) 11. Miyamoto, S., Inenaga, S., Takeda, M., Shinohara, A.: Ternary Directed Acyclic Word Graphs. Theoretical Compututer Science 328(1-2), 97–111 (2004); H. Ibarra, O., Dang, Z. (eds.) CIAA 2003. LNCS, vol. 2759, pp. 120–130. Springer, Heidelberg (2003)

On the Structure of Consistent Partitions of Substring Set of a Word

335

12. Manber, U., Myers, G.: Suffix arrays: A new method for on-line string searches. SIAM Journal on Computing 22, 935–948 (1993) 13. Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14, 249–260 (1995) 14. Weiner, P.: Linear pattern matching algorithm. In: Proceedings of the 14th Annual IEEE Symposium on Switching and Automata Theory, pp. 1–11 (1973) 15. Zhang, M., Ju, J.: Space-economical reassembly for intrusion detection system. In: Qing, S., Gollmann, D., Zhou, J. (eds.) ICICS 2003. LNCS, vol. 2836, pp. 393–404. Springer, Heidelberg (2003) 16. Zhang, M., Tang, J., Guo, D., Hu, L., Li, Q.: Succinct Text Indexes on Large Alphabet. In: Cai, J.-Y., Cooper, S.B., Li, A. (eds.) TAMC 2006. LNCS, vol. 3959, pp. 528–537. Springer, Heidelberg (2006) 17. Zhang, M., Hu, L., Li, Q., Ju, J.: Weighted Directed Word Graph. In: Apostolico, A., Crochemore, M., Park, K. (eds.) CPM 2005. LNCS, vol. 3537, pp. 156–167. Springer, Heidelberg (2005)

A Bit-Parallel Exact String Matching Algorithm for Small Alphabet Guomin Zhang1, En Zhu1, Ling Mao2, and Ming Yin3 1

School of Computer Science, National University of Defense Technology, Changsha 410073, China [email protected], [email protected] 2 School of Electronic Science and Engineering, National University of Defense Technology, Changsha 410073, China [email protected] 3 School of Software, Tsinghua University, Beijing 100084, China [email protected]

Abstract. This paper concentrates on the problem of finding all the occurrences of a pattern in a text. A novel bit-parallel exact string matching algorithm for small alphabet (SABP) is proposed based on a position related character matching table, which is deduced according to the matching matrix of the pattern and the text. A 2-base logarithm table consisting of 216 items is employed to locate the leftmost “1” bit of an unsigned integer flag, which indicates a latest probable occurrence of the pattern in the text. Safe shifts are obtained through combining the 2-base logarithm table value of current flag and the bad character shift which is adopted in Boyer-Moore algorithm. Our algorithm suits to the situation that the pattern length is more than the word size of a computer. Experimental results on random generated texts show that it is the fastest in many cases, particularly, on long patterns with a small alphabet. Keywords: String matching, bit-parallel, matching table, matching matrix.

1 Introduction String matching is a basic and crucial problem in many applications such as DNA analysis, network monitoring, information retrieval, etc. It consists in finding one or more usually all the occurrences of a pattern x=x[0..m-1] of length m in a text y=y[0..n-1] of length n, where the symbols of x and y are taken from some finite alphabet Σ of size σ. Apparently, there are at most n-m+1 candidate occurrences. Given strings u, v, and z, we say that u is a prefix of uv, a suffix of vu, and a factor of vuz. And we label the memory-word size of the machine as w. Applications require two kinds of solution depending on which string, x or y, is given first. We are interested here in the problem where x is given first. In that case, a preprocessing phase is allowed on x, which has been studied extensively. And aiming to sweep candidate occurrences as many as possible with fewer costs by utilizing the information of x and inspected text characters in y, numerous techniques and X. Deng, J.E. Hopcroft, and J. Xue (Eds.): FAW 2009, LNCS 5598, pp. 336–345, 2009. © Springer-Verlag Berlin Heidelberg 2009

A Bit-Parallel Exact String Matching Algorithm for Small Alphabet

337

algorithms were invented [1] by finding different solutions of what and how known information could be utilized. With a preprocessing phase, we can obtain information from x and Σ without y, which includes prefixes, suffixes, factors, the order of character codes, and other derivative information such as hashing functions, and the matching table of x and Σ. Combined with the matched and mismatched information of inspected characters in y obtained in the searching phase, we can often confirm more than one candidate occurrences after inspecting a new character of y. Most of existing works are based on a sliding window with the size of m; where the longest matched prefix, the longest matched suffix, and the longest matched factors are often utilized. And in the searching phase, bit-parallel and hashing technique can usually be employed to accelerate the algorithm. Prefixes based methods often inspect characters from left to right in a sliding window y[i..i+m-1], i.e., from y[i] to y[i+m-1]. KMP algorithm [2] and its variations aim at finding a mechanism to effectively compute the longest suffix of the text read that is also a prefix of x, preferably in amortized constant time per character. These algorithms achieve linear computational complexity even on the worst cases, but need to inspect each character of y. Thus they are not efficient in average running time. Baeza-Yates R and H.Gonnet G. (1992) [3] employ bit-parallel technique to maintain a set of all the prefixes of x that are also suffixes of the text read, and update the set at each character read. It is called Shift-Or algorithm, which is efficient in practice for small x on very small alphabet size. And it is easily adapted to approximate string matching problems. Suffix based methods inspect characters in y[i..i+m-1] from right to left, i.e., from y[i+m-1] down to y[i]. And the main difficulty in these methods is to shift the window in a safe way, which means without missing an occurrence of the pattern. BM algorithm [4] computes three shift functions beforehand to solve the problem, which is the first one with sublinear average computational complexity. Based on BM algorithm, many practical string matching algorithms have been invented [1], e.g., its Horspool simplification [5] becomes more and more difficult to beat in practice as the alphabet grows. Factor based methods recognize the set of factors of x, and leads to optimal average-case algorithms assuming that the characters of the text are independent and occur with the same probability for the reason that more known information have been utilized. In fact, prefixes and suffixes are all special factors. However, to recognize the set of factors of x is a difficult job. Backward Dawg Matching (BDM) algorithm [6] uses a suffix automaton, which is a powerful but complex structure. And bit-parallel technique is employed to implement the suffix automaton when x is short enough (less than w) in Backward Nondeterministic Dawg Matching (BNDM) algorithm [7]. Recently, Ďurian, B. etc.(2009) [8] proposed BNDM series algorithms (BNDM4b, SBNDM4b, etc.) which read a q-gram before testing the state variable at each alignment and are very efficient when the pattern is no longer than the computer word size. For a longer pattern, suffix automaton can be replaced by a simpler structure called factor oracle in Backward Oracle Matching (BOM) [9] algorithm, and the same experimental times are achieved as BDM. These algorithms were improved by Simone Faro and Thierry Lecroq (2008) [10] through fast loop and sentinel techniques.

338

G. Zhang et al.

Hashing [11] is another simple method which inspect characters from left to right remembering known information as hashing function values and computing the hashing function of y[i+1..i+m] by y[i+m] and the hashing function of y[i..i+m-1]. And q-gram hashing based algorithm [12] achieves the fastest results on many cases with small size alphabets by hashing substrings of length q. When the size of x is less than w and the alphabet size σ is relatively small, bitparallel technique can preserve known information far more than prefixes, suffixes, and factors. And since the Shift-Or algorithm [3] was proposed, various methods [7, 13-15] have been invented with different approaches to utilize these bit-parallel information. Unfortunately, the performance of these algorithms degrades when the input pattern length exceeds the computer word size. Külekci, M.O. and TÜBİTAKUEKAE (2008) [16] proposed a bit-parallel length invariant matcher (BLIM) without this default through pre-calculating a position related character matching table. In this paper, we follow these steps and proposed a bit-parallel exact string matching algorithm for small alphabet (SABP) without the pattern length limit by the computer word size. We pre-calculate a position related character matching table with the size of max(m,w), which produce the information of all the inspected characters of y within the sliding window through a simple AND bit-operation. Based on the 16 ⎣⎢log 2 d ⎦⎥ indexing table with a size of 2 , we locate the leftmost 1-value bit efficiently, which indicates a probable occurrence. Experimental results show that the new algorithm is the fastest on many cases, in particular, on small size alphabets. The rest of this paper is organized as follows. Section 2 analyzes the string matching problem according to the matching matrix of x and y. Section 3 is the description of the new algorithm. Section 4 analyzes our algorithm in detail. Section 5 is the experimental results compared with recent works. Section 6 draws the conclusion.

2 Problem Analysis with Matching Matrix We define the matching matrix of x and y by equation (1):

×

x [i ] ≠ y[ j ] ⎪⎧0 . M [i ][ j ] = ⎨ x i y j 1 [ ] or y[ j ] is unknown = [ ] ⎪⎩

(1)

M is an m n matrix, which stores all the character inspection results. Table 1 is an example of matching matrix; where Σ={A,C,G,T}, x[0..7]=GCAGAGAG, y[0..23]=GCATCGCAGAGAGTATACAGTACG, and there is an occurrence of pattern x[0..7]=y[5..12]. Apparently, x[0..m-1]=y[i..i+m-1] iff AND ( M [ k ][i + k ]) = 1 ; where AND is bit-and 0≤ k < m

operation. Thus if there is a k (0≤k