ST: Introduction to Graph Algorithms This Class Website and Contact - - PowerPoint PPT Presentation

st introduction to graph algorithms this class website
SMART_READER_LITE
LIVE PREVIEW

ST: Introduction to Graph Algorithms This Class Website and Contact - - PowerPoint PPT Presentation

ST: Introduction to Graph Algorithms This Class Website and Contact Website www.cs.kent.edu/ aleitert/iga/ Important information Slides (maybe ;) Announcements Email aleitert@cs.kent.edu Office hours Monday and


slide-1
SLIDE 1

ST: Introduction to Graph Algorithms

slide-2
SLIDE 2

This Class

slide-3
SLIDE 3

Website and Contact

Website

◮ www.cs.kent.edu/∼aleitert/iga/ ◮ Important information ◮ Slides (maybe ;) ◮ Announcements

Email

◮ aleitert@cs.kent.edu

Office hours

◮ Monday and Wednesday, 1.00 – 2.00 p.m.

Room 352, Math and CS Building

◮ Or appointment via email

3 / 26

slide-4
SLIDE 4

Requirements

Completely new class from scratch!

◮ Experimental. ◮ No textbook. ◮ Feedback is highly appreciated.

Requirements

◮ Quizzes

50 %

◮ Project

50 %

4 / 26

slide-5
SLIDE 5

Quizzes

Questions

◮ 5 questions, each 20 % ◮ Mostly given in advance ◮ Usual case: Given a graph, run a certain algorithm on it.

Dates (may change)

◮ March 2.

during class

◮ April 6.

during class

◮ May 10.

Wednesday, 12:45 – 3:00 p. m. (“Final”)

5 / 26

slide-6
SLIDE 6

Project

Selection

◮ Pick 1 out of 4. ◮ 2 theory, 2 coding projects (more details next week)

Groups

◮ Up to 4 students per group. (Some exceptions are allowed) ◮ One grade for the whole group. ◮ I don’t care about your group drama. ◮ Report groups until Feb 3.

6 / 26

slide-7
SLIDE 7

Project-Reports

Report progress during the semester

◮ 2 small reports

Feb 24. and Apr 6.

◮ 1 larger reports

Mar 16. Small Reports (1 or 2 sentences per question)

◮ What have you done so far? ◮ What do you plan to do next? ◮ Any blockers?

Larger Report (≈ 1 page)

◮ What is the status of your project? ◮ What is you approach for solving it?

7 / 26

slide-8
SLIDE 8

Alternative to Project

Give a presentation

◮ ≥ 20 minutes ◮ 1 or 2 students per talk ◮ Only if you can convince me in advance that you give a good

presentation! Topic ideas

◮ Shortest path beyond Dijkstra ◮ RT + Walker algorithms for drawing trees ◮ Reconfiguration problems ◮ Dominating Set and variants

8 / 26

slide-9
SLIDE 9

Not in this Class but Useful to Know

slide-10
SLIDE 10

Array Based Lists

Add(e) (amortised) O(1)

◮ Adds an element e to the end.

AddAt(e, i ) O(n)

◮ Adds an element e at index i. Other elements are shifted.

Get(i ) / Set(i, e) O(1)

◮ Reads or overrides the element at index i.

Find(e) O(n)

◮ Finds the first element equal to e.

10 / 26

slide-11
SLIDE 11

Trees

11 / 26

slide-12
SLIDE 12

Priority Queues

Enqueue O(log n)

◮ Adds an element to the queue.

Dequeue O(log n)

◮ Removes the smallest element in the queue.

Min O(1)

◮ Return the smallest element in the queue without removing it.

5 2 4 1 3 Enqueue Dequeue Min

12 / 26

slide-13
SLIDE 13

Sorting

Array based

◮ In O(n log n) time. ◮ Requires O(log n) additional space. ◮ Not stable.

5 2a 4 6a 3 1 6b 2b Input 1 2b 2a 3 4 5 6a 6b Output

13 / 26

slide-14
SLIDE 14

Hash Tables

Insert(k, v) O(1)

◮ Inserts a key-value pair (k, v).

Delete(k) O(1)

◮ Deletes a value with the given key k.

Find(k) O(1)

◮ Finds a value with the given key k.

Note: Elements cannot be sorted within the table.

14 / 26

slide-15
SLIDE 15

