Algorithms in C, Part 5 Graph Algorithms

Why Rent from Knetbooks?

Because Knetbooks knows college students. Our rental program is designed to save you time and money. Whether you need a textbook for a semester, quarter or even a summer session, we have an option for you. Simply select a rental period, enter your information and your book will be on its way!

Once again, Robert Sedgewick provides a current and comprehensive introduction to important algorithms. The focus this time is on graph algorithms, which are increasingly critical for a wide range of applications, such as network connectivity, circuit design, scheduling, transaction processing, and resource allocation. In this book, Sedgewick offers the same successful blend of theory and practice with concise implementations that can be tested on real applications, which has made his work popular with programmers for many years. Algorithms in C, Third Edition, Part 5: Graph Algorithmsis the second book in Sedgewick's thoroughly revised and rewritten series. The first book, Parts 1-4, addresses fundamental algorithms, data structures, sorting, and searching. A forthcoming third book will focus on strings, geometry, and a range of advanced algorithms. Each book's expanded coverage features new algorithms and implementations, enhanced descriptions and diagrams, and a wealth of new exercises for polishing skills. A focus on abstract data types makes the programs more broadly useful and relevant for the modern object-oriented programming environment. Coverage includes: A complete overview of graph properties and types Diagraphs and DAGs Minimum spanning trees Shortest paths Network flows Diagrams, sample C code, and detailed algorithm descriptions The Web site for this book (http://www.cs.princeton.edu/~rs/) provides additional source code for programmers along with numerous support materials for educators. A landmark revision, Algorithms in C, Third Edition, Part 5provides a complete tool set for programmers to implement, debug, and use graph algorithms across a wide range of computer applications.

Robert Sedgewick is the William O. Baker Professor of Computer Science at Princeton University. He is a Director of Adobe Systems and has served on the research staffs at Xerox PARC, IDA, and INRIA. He earned his Ph.D from Stanford University under Donald E. Knuth.

0201316633AB06262002

Graph Algorithms

Graph Properties and Types

3

(72)

Glossary

7

(9)

Graph ADT

16

(5)

Adjacency-Matrix Representation

21

(6)

Adjacency-Lists Representation

27

(4)

Variations, Extensions, and Costs

31

(9)

Graph Generators

40

(10)

Simple, Euler, and Hamilton Paths

50

(14)

Graph-Processing Problems

64

(11)

Graph Search

75

(66)

Exploring a Maze

76

(5)

Depth-First Search

81

(5)

Graph-Search ADT Functions

86

(5)

Properties of DFS Forests

91

(8)

DFS Algorithms

99

(7)

Separability and Biconnectivity

106

(8)

Breadth-First Search

114

(10)

Generalized Graph Search

124

(9)

Analysis of Graph Algorithms

133

(8)

Digraphs and DAGs

141

(78)

Glossary and Rules of the Game

144

(8)

Anatomy of DFS in Digraphs

152

(9)

Reachability and Transitive Closure

161

(13)

Equivalence Relations and Partial Orders

174

(4)

DAGs

178

(5)

Topological Sorting

183

(10)

Reachability in DAGs

193

(3)

Strong Components in Digraphs

196

(12)

Transitive Closure Revisited

208

(4)

Perspective

212

(7)

Minimum Spanning Trees

219

(46)

Representations

222

(6)

Underlying Principles of MST Algorithms

228

(7)

Prim's Algorithm and Priority-First Search

235

(11)

Kruskal's Algorithm

246

(6)

Boruvka's Algorithm

252

(3)

Comparisons and Improvements

255

(6)

Euclidean MST

261

(4)

Shortest Paths

265

(88)

Underlying Principles

273

(7)

Dijkstra's algorithm

280

(10)

All-Pairs Shortest Paths

290

(10)

Shortest Paths in Acyclic Networks

300

(8)

Euclidean Networks

308

(6)

Reduction

314

(17)

Negative Weights

331

(19)

Perspective

350

(3)

Network Flows

353

(120)

Flow Networks

359

(11)

Augmenting-Path Maxflow Algorithms

370

(26)

Preflow-Push Maxflow Algorithms

396

(15)

Maxflow Reductions

411

(18)

Mincost Flows

429

(10)

Network Simplex Algorithm

439

(18)

Mincost-Flow Reductions

457

(10)

Perspective

467

(6)

References for Part Five

473

(2)

Index

475

Graphs and graph algorithms are pervasive in modern computing applications. This book describes the most important known methods for solving the graph-processing problems that arise in practice. Its primary aim is to make these methods and the basic principles behind them accessible to the growing number of people in need of knowing them. The material is developed from first principles, starting with basic information and working through classical methods up through modern techniques that are still under development. Carefully chosen examples, detailed figures, and complete implementations supplement thorough descriptions of algorithms and applications. Algorithms This book is the second of three volumes that are intended to survey the most important computer algorithms in use today. The first volume (Parts 1-4) covers fundamental concepts (Part 1), data structures (Part 2), sorting algorithms (Part 3), and searching algorithms (Part 4); this volume (Part 5) covers graphs and graph algorithms; and the (yet to be published) third volume (Parts 6-8) covers strings (Part 6), computational geometry (Part 7), and advanced algorithms and applications (Part 8). The books are useful as texts early in the computer science curriculum, after students have acquired basic programming skills and familiarity with computer systems, but before they have taken specialized courses in advanced areas of computer science or computer applications. The books also are useful for self-study or as a reference for people engaged in the development of computer systems or applications programs because they contain implementations of useful algorithms and detailed information on these algorithms' performance characteristics. The broad perspective taken makes the series an appropriate introduction to the field. Together the three volumes comprise theThird Editionof a book that has been widely used by students and programmers around the world for many years. I have completely rewritten the text for this edition, and I have added thousands of new exercises, hundreds of new figures, dozens of new programs, and detailed commentary on all the figures and programs. This new material provides both coverage of new topics and fuller explanations of many of the classic algorithms. A new emphasis on abstract data types throughout the books makes the programs more broadly useful and relevant in modern object-oriented programming environments. People who have read previous editions will find a wealth of new information throughout; all readers will find a wealth of pedagogical material that provides effective access to essential concepts. These books are not just for programmers and computer-science students. Nearly everyone who uses a computer wants it to run faster or to solve larger problems. The algorithms that we consider represent a body of knowledge developed during the last 50 years that has become indispensable in the efficient use of the computer for a broad variety of applications. From N-body simulation problems in physics to genetic-sequencing problems in molecular biology, the basic methods described here have become essential in scientific research; and from database systems to Internet search engines, they have become essential parts of modern software systems. As the scope of computer applications becomes more widespread, so grows the impact of basic algorithms, particularly the fundamental graph algorithms covered in this volume. The goal of this book is to serve as a resource so that students and professionals can know and make intelligent use of graph algorithms as the need arises in whatever computer application they might undertake. Scope This book,Algorithms in C, Third Edition, Part 5: Graph Algorithms,contains six chapters that cover graph properties and types, graph search, directed graphs, minimal spanning