1 / 59

Use networks in solving problems Level 2 AS91260 2credits

Use networks in solving problems Level 2 AS91260 2credits. MCS: 27 Feb 2013. What is a network?. A graph is collection of points with lines between them. A network is a graph with positive numbers assigned to the edges as weights. Network Examples.

pello
Download Presentation

Use networks in solving problems Level 2 AS91260 2credits

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Use networks in solving problemsLevel 2 AS91260 2credits MCS: 27 Feb 2013

  2. What is a network? A graph is collection of points with lines between them. A networkis a graph with positive numbers assigned to the edges as weights.

  3. Network Examples Networks are useful for modelling things that are connected. For example: • Devices connected to routers • Cities connected by highways • Airports connected by flight paths • Water pipes connected to mains and treatment plants • Modelling disease spread • Robot path finding In this topic, we will look at ways of optimising the use of networks – eg“What is the quickest way from A to B”?

  4. London Tube and Rail network

  5. Vocabulary Point/Vertex/Node Line/Edge/Arc Weighting Region/AreaWe count the region outside, too

  6. Euler’s Rule How many arcs, regions and vertices does this network have? Euler’s Rule: arcs = vertices + regions - 2 Does Euler’s Rule work for this graph? a = v + r – 2 Vertices = Regions = Arcs =

  7. Breaking Euler? Can we break Euler’s Rule? What about this? We can draw the same situation, with the same nodes connected like this: The arcs are crossing, but not at a node. It is almost as is they are overlapping. We can’t easily define the regions . Now we can easily define the regions. Does Euler’s Rule still work?

  8. 3D shapes to 2D networks Imagine that we have a cuboid, with nodes on each corner, and arcs making up each edge We can represent this as a 2D network by ‘flattening’ it Every edge in the cuboid is represented by an equivalent arc in the network.Same with corners and nodes.

  9. Odd and Even Vertices The degree(or valency) of a vertex is the number of arcs connected to it Even vertex4 arcs connected Odd vertex3 arcs connected

  10. Can you draw it? 1. Is it possible to draw the arcs in these shapes without lifting your pen from the page? 2. Is it possible to travel along every arc in these networks once and once only? 3. Is it possible to do this by starting and ending at the same node?

  11. Traversability Question 1 and 2 are the same. If we can travel along each arc once and once only, then the network is traversable. If a traversable network can start and end at the same vertex, it is called an Eulerian Circuit. Traversable networks that start and end at different vertices are called Eulerian Paths.

  12. Eulerian Circuits and Paths Eulerian Circuits have no odd nodes. Eulerian Paths have exactly two odd nodes. Any network with more odd nodes isnot traversable Count the odd nodes on these networks to prove which are Eulerian Paths, Eulerian Circuits and not traversable.

  13. Weighting the Network Often, network information will be given in a table form. Copy this diagram and fill in the distances from the table provided. Orangetown Yellowville Red Bay Greenberg Blueswater Cape Purple

  14. Weighting the Network Often, network information will be given in a table form. Copy this diagram and fill in the distances from the table provided. Orangetown Yellowville 7 3 8 5 4 Red Bay 10 6 Greenberg Blueswater 12 Cape Purple

  15. Shortest Path –Dijkstra’s algorithm Dijkstra’s algorithm connects any two nodes in a network using the shortest path: • Label the starting node with ‘0’ • Label the nodes connected to this with the total (smallest) arc weight to get there. Put an arrow on the arc back to the node it came from. • Repeat step 2 until you have a total in the end node. Follow the arrows back to the start to find the shortest path. Keep track of your working on the network diagram itself. Show the sequence of nodes that make up the final path, along with the total weight of the path at the end. Eg: “The shortest path from A to L is ABFHJL. It is 45km long” EdsgerDijkstra

  16. Shortest Path – Dijkstra’s We want the shortest path from A to L Label the starting node with ‘0’ I 6 7 L H J 3 25 11 C 4 A 1 0 E 25 4 9 D 2 G 12 3 B K 5 7 23 F

  17. Shortest Path – Dijkstra’s Label the nodes connected to this with the total (smallest) arc weight to get there. Put an arrow on the arc back to the node it came from. I 6 7 L H J 3 25 11 C 4 A 4 1 0 E 25 4 9 D 2 G 12 3 B K 2 5 7 23 F

  18. Shortest Path – Dijkstra’s Label the nodes connected to this with the total (smallest) arc weight to get there. Put an arrow on the arc back to the node it came from. I 6 7 L H 29 J 3 25 11 C 4 A 4 1 0 E 25 5 4 9 D 2 G 12 5 3 B K 2 5 7 23 F 25

  19. Shortest Path – Dijkstra’s Label the nodes connected to this with the total (smallest) arc weight to get there. Put an arrow on the arc back to the node it came from. 36 I 6 7 L H 29 J 3 25 32 11 C 4 A 4 1 0 E 25 5 4 9 D 2 G 12 5 17 3 B K 2 29 5 The value at F has reducedand an arrow removed due to a smaller path found 7 23 F 22

  20. Shortest Path – Dijkstra’s Label the nodes connected to this with the total (smallest) arc weight to get there. Put an arrow on the arc back to the node it came from. 36 I 6 7 L H 29 J 38 3 25 32 11 C 4 A 4 1 0 E 25 5 4 9 D 2 G 12 5 17 3 B K 2 29 5 7 23 F 22

  21. Shortest Path – Dijkstra’s Follow the arrows back to the start to find the shortest path. Shortest path: ABDGFKL Path length: 38 36 I 6 7 L H 29 J 38 3 25 32 11 C 4 A 4 1 0 E 25 5 4 9 D 2 G 12 5 17 3 B K 2 29 5 7 23 F 22

  22. Minimum Spanning Trees A Spanning Tree is a series of arcs which connects all nodes in the network. A Minimum Spanning Tree (MST) uses the smallest possible total weight to do so. Total Weight3+2+2+8+8+7+4+1+3= 38

  23. MST – Prim’s Algorithm Prim’s starts at any node and builds up a tree ofconnected arcs to new nodes. Prim’s Algorithm: • Choose a node to start at. • Find (and highlight) the shortest arc connected to this node. • Find (and highlight) the shortest arc that connects a previously selected node to a new one. • Repeat step 3 until all nodes are connected. Keep track of your working by writing down each arc that you are adding,and the weight of it. Eg: Show the total weight of the MST at the end. Robert C. Prim MST- Prim’sStart: C C-A (15) C-D (12) D-B (5) …etc

  24. MST – Prim’s Start: D Prim’s Algorithm for Minimum Spanning TreeThis is our original networkWe are going to choose D as the starting node

  25. MST – Prim’s Start: D D-A (5) Identify arcs (dark blue) which connect new nodes to our current tree (green). Select arc with smallest weighting (light blue)

  26. MST – Prim’s Start: D D-A (5) D-F (6) Identify arcs (dark blue) which connect new nodes to our current tree (green). Select arc with smallest weighting (light blue)

  27. MST – Prim’s Start: D D-A (5) D-F (6) A-B (7) Identify arcs (dark blue) which connect new nodes to our current tree (green). Select arc with smallest weighting (light blue)

  28. MST – Prim’s Start: D D-A (5) D-F (6) A-B (7)B-E (7) Identify arcs (dark blue) which connect new nodes to our current tree (green). Select arc with smallest weighting (light blue)

  29. MST – Prim’s Start: D D-A (5) D-F (6) A-B (7)B-E (7) E-C (5) Identify arcs (dark blue) which connect new nodes to our current tree (green). Select arc with smallest weighting (light blue)

  30. MST – Prim’s Start: D D-A (5) D-F (6) A-B (7)B-E (7) E-C (5) E-G (9) Identify arcs (dark blue) which connect new nodes to our current tree (green). Select arc with smallest weighting (light blue)

  31. MST – Prim’s Start: D D-A (5) D-F (6) A-B (7)B-E (7) E-C (5) E-G (9) Total: 39 All nodes are now connected and MST is complete.Total the weights of each connected arc.

  32. MST – Kruskal’s Algorithm Kruskal’sstarts at the smallest arc and adds morearcs, avoiding cycles, until every node is linked. Kruskal’s Algorithm: • Find (and highlight) the shortest arc. • Find (and highlight) the next shortest arcthat does not create a cycle. This arc does not need to be connected to any previous one. • Repeat step 2 until all nodes are connected. Keep track of your working by writing down each arc that you are adding, and the weight of it. Eg: Show the total weight of the MST at the end. Joseph Kruskal MST- Kruskal’sStart: C-A (3) F-H (5) D-B (5) …etc

  33. MST – Kruskal’s Start: A-D (5) Kruskal’s Algorithm for Minimum Spanning TreeThis is our original networkA-D is shortest arc (choose one if there are several)

  34. MST – Kruskal’s Start: A-D (5)C-E (5) Identify next shortest arc, provided it doesn’t create a cycle

  35. MST – Kruskal’s Start: A-D (5)C-E (5) D-F (6) Identify next shortest arc, provided it doesn’t create a cycle

  36. MST – Kruskal’s Start: A-D (5)C-E (5) D-F (6)A-B (7) Identify next shortest arc, provided it doesn’t create a cycle

  37. MST – Kruskal’s Start: A-D (5)C-E (5) D-F (6)A-B (7) B-E (7) Identify next shortest arc, provided it doesn’t create a cycle

  38. MST – Kruskal’s Start: A-D (5)C-E (5) D-F (6)A-B (7) B-E (7)E-G (9) Total: 39 All nodes are now connected and MST is complete.Total the weights of each connected arc.

  39. MST – Reverse Delete Algorithm Reverse-Delete is the opposite of Kruskal’s Algorithm, starting with the full network and removing arcs. Reverse-Delete Algorithm: • Find the longest arc. Remove (highlight ‘out’) this arc, provided that it doesn’t isolate a node or set of nodes. • Repeat, removing the next longest arc, remembering not to isolate any nodes or sets of nodes. Keep track of your working by writing down each arc that you are removing, and the weight of it. Eg: Show the total weight of the remaining MST at the end. MST- Reverse DeleteArcs Removed: E-F (23) A-G (21) G-I (21) …etc

  40. MST – Reverse-Delete Removed: Reverse-Delete Algorithm for Minimum Spanning TreeThis is our original network

  41. MST – Reverse-Delete Removed:D-E (15) Identify longest arc, provided it doesn’t isolate a node or nodes

  42. MST – Reverse-Delete Removed:D-E (15)F-G (11) Identify longest arc, provided it doesn’t isolate a node or nodes

  43. MST – Reverse-Delete Removed:D-E (15)F-G (11) D-B (9) Identify longest arc, provided it doesn’t isolate a node or nodes

  44. MST – Reverse-Delete Removed:D-E (15)F-G (11) D-B (9)B-C (8) Identify longest arc, provided it doesn’t isolate a node or nodes

  45. MST – Reverse-Delete Removed:D-E (15)F-G (11) D-B (9)B-C (8) F-E (8) Identify longest arc, provided it doesn’t isolate a node or nodes

  46. MST – Reverse-Delete Removed:D-E (15)F-G (11) D-B (9)B-C (8) F-E (8) Total remaining: 39 No more arcs can be removed, so MST is complete.Total the weights of each remainingarc.

  47. Minimum Spanning Trees - Notes • A MST with n nodes has (n-1) arcs. • There can be more than one MST for a network. • Each MST will have the same total weight.

  48. Maximum Spanning Trees?

  49. Maximum Spanning Trees? We can imagine a MaximumSpanning Tree – that is, a tree which joins each node using a minimum number of arcs (n-1), but using the largest possible total weight to do so. For instance, we might be interested in maximising passenger numbers on flights paths which join cities. Or we might want to maximise scenic value on a set of trails which join key locations in a national park. To find the Maximum Spanning Tree, use Prim’s or Krukal’s algorithm, but go from longest to shortest arcs. Or use Reverse-Delete, but delete shortest arcs first.

  50. Example: Cities in the North-East USA

More Related