st introduction to graph algorithms this class website
play

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


  1. ST: Introduction to Graph Algorithms

  2. This Class

  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

  4. Requirements Completely new class from scratch! ◮ Experimental. ◮ No textbook. ◮ Feedback is highly appreciated. Requirements ◮ Quizzes 50 % ◮ Project 50 % 4 / 26

  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

  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

  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

  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

  9. Not in this Class but Useful to Know

  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

  11. Trees 11 / 26

  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. Dequeue Enqueue 5 2 4 1 3 Min 12 / 26

  13. Sorting Array based ◮ In O ( n log n ) time. ◮ Requires O ( log n ) additional space. ◮ Not stable. 2 a 6 a 6 b 2 b 5 4 3 1 Input 2 b 2 a 6 a 6 b 1 3 4 5 Output 13 / 26

  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

  15. Graphs

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

  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

  18. Implementation: Adjacency List For each vertex, there is an array storing pointers † to all neighbours. 0 1 3 4 1 1 2 5 2 5 2 1 3 0 3 0 2 4 3 4 4 0 3 5 G 5 1 4 † Usually, the vertex index is sufficient. 18 / 26

  19. Example Problem

  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

  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 } . 5 7 A 3 G Problem: Find the set A for which sep ( A ) is maximal. 21 / 26

  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

  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

  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

  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

  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

  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

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend