Table Of ContentTexts in Computer Science
K. Erciyes
Guide
to Graph
Algorithms
Sequential, Parallel and Distributed
Texts in Computer Science
Series editors
David Gries, Dept of Computer Science, Cornell University, Ithaca, New York,
USA
Orit Hazzan, Faculty of Education in Technology and Science, Technion—Israel
Institute of Technology, Haifa, Israel
Fred B. Schneider, Dept of Computer Science, Cornell University, Ithaca,
New York, USA
More information about this series at http://www.springer.com/series/3191
K. Erciyes
Guide to Graph
Algorithms
Sequential, Parallel and Distributed
123
K. Erciyes
International Computer Institute
Ege University
Izmir
Turkey
ISSN 1868-0941 ISSN 1868-095X (electronic)
Texts in Computer Science
ISBN 978-3-319-73234-3 ISBN 978-3-319-73235-0 (eBook)
https://doi.org/10.1007/978-3-319-73235-0
Library of Congress Control Number: 2017962034
© Springer International Publishing AG, part of Springer Nature 2018
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publi-
cation does not imply, even in the absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, express or implied, with respect to the material contained herein or
for any errors or omissions that may have been made. The publisher remains neutral with regard to
jurisdictional claims in published maps and institutional affiliations.
Printed on acid-free paper
This Springer imprint is published by the registered company Springer International Publishing AG
part of Springer Nature
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
To the memories of Semra, Seyhun, Şebnem
and Hakan
Preface
Graphs are key data structures for the analysis of various types of networks such as
mobile ad hoc networks, the Internet, and complex networks such as social net-
works and biological networks. Study of graph algorithms is needed to efficiently
solve a variety of problems in such networks. This study is commonly centered
around three fundamental paradigms: Sequential graph algorithms; parallel graph
algorithms and distributed graph algorithms. Sequential algorithms in general
assume a single flow of control and such methods are well established. For
intractable graph problems that do not have sequential solutions in polynomial time,
approximation algorithms which have proven approximation ratios to the optimum
solutions can be used. Many times however, the approximation algorithms are not
known to date and the only choice is the use of heuristics which are common sense
rules that are shown experimentally to work for a wide range of inputs. The
algorithm designer is frequently confronted with this task of knowing what to
search or not; and what road to follow if the solution does not exist. The first aim of
this book is to provide a comprehensive and in-depth analysis of sequential graph
algorithms and guide the designer on how to approach a typical hard problem by
showing how to inspect an appropriate heuristic which is commonly needed in
many cases.
Parallel algorithms are needed to provide speed-up in the running of graph
algorithms. Shared memory parallel algorithms synchronize using a common
memory and distributed memory parallel algorithms communicate by
message-passing only. Distributed graph (or network) algorithms are aware of
network topology and can be used for various network related tasks such as routing.
Distributed algorithms is the common term used for distributed memory and dis-
tributed graph algorithms, however, we will call shared memory and distributed
memory parallel graph algorithms parallel graph algorithms and distributed graph
or network algorithms as distributed algorithms. Design and analysis of parallel and
distributed algorithms as well as sequential algorithms for graphs will be the subject
of this book.
A second and a fundamental goal of this book is to unify these three seemingly
different methods of graph algorithms where applicable. For example, the minimum
spanning tree (MST) problem can be solved by four classical sequential algorithms:
Boruvka’s, Prim’s, Kruskal’s, and Reverse-Delete algorithms all with similar
vii
viii Preface
complexities. A parallel MST algorithm will attempt to find the MST of a large
network on a fewer number of processors solely to obtain a speedup. In a dis-
tributed MST algorithm, each processor is a node of the network graph and par-
ticipates to find the MST of the network. We will describe and compare all three
paradigms for this and many other well-known graph problems by looking at the
same problem from three different angles, which we believe will help to understand
the problem better and form a unifying view.
A third and an important goal of this work will be the conversions between
sequential, shared, and distributed memory parallel and distributed algorithms for
graphs. This process is not commonly implemented in literature although there are
opportunities in many cases. We will exemplify this concept by maximal weighted
matching algorithm in graphs. The sequential approximation algorithm for this
purpose with 0.5 ratio has a time complexity of OðmlogðmÞÞ with m being the
number of edges. Preis provided a faster localized sequential algorithm based on the
first algorithm with better OðmÞ complexity. Later, Hoepmann provided a dis-
tributed version of Preis’ algorithm. More recently, Manne provided sequential
form of Hoepman’s distributed graph algorithm and parallelized this algorithm. The
sequence of methods employed has been sequential ! sequential ! distributed !
sequential ! parallel for this graph problem. Although this example shows a rather
long transformation sequence, sequential ! parallel and sequential ! distributed
are commonly followed by researchers mostly by common sense. Parallel graph
algorithms $ distributed graph algorithms conversion of algorithms is very seldom
practiced. Our aim will be to lay down the foundations of these transformations
between paradigms to convert an algorithm in one domain to another. This may be
difficult for some types of algorithms but graph algorithms are a good premise.
As more advanced technologies are developed, we are confronted with the
analysis of big data of complex networks which have tens of thousands of nodes
and hundreds of thousands of edges. We also provide a part on algorithms for big
data analysis of complex networks such as the Internet, social networks, and bio-
logical networks in the cell. To summarize, we have the following goals in this
book:
• A comprehensive study and a detailed study of fundamental principles of
sequential graph algorithms and approaches for NP-hard problems, approxi-
mation algorithms and heuristics.
• A comparative analysis of sequential, parallel and distributed graph algorithms
including algorithms for big data.
• Study of conversion principles between the three methods.
There are three parts in the book; we provide a brief background on graphs,
sequential, parallel, and distributed graph algorithms in the first part. The second
part forms the core of the book with a detailed analysis of sequential, parallel, and
distributed algorithms for fundamental graph problems. In the last part, our focus is
on algebraic and dynamic graph algorithms and graph algorithms for very large
networks, which are commonly implemented using heuristics rather than exact
solutions.
Preface ix
We review theory as much as needed for the design of sequential, parallel, and
distributed graph algorithms and our emphasis for many problems is on imple-
mentation details in full. Our study of sequential graph algorithms throughout the
book is comprehensive, however, we provide a comparative analysis of sequential
algorithms only with the fundamental parallel and distributed graph algorithms. We
kept the layout of each chapter as homogenous as possible by first describing the
problem informally and then providing the basic theoretical background. We then
describe fundamental algorithms by first describing the main idea of an algorithm;
then giving its pseudocode; showing an example implementation and finally the
analysis of its correctness and complexities. This algorithm template is repeated for
all algorithms except the ones that have complex structures and phases in which
case we describe the general idea and the operation of the algorithm.
The intended audience for this book is the senior/graduate students of computer
science, electrical and electronic engineering, bioinformatics, and any researcher or
a person with background in discrete mathematics, basic graph theory and algo-
rithms. There is a Web page for the book to keep errata and other material at: http://
ube.ege.edu.tr/*erciyes/GGA/.
I would like to thank senior/graduate students at Ege University, University of
California Davis, California State University San Marcos, and senior/graduate
students at Izmir University who have taken the distributed algorithms and complex
networks courses, sometimes under slightly different names, for their valuable
feedback when parts of the material covered in the book was presented during
lectures. I would also like to thank Springer editors Wayne Wheeler and Simon
Rees for their help and their faith in another book project I have proposed.
Izmir, Turkey K. Erciyes
An emeritus professor
International Computer Institute
Ege (Aegean) University
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Graph Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Sequential Graph Algorithms. . . . . . . . . . . . . . . . . . . . . 2
1.2.2 Parallel Graph Algorithms . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3 Distributed Graph Algorithms . . . . . . . . . . . . . . . . . . . . 5
1.2.4 Algorithms for Large Graphs. . . . . . . . . . . . . . . . . . . . . 7
1.3 Challenges in Graph Algorithms. . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Outline of the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Part I Fundamentals
2 Introduction to Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Notations and Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.1 Vertex Degrees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.2 Subgraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.3 Isomorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.3 Graph Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.1 Union and Intersection . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.2 Cartesian Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.4 Types of Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.1 Complete Graphs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.2 Directed Graphs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.4.3 Weighted Graphs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.4.4 Bipartite Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.4.5 Regular Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4.6 Line Graphs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.5 Walks, Paths, and Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.5.1 Connectivity and Distance . . . . . . . . . . . . . . . . . . . . . . . 29
2.6 Graph Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.6.1 Adjacency Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.6.2 Adjacency List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.6.3 Incidence Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
xi