Lec14_Graph_Theory_Part_2

# Lec14_Graph_Theory_P - [Lecture 14[Graph Theory Part 2 Discrete Structures 1 Discrete Structures TDS1191 Lecture 14 Graph Theory Part 2 Discrete

This preview shows pages 1–5. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: [Lecture 14][Graph Theory Part 2] Discrete Structures 1 Discrete Structures TDS1191- Lecture 14 - Graph Theory Part 2 Discrete Structures 2 Shortest Path Problem The shortest path problem arises whenever we try to determine the shortest, cheapest, or most reliable path between one or many pairs of nodes in a network. Graphs that have a number assigned to each edge are called weighted graphs . Several types of problems involving weighted graph arise frequently, such as the traveling salesman problem, which asks for the minimum total distance a salesman need to travel. The shortest path problem arises whenever we try to determine the shortest, cheapest, or most reliable path between one or many pairs of nodes in a network. Graphs that have a number assigned to each edge are called weighted graphs . Several types of problems involving weighted graph arise frequently, such as the traveling salesman problem, which asks for the minimum total distance a salesman need to travel. a 3 b c d e f 3 2 5 7 1 9 A weighted simple graph [Lecture 14][Graph Theory Part 2] Discrete Structures 3 Discrete Structures 3 There are several different algorithms that find a shortest path between two vertices in a weighted graph. The Dutch Mathematician Edsger Dijkstra in 1959 discovered an algorithm to solve the shortest path problem, the algorithm is named after him. The algorithm relies on a series of iterations. It uses O(n 2 ) operations (additions and comparisons) to find the length of a shortest path between two vertices in a connected simple undirected weighted graph with n vertices. Dijkstra’s Algorithm is an algorithm to find the shortest path from a single source vertex to all other vertices in a weighted , undirected graph. All weights must be nonnegative. Dijkstra’s Algorithm is an algorithm to find the shortest path from a single source vertex to all other vertices in a weighted , undirected graph. All weights must be nonnegative. Dijkstra’s Shortest Path Algorithm [Lecture 14][Graph Theory Part 2] Discrete Structures 4 Discrete Structures 4 Algorithm : Dijkstra’s shortest-path algorithm Input : A connected, weighted graph with positive edge weights; Vertices a and z . Output : L(z) , the length of a shortest path from vertex a to vertex z . 1. procedure Dijkstra( w, a, z, L ); 2. L(a) := ; 3. for all vertices x ≠ a do 4. L(x) := ∞ ; 5. T := set of all vertices; 6. // T is the set of vertices whose shortest distance from a has not been found // 7. while z ∈ T do 8. begin 9. choose v from T with minimum L(v) ; 10 T := T – { v }; 11 for each x that is in T and that is adjacent to v do 12 L(x) := min{ L(x) , L(v) + w(v, x) }; 13 end // while // 14 end; Algorithm : Dijkstra’s shortest-path algorithm Input : A connected, weighted graph with positive edge weights; Vertices a and z ....
View Full Document

## This note was uploaded on 02/03/2012 for the course IT 1191 taught by Professor Yong during the Spring '11 term at Multimedia University, Cyberjaya.

### Page1 / 29

Lec14_Graph_Theory_P - [Lecture 14[Graph Theory Part 2 Discrete Structures 1 Discrete Structures TDS1191 Lecture 14 Graph Theory Part 2 Discrete

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online