Graphs

slide-16
SLIDE 16

Graph

Graph A graph G = (V, E) is a set V of vertices connected by an edge set E.

16 / 26

slide-17
SLIDE 17

Variations

Multi-Graph: Multiple edges between two vertices. Directed: Edges have a direction. Weighted: Vertices and/or edges have weights. Simple: No multiple edges, no loops. Simple Undirected Graph A simple undirected graph G = (V, E) is a set V of vertices connected by an edge set E ⊆

  • {u, v} | u, v ∈ V, u = v
  • . An edge {u, v} is also

written as uv. (More definitions later.)

17 / 26

slide-18
SLIDE 18

Implementation: Adjacency List

For each vertex, there is an array storing pointers† to all neighbours.

1 2 3 4 5 G 1 2 3 4 5 1 3 4 2 5 1 3 2 4 3 5 1 4

† Usually, the vertex index is sufficient.

18 / 26

slide-19
SLIDE 19

Example Problem

slide-20
SLIDE 20

Example Problem

Let G = (V, E, ω) be an undirected weighted graph and let A ⊂ V be a non-empty proper subset of V (i. e., A = V). The separation sep(A) is defined as sep(A) = min{ ω(ab) | a ∈ A, b ∈ V \ A}. Given a graph G, find a subset A with maximum possible separation.

20 / 26

slide-21
SLIDE 21

Understanding the Problem

Separation Let A ⊂ V be a non-empty. The separation sep(A) is defined as sep(A) = min{ ω(a, b) | a ∈ A, b ∈ V \ A}.

3 7 5 G A

Problem: Find the set A for which sep(A) is maximal.

21 / 26

slide-22
SLIDE 22

Finding a First Solution

Naive approach

◮ Test all subsets A ◮ Problem: Too many subsets.

Observation

◮ A solution is defined by an edge.

22 / 26

slide-23
SLIDE 23

Finding a First Solution

Better approach

◮ For each edge e, check if there is a set A with sep(A) = ω(e). ◮ How do we check this?

Observation

◮ If sep(A) = ω(e), then, for each edge uv with ω(uv) < ω(e), u ∈ A if

and only if v ∈ A, i. e., both are in A or bot are not in A. Lemma There is a set A with sep(A) = ω(uv) if and only if there is no path from u to v where each edge has a lower weight than uv.

23 / 26

slide-24
SLIDE 24

Finding a First Solution

Algorithm idea

◮ For each edge uv, check if there is path from u to v only using edges

with less weight than uv.

◮ If there is no such path, store uv as potential solution. ◮ Out of all these edges uv, pick the one with the largest weight.

Runtime

◮ O(|E|2)

This is an acceptable solution. However, can we do better?

24 / 26

slide-25
SLIDE 25

Improve a Solution

A defines a partition of the graph and sep(A) is represented by the smallest edge connecting bots sets. What else do we know about this edge?

25 / 26

slide-26
SLIDE 26

Improve a Solution

A defines a partition of the graph and sep(A) is represented by the smallest edge connecting bots sets. What else do we know about this edge? Lemma If e is in { ab | a ∈ A, b ∈ V \ A} and ω(e) = sep(A), then there is a minimum spanning tree containing e. This gives us a new algorithm:

◮ Compute a minimum spanning tree T. ◮ Find the edge e of T with the largest weight. ◮ Runtime (using Prim’s algorithm): O(|E| log |V|)

Question: Do we really need a MST?

25 / 26

slide-27
SLIDE 27

Improve a Solution

Minimum Spanning Tree

◮ The tree with the smallest sum of edges.

Observation

◮ We only want the largest edge e of an MST. ◮ If we remove all edges e′ from G with ω(e) ≤ ω(e′), G is

disconnected. Can we find e without finding the MST first?

26 / 26

slide-28
SLIDE 28

Improve a Solution

Minimum Spanning Tree

◮ The tree with the smallest sum of edges.

Observation

◮ We only want the largest edge e of an MST. ◮ If we remove all edges e′ from G with ω(e) ≤ ω(e′), G is

disconnected. Can we find e without finding the MST first?

◮ Related problem: Minimum Bottleneck Spanning Tree ◮ Can be implemented in (expected) linear time. ◮ Uses quick-select algorithm as basic strategy. ◮ Not easy to implement correctly.

26 / 26