Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Graph Theory - Shortest Path Problem

AllenHeard
October 12, 2016

Graph Theory - Shortest Path Problem

Year 13 Lesson

AllenHeard

October 12, 2016
Tweet

More Decks by AllenHeard

Other Decks in Education

Transcript

  1. Graph Theory ▪ A graph is a mathematical structure that

    models the relationship between pairs of objects. ▪ The pairs of objects could be almost anything including places, people, websites, numbers, physical components, biological, chemical, data or even concepts. ▪ The study of the use of graphs is called graph theory and it is useful in computing as it allows the programmer to model real-life situations that would otherwise be abstract.
  2. Shortest Path Problem ▪ In graph theory, the shortest path

    problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized. ▪ The problem of finding the shortest path between two intersections on a road map (the graph's vertices correspond to intersections and the edges correspond to road segments, each weighted by the length of its road segment) may be modelled by a special case of the shortest path problem in graphs.
  3. Graph Theory ▪ To start with an example, a graph

    could be used to model the relationship between two places and how they are connected via a train line. ▪ In graph theory, objects are called nodes or vertices and each connection is called an edge or arc. In this simple example, we have two vertices, one for each town and one edge, which in this case will be the train connection between the two towns. ▪ A simple graph may look like this: Town A Town B
  4. Graph Theory ▪ A weighted graph can be created by

    adding values to the edges. ▪ In this example, we might add the travel time between the two towns, so the weighted graph would look like this: Town A Town B 30
  5. Graph Theory ▪ To extend this example, you might add

    in all of the towns on a particular network, with the travel time between each point. Below shows a graph that models the real-life situation so you can see that there is no direct connection between some of the towns, therefore there is no edge between some of the vertices. Town B 30 Town D Town E 60 Town C Town A 30 30 20 20
  6. Graph Theory ▪ The graph now becomes quite useful as

    it could be used, for example, to find the quickest journey times between two towns. For example, to travel by train from Town A to Town E would be quicker via Town C and Town D than via Town B. ▪ Graphs can also be directed or undirected, which refers to the direction of the relationship between two vertices. ▪ An undirected graph is when the relationship between the vertices can be in either direction. In this example, the train will go in either direction between the towns, which means there is a two-way direction between the vertices in the graph. Town B 30 Town D Town E 60 Town C Town A 30 30 20 20
  7. Graph Theory ▪ A directed graph (also known as a

    digraph) is where there is a one-way relationship between the vertices. For example, we may produce a digraph to represent a real-life situation where we are creating a family tree. ▪ In this case, Charles is the parent of Dave and Pauline, Pauline is the parent of Jack and Harry. The arrows indicate that this is a one-way relationship. Pauline Jack Harry `Dave Charles
  8. Shortest Path Algorithms ▪ A number of shortest path algorithms

    exist: – Shimbel (1955). Information networks. – Ford (1956). RAND, economics of transportation. – Leyzorek, Gray, Johnson, Ladew, Meaker, Petry, Seitz (1957). Combat Development Dept. of the Army Electronic Proving Ground. – Dantzig (1958). Simplex method for linear programming. – Bellman (1958). Dynamic programming. – Moore (1959). Routing long-distance telephone calls for Bell Labs. – Dijkstra (1959). Simpler and faster version of Ford's algorithm.
  9. Edsger W.Dijkstra ▪ 1 May 1930 – 6 August 2002

    ▪ Dutch computer scientist – “The question of whether computers can think is like the question of whether submarines can swim.” – “Simplicity and elegance are unpopular because the require hard work and discipline to achieve and education to be appreciated.”
  10. Application of Shortest Path Algorithm ▪ Below are examples of

    some of the common applications that will require a shortest path algorithm. Dijkstra's algorithm is likely to be the basis of all of these: – Geographic information systems (GIS) such as satellite navigation systems and mapping software where the vertices are geographical locations and the edges show distance or drive-time. – Telephone and computer network planning where the vertices are the individual devices on the network and the edges could either be physical distance or a measurement of network capability, such as bandwidth.
  11. Application of Shortest Path Algorithm ▪ Below are examples of

    some of the common applications that will require a shortest path algorithm. Dijkstra's algorithm is likely to be the basis of all of these: – Network routing/packet switching: where the vertices are network devices and the edges are the connections between them. The algorithm can be used to send data packets along the most efficient route. In fact there is a routing protocol for TCP/IP networks called OSPF, which stands for open shortest path first. – Logistics and scheduling: wherever there is a large network of vehicles, for example, delivery vehicles, buses or aeroplanes the algorithm can be used to calculate the optimum routes.
  12. Dijkstra’s Algorithm ▪ The algorithm works as follows using the

    following diagram as an example and assumes that we are looking for the shortest path between vertex A and F rather than the shortest path from A to every node.
  13. Dijkstra’s Algorithm - Task ▪ Calculate the shortest cost path

    from A to G B 2 D F 7 C A 3 6 4 5 E 4 4 G 2
  14. Dijkstra’s Algorithm - Task ▪ Solution B 2 D F

    7 C A 3 6 4 5 E 4 4 G 2 Step Visited A B C D E F G
  15. Dijkstra’s Algorithm - Task ▪ Calculate the shortest cost path

    from A to G F 3 B C 4 E A 8 4 6 6 2 D 2 Step Visited A B C D E F