Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

Make swiftly iOS development Telerik Academy Telerik Academy Plus.
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Overview of the Max-flow problem with sample code and example problem. Georgi Stoyanov Sofia University Student at.
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
C# Fundamentals – Part I
NoSQL Concepts, Redis, MongoDB, CouchDB
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Marketing Mix, SWOT Analysis and Stages of Developing an Idea Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Processing Matrices and Multidimensional Tables Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Optimization problems, Greedy Algorithms, Optimal Substructure and Greedy choice Learning & Development Team Telerik Software.
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Creating E/R Diagrams with SQL Server Management Studio and MySQL Workbench Svetlin Nakov Telerik Software Academy Manager Technical.
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Telerik Software Academy End-to-end JavaScript Applications.
General and reusable solutions to common problems in software design Vasil Dininski Telerik Software Academy academy.telerik.com Intern at Telerik Academy.
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Course Overview Doncho Minkov Telerik Software Academy Technical Trainer
Subroutines in Computer Programming Telerik School Academy C# Fundamentals – Part 1.
Correctly Formatting the Source Code Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Learn to Design Error Steady Code Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Inheritance, Abstraction, Encapsulation, Polymorphism Telerik Software Academy Mobile apps for iPhone & iPad.
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Dijkstra's Shortest Path Algorithm
Graphs: Shortest path and mst
Presentation transcript:

Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor

1. Background 2. The problem 3. Properties and assumptions 4. Applications 5. Dijkstra's algorithm and Pseudocode 6. C# Demo 7. Related problems and algorithms 8. Resources 2

 Let be a (di)graph.  Let G=(V,E) be a (di)graph.  In directed graphs, edges are one-way  An edge-weighted graph is a graph where we associate weights or costs with each edge (or other attributes).  A shortest path from vertex s to vertex t is a directed path from s to t with the property that no other such path has a lower weight. 3

Single-Source Shortest Path Problem Find the shortest paths from a source vertex to all other vertices in the graph 4

 Paths are directed.  The weights are not necessarily distances (could be time or cost).  Edge weights are positive (or zero)  Shortest paths are not necessarily unique  Not all vertices need be reachable  Parallel edges may be present 5

ApplicationVertexEdgeSolutions MapIntersectionRoadFind the shortest route Find the fastest route Find the best route NetworkRouterConnectionInternet routing Flight AgendaAirportsFlightsFind earliest time to reach destination EpidemiologyIndividualsPossible contactsModel the spread of infectious diseases ArbitrageCurrencyExchange rate 6

7 Dijkstra's algorithm first initiates all vertex distances with preliminary values and puts all vertexes in a priority queue. Then picks the unvisited vertex with the lowest-distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor's distance if smaller. Mark visited when done with neighbors.

8

9

function Dijkstra(Graph, source): for each vertex v in Graph: // Initializations for each vertex v in Graph: // Initializations dist[v] := infinity ; // Unknown distance function from dist[v] := infinity ; // Unknown distance function from // source to v // source to v previous[v] := undefined ; // Previous node in optimal path previous[v] := undefined ; // Previous node in optimal path end for // from source end for // from source dist[source] := 0 ; // Distance from source to source dist[source] := 0 ; // Distance from source to source Q := the set of all nodes in Graph ; // All nodes in the graph are put in a Q := the set of all nodes in Graph ; // All nodes in the graph are put in a // Priority Queue Q // Priority Queue Q while Q is not empty: // The main loop while Q is not empty: // The main loop u := vertex in Q with smallest distance in dist[] ; // Start node in first case u := vertex in Q with smallest distance in dist[] ; // Start node in first case remove u from Q ; remove u from Q ; if dist[u] = infinity: if dist[u] = infinity: break ; // all remaining vertices are break ; // all remaining vertices are end if // inaccessible from source end if // inaccessible from source for each neighbor v of u in Q: // where v has not yet been for each neighbor v of u in Q: // where v has not yet been // removed from Q. // removed from Q. alt := dist[u] + dist_between(u, v) ; alt := dist[u] + dist_between(u, v) ; if alt < dist[v]: // Relax (u,v,a) if alt < dist[v]: // Relax (u,v,a) dist[v] := alt ; dist[v] := alt ; previous[v] := u ; previous[v] := u ; decrease-key v in Q; // Reorder v in the Queue decrease-key v in Q; // Reorder v in the Queue end if end if end for end for end while end while return dist; 10

 We can solve different problems using modified Dijkstra algorithm elements:  Graph –vertices, edges and weights meanings  Distance – definition  Priority Queue  Relaxation and Distance Initialization 12

 Dijkstra algorithm is based on the following Lemmas:  Shortest paths are composed of shortest paths. It is based on the fact that if there was a shorter path than any sub-path, then the shorter path should replace that sub-path to make the whole path shorter.  The sum of the lengths of any two sides of a triangle is greater than the length of the third side. 13

 Analysis of Dijkstra’s Algorithm:  The initialization uses only O(n) time.  Each vertex is processed exactly once.  The inner loop is called once for each edge in the graph. Each call of the inner loop does O(1) work plus, possibly, one Decrease-Key operation.  All of the priority queue operations require time  Finally and we get time  If unsorted sequence is used instead of priority queue we get O(n 2 + e) 14

 Breadth-first search - special-case of Dijkstra's algorithm on unweighted graphs when all edge costs are positive and identical. The priority queue degenerates into a FIFO queue.  Uniform-cost search - the shortest path to a particular node  The A* algorithm - generalization of Dijkstra's algorithm that cuts down on the size of the subgraph that must be explored, if additional information is available that provides a lower bound on the "distance" to the target. 15

  orithm orithm orithm  Engineering-and-Computer-Science/6- 046JFall-2005/CourseHome/ Engineering-and-Computer-Science/6- 046JFall-2005/CourseHome/ Engineering-and-Computer-Science/6- 046JFall-2005/CourseHome/   Nakov’s book: Programming = ++Algorithms; 16

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

 “C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com