Institute of Operating Systems and Computer Networks Algorithms Group. Network Algorithms. Tutorial 1: Flashback and Fast Forward

Similar documents
Introduction to Graph Theory

Institute of Operating Systems and Computer Networks Algorithms Group. Network Algorithms. Tutorial 4: Matching and other stuff

Data Structure. IBPS SO (IT- Officer) Exam 2017

Design and Analysis of Algorithms

implementing the breadth-first search algorithm implementing the depth-first search algorithm

Graphs and Algorithms 2016

Chapter 9 Graph Algorithms

val(y, I) α (9.0.2) α (9.0.3)

Let G = (V, E) be a graph. If u, v V, then u is adjacent to v if {u, v} E. We also use the notation u v to denote that u is adjacent to v.

Chapter 9 Graph Algorithms

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

Chapter 9 Graph Algorithms

r=1 The Binomial Theorem. 4 MA095/98G Revision

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Lecture 3: Graphs and flows

Some major graph problems

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design

CMPSCI611: The SUBSET-SUM Problem Lecture 18

1 Variations of the Traveling Salesman Problem

COMP Analysis of Algorithms & Data Structures

Mathematics and Statistics, Part A: Graph Theory Problem Sheet 1, lectures 1-4

Solving problems on graph algorithms

I A graph is a mathematical structure consisting of a set of. I Formally: G =(V, E), where V is a set and E V V.

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn

Graphs and Network Flows IE411. Lecture 13. Dr. Ted Ralphs

DESIGN AND ANALYSIS OF ALGORITHMS

PATH FINDING AND GRAPH TRAVERSAL

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science.

Fundamental Algorithms

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

CS2 Algorithms and Data Structures Note 9

Inf 2B: Graphs, BFS, DFS

EECS 203 Lecture 20. More Graphs

Lecture 26: Graphs: Traversal (Part 1)

APPROXIMATION ALGORITHMS FOR GEOMETRIC PROBLEMS

Introduction to Algorithms Third Edition

Graph Algorithms Using Depth First Search

V1.0: Seth Gilbert, V1.1: Steven Halim August 30, Abstract. d(e), and we assume that the distance function is non-negative (i.e., d(x, y) 0).

CMPSCI 311: Introduction to Algorithms Practice Final Exam

Graphs and Algorithms 2015

Instant Insanity Instructor s Guide Make-it and Take-it Kit for AMTNYS 2006

I want an Oompa-Loompa! screamed Veruca. Roald Dahl, Charlie and the Chocolate Factory

Search Algorithms. IE 496 Lecture 17

Practice Final Exam 1

LECTURES 3 and 4: Flows and Matchings

Matching Theory. Figure 1: Is this graph bipartite?

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs:

Math 776 Graph Theory Lecture Note 1 Basic concepts

Lecture 8: The Traveling Salesman Problem

12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees

Polynomial time approximation algorithms

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

Chapter 4. Relations & Graphs. 4.1 Relations. Exercises For each of the relations specified below:

Approximation Algorithms

GRAPHS Lecture 19 CS2110 Spring 2013

CSE 21 Spring 2016 Homework 5. Instructions

GRAPHS: THEORY AND ALGORITHMS

CS 4407 Algorithms. Lecture 8: Circumventing Intractability, using Approximation and other Techniques

6.856 Randomized Algorithms

(Refer Slide Time: 01:00)

Graph and Digraph Glossary

Theorem 2.9: nearest addition algorithm

Reference Sheet for CO142.2 Discrete Mathematics II

csci 210: Data Structures Graph Traversals

Information Science 2

Computational Optimization ISE 407. Lecture 19. Dr. Ted Ralphs

Lecture 24: More Reductions (1997) Steven Skiena. skiena

4. (a) Draw the Petersen graph. (b) Use Kuratowski s teorem to prove that the Petersen graph is non-planar.

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

- Logic and Algorithms - Graph Algorithms

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

INSTITUTE OF AERONAUTICAL ENGINEERING

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018

PSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V

12 Abstract Data Types

Course Review. Cpt S 223 Fall 2009

Announcements. CSEP 521 Applied Algorithms. Announcements. Polynomial time efficiency. Definitions of efficiency 1/14/2013

Algorithms for Euclidean TSP

Coping with NP-Completeness

Lecture 8: PATHS, CYCLES AND CONNECTEDNESS

Chapter 3: Paths and Cycles

Solutions for the Exam 6 January 2014

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Virtual University of Pakistan

Notes for Lecture 24

(Re)Introduction to Graphs and Some Algorithms

Outline. Graphs. Divide and Conquer.

Proposition 1. The edges of an even graph can be split (partitioned) into cycles, no two of which have an edge in common.

lecture27: Graph Traversals

Homework 3 Solutions

Branch and Bound. Live-node: A node that has not been expanded. It is similar to backtracking technique but uses BFS-like search.

Matching 4/21/2016. Bipartite Matching. 3330: Algorithms. First Try. Maximum Matching. Key Questions. Existence of Perfect Matching

Graphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs

Lecture Notes for IEOR 266: Graph Algorithms and Network Flows

CS 310 Advanced Data Structures and Algorithms

Transcription:

Institute of Operating Systems and Computer Networks Algorithms Group Network Algorithms Tutorial 1: Flashback and Fast Forward Christian Rieck

Staff Lecture: Dr. Christian Scheffer scheffer@ibr.cs.tu-bs.de Room: IZ 331 Tutorial: Christian Rieck rieck@ibr.cs.tu-bs.de Room: IZ 314 Small tutorial: Jakob Keller jakob.keller@tu-braunschweig.de 2

Structure Lecture: theoretical content on graph algorithms Tutorial: application of graph algorithms and many more cool stuff on graphs and problems on graphs Small tutorial: discussion of homework sheets 3

Homework and exam There will be five homework assignment sheets. You have to get at least 50% of the points in total. (Probably 150 out of 300.) You have to pass a written exam at the end of the lecture August, 6th. (Probably at 12am.) 4

Extra points You can earn extra points for your homework! find a (crucial) mistake in the slides improve the tutorial by a better example improve the tutorial by ideas on new interesting stuff Please send an email or talk to me and I will think about it. Usually the amount of extra points is in some way related to the improvement and is a fraction of my room number π. 5

Mailing list There is a mailing list for this lecture. https://mail.ibr.cs.tu-bs.de/mailman/listinfo/na We will distribute several announcements via this list. So, please subscribe. 6

Webpage There is a webpage for this lecture. https://www.ibr.cs.tu-bs.de/courses/ss18/na/index.html There is all the stuff like the slides of the tutorials, the homework assignment sheets, the schedule of the lecture, informations regarding the exam, 7

(preliminary) Schedule 8

(preliminary) Schedule There is also a calendar on the webpage which will be up-to-date! 8

Questions? 9

Previously in * 10

Graphs A graph is an ordered pair G=(V,E) comprising a set V of vertices together with a set E of edges, which are 2-element subsets of V. We normally consider simple graphs, i.e., there is at most one edge between two specific vertices and there are no edges connecting a vertex with itself. 11

Digraphs A digraph is an ordered pair D=(V,A) comprising a set V of vertices together with a set A of arcs (edges), which are ordered pairs of vertices. 12

Data structures for graphs There are several ways to represent graphs, e.g., adjacency list adjacency matrix incidence matrix Please make yourself familiar with these data structures. A good reference is the lecture on algorithms and data structures. https://www.ibr.cs.tu-bs.de/courses/ws1718/aud/webpages/skript/vl7_new.pdf https://www.ibr.cs.tu-bs.de/courses/ws1718/aud/webpages/skript/vl8_new.pdf 13

Other data structures Stack last in, first out (LIFO) push pop Queue first in, first out (FIFO) enqueue dequeue 14

Breadth-First-Search procedure BFS(G,v) let Q be a queue Q.enqueue(v) while Q is not empty v = Q.dequeue() for each edge e incident to v let w be the other endpoint of e if w is not marked mark w Q.enqueue(w) v 0 v 0 v 1 v 2 v 3 v 4 v 1 v 2 v 3 v 5 v 6 v 7 v 8 v 5 v 6 v 7 v 10 v 9 v 10 v 9 v 11 v 12 v 11 v 4 v 8 v 12 15

Depth-First-Search procedure DFS(G,v) let S be a stack S.push(v) while S is not empty v = S.pop() if v is not labeled as discovered label v as discovered for all edges from v to w S.push(w) v 0 v 0 v 1 v 2 v 3 v 4 v 1 v 2 v 3 v 5 v 6 v 7 v 8 v 5 v 10 v 9 v 10 v 11 v 12 v 11 v 6 v 7 v 9 v 4 v 8 v 12 16

Walk, path, trail, Kantenfolge: Weg: Pfad: Tour: Kreis: Alternating sequence of vertices and edges. Kantenfolge + no repeating edges Kantenfolge + no repeating vertices Weg + same start and end vertex Pfad + same start and end vertex 17

Big O-Notation describes the limiting behavior of a function when the argument tends towards infinity is used to classify algorithms according to their running time (and other stuff ) O( f )={g : N! R + 9c 2 R >0 9n 0 2 N 8n 2 N n0 : g(n) apple c f (n)} g(n) 2 O( f (n)) f (n) g(n) n 0 18

Other Landau symbols There are some other notations for analyzing the running time and space requirements of algorithms, e.g., big-omega, Theta, Please make yourself familiar with these notations. Lecture on algorithms and data structures: Theta Lecture on algorithms and data structures: Big-O and Big-Omega 19

Proofs Well Sometimes it is very challenging to prove something. There are different methods, e.g., induction, or contraposition. Not only in this class you have to prove mathematical statements. Therefore you should be familiar with these methods and techniques https://www.ibr.cs.tu-bs.de/courses/ws1718/aud/uebungen/u2.pdf https://www.ibr.cs.tu-bs.de/courses/ws1718/aud/uebungen/merkzettel-beweise.pdf 20

Proofs Well Sometimes it is very challenging to prove something. There are different methods, e.g., induction, or contraposition. Not only in this class you have to prove mathematical statements. Therefore you should be familiar with these methods and techniques https://www.ibr.cs.tu-bs.de/courses/ws1718/aud/uebungen/u2.pdf https://www.ibr.cs.tu-bs.de/courses/ws1718/aud/uebungen/merkzettel-beweise.pdf 20

Different issues Eulerian Tour this is a problem! Given: A graph G Wanted: A tour that visits every edge exactly once Fleury s algorithm! Given: this is a specific instance! Wanted: A tour that visits every edge exactly once specific solution! 21

Different issues Hamiltonian Circle Given: A graph G Wanted: A circle that visits every vertex exactly once Traveling Salesman Tour Given: A weighted graph G Wanted: A circle of minimum total weight that visits every vertex exactly once Decision problem Given: A graph ( ) Wanted: A specific structure or an argument that such a structure do not exist in that graph Optimization problem Given: A graph ( ) and edge weights Wanted: From all feasible specific structures the best or an argument that such a structure do not exist in that graph 22

Soon in network algorithms 23

Minimum-cost problems Minimum Spanning Tree Given: A graph G=(V,E) with edge weights Wanted: A tree T of minimum cost that spans the graph 5 1 5 9 3 7 8 3 4 2 1 2 7 6 11 5 6 5 1 3 7 3 4 2 1 2 7 6 5 G T 24

Minimum-cost problems Minimum Spanning Tree Given: A graph G=(V,E) with edge weights A geometric generalization is the Minimum Steiner Tree Problem. Wanted: A tree T of minimum cost that spans the graph One can also ask for a spanning tree where the longest edge is as short as possible the Minimum Bottleneck Spanning Tree! 7 5 1 5 8 7 6 7 Or we want a minimum spanning tree where each vertex degree 7 6 is bounded by some value (Bounded Degree 5 Spanning Tree), 11 1 3 or satisfies some other constraints. 3 9 2 6 2 4 4 Some 3 of them 3 2 1 are really hard, e.g., most Steiner problems. 5 2 1 5 G T 24

Shortest-path problems Single source shortest paths Given: A graph G=(V,E) with edge weights, and a vertex s Wanted: A shortest path tree T rooted in s 5 1 5 9 3 7 8 3 4 2 1 2 7 6 11 5 6 s 5 1 9 3 7 3 2 1 2 7 5 6 G T 25

Shortest-path problems Single source shortest paths Given: A graph G=(V,E) with edge weights, and a vertex s Wanted: A shortest path tree T rooted in s There are many 7 related problems, 7 7 5 1 5 8 7 6 e.g., Longest Path, Hamiltonian Path, several tour problems like the Traveling Salesman Problem, 5 11 1 3 Almost all of them are NP-hard! 3 9 2 6 s 9 2 6 4 3 3 2 1 2 1 5 5 G T 25

Flows Maximum Flow Given: A digraph D=(V,A) with edge weights, and vertices s and t Wanted: A maximum flow F starting from s to t 7 5 5 1 9 3 2 8 3 4 1 2 7 6 11 5 6 s 5 7 5 5 5 1 9 9 3 2 26 8 5 7 2 33 11 11 22 1 4 1 1 1 5 t 6 1 D F 26

Flows Maximum Flow Given: A digraph D=(V,A) with edge weights, and vertices s and t Wanted: A maximum flow F starting from s to t A fundamental theorem is the MaxFlow-MinCut-Theorem of Ford and Fulkerson that shows that a maximum flow is equal to 7 a minimum 6 cut of a flow network. 5 7 26 5 5 8 7 1 5 5 8 5 7 2 t 5 There are polynomial-time 1 3 11algorithms for solving such flow 9 2 6 33 11 problems. 11 But there are many related problems, and s 9some 9 of them are 2 6 2 NP-hard. 1 3 4 3 1 4 2 1 1 5 2 1 1 5 D F 26

Matchings Maximum Matching Given: A graph G=(V,E) Wanted: A maximum set M of pairwise non-adjacent edges G M 27

Matchings Maximum Matching Given: A graph G=(V,E) Wanted: A maximum set M of pairwise non-adjacent edges There are many different variants of the matching problem, e.g., Perfect Matching, Minimum Cost Perfect Matching, Maximal Matching, Matching in bipartite Graphs, G M 27

Questions? 28