Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming for Geographical Information Analysis: Advanced Skills Online mini-lecture: Introduction to Networks Dr Andy Evans.

Similar presentations


Presentation on theme: "Programming for Geographical Information Analysis: Advanced Skills Online mini-lecture: Introduction to Networks Dr Andy Evans."— Presentation transcript:

1 Programming for Geographical Information Analysis: Advanced Skills Online mini-lecture: Introduction to Networks Dr Andy Evans

2 This lecture Introduction. Graph theory. Types of Networks. Path analysis. Flow analysis.

3 Networks? Vehicle / Distribution: Motorways, rail, electricity grid, water, nerves, circuits. Socio-economic: Trade, politics, friendship. Spatial-temporal: Timetables, zonal maps, chemical structures. Almost any set of complex relationships between variables can be represented as a network in variable space.

4 Graph Theory The study of networks as graphs. How do we efficiently move around networks? How do networks break down? Can we add links to improve networks? How do things spread around networks?

5 Combination of (potentially disconnected) Vertices and Edges. Can be Directional (sometimes called digraphs) What is a graph?

6 Vertices are the points on a network. Edges are the relationships. The degree of a vertex is the number of edges it has connected to it.

7 Representing networks Note that it is only the connections that matter, not how they’re drawn. E.g. contiguousness in maps. 1 234 56 011100 101010 110111 101010 011001 001110 123456 1 2 3 4 5 6

8 Types of graph Planar graphs can be redrawn without crossing. Tree Complete: each vertex is connected to all the others. Regular: each vertex has the same number of edges. Simple: no loops or multiple paths.

9 Walks, Trails and Paths A Walk: any sequence of adjacent edges. A Trail: any sequence of unrepeated adjacent edges. A Path: any sequence of adjacent edges that don’t visit the same vertex more than once. A trail, but not a path. A path that ends where it begins is called a Cycle.

10 Eulerian networks A graph is Eulerian if there is a trail containing every edge in a graph. Euler solved the K ö nigsberg Bridges problem: can you cross all the bridges and return to your starting point, crossing each once and once only… A B C D

11 Eulerian networks A graph will contain a cycle if each vertex has a degree of >2. A connected graph is Eulerian if, and only if, the degree of each vertex is even. A semi-Eulerian network is the same but doesn’t end up at its start. A connected graph is semi-Eulerian when only two of its vertices are odd. Uses: Designing one-way systems. Designing diversions / flow alterations.

12 Fleury’s Algorithm How to construct a Eulerian trail in a Eulerian graph. Start with any vertex, and travel through the edges, following these rules… 1. As you go through each edge, mark it as taboo. 2. If you create isolated vertices, mark them as taboo. 3. Only use a bridge as a last resort. A bridge is an edge connecting two otherwise disconnected graphs…

13 Hamiltonian networks A graph is Hamiltonian if there’s a path taking in every vertex once only, that ends where it began. A graph is semi-Hamiltonian if there’s a trail taking in every vertex once only that doesn’t end where it began. Dirac’s Theorem A simple graph with n vertices (more than two) is Hamiltonian if the degree of each vertex is greater than n/2. Note that there may be more Hamiltonian situations.

14 Weighted graphs So far we’ve only been interested in connections, but we can add strength, capacity, or length of connections. This gives much more realistic networks, and allows us to study real path optimisation problems. 3 4 2 1 1 3 3 Path length = 5

15 Path optimisation problems Three major problems Shortest Path Problem What is the shortest path between two points? Chinese Postman Problem What is the shortest way around a network back to the start taking in each edge (imagining the edges to be roads of houses)? Travelling Salesman Problem What is the shortest way around a network back to the start taking in each vertex (imagining each to be a city)?

16 Shortest Path Problem Find the shortest path across a weighted graph. 95 5 5 3 2 1 9 1 2 AB

17 Shortest Path Problem algorithm Move from A to B, treating all the vertices at each distance from the start in turn. Attribute the value of the shortest path to each vertex to that vertex, then reassess each of its neighbours to see if the path is now shorter to them. Continue until at the destination and follow back shortest path. 9 9 5 3 2 1 A 0 2 14 8 9 5 3 2 1 A 0 2 3

18 Chinese Postman Problem Suggested by Mei-Ku Kwan Find the shortest walk taking in all the weighted edges and coming back to the start. If the graph is Eulerian we can use Fleury’s method. If not we find a semi-Eulerian trail using Fleury’s to take in all the edges. We then use the Shortest Path algorithm to find our way back to the start.

19 Travelling Salesman Problem Find the shortest weighted path needed to visit a number of cities once (i.e. the shortest Hamiltonian path). No efficient accurate algorithm. Could calculate all the possible Hamiltonians and pick the shortest. However, for 20 cities on a Hamiltonian graph, there are about 6 x 10 16 such possible paths. One solution is to use a Minimum Connector.

20 The Minimum Connector Problem Work out the smallest sub-network to connect a set of vertices on a weighted network – a spanning tree. 1) Choose the smallest weighted edge. 2) Continue picking the next smallest connected edges but not using edges that form cycles with the ones already picked. 3 1 2 5 6 3 1 2 5 6 3 1 2 5 6

21 The Travelling Salesman revisited If we remove a vertex from a Hamiltonian path, we end up with a spanning tree. To get an good approximation for the Travelling Salesman path, we… 1) Remove a vertex from the graph, and its associated edges. 2) Form the minimum connector for the rest of the graph. 3) Add in the vertex and the two of its edges with the minimum weights. This will give us a semi-Hamiltonian which the solution can’t be better than, and which the solution will be close to. Alternatively use AI to search the solution space.

22 Network flows: strong connection Strongly connected graphs are those digraphs where every vertex can be reach from every other. A graph can be made into a strongly connected one if each edge is in a cycle. I.e. you can’t make a purely one-way system in a town split by a single bridge. Strongly connected Not strongly connected

23 Maximum Flow – Minimum Cut Given each part of a network has a capacity, what is the maximum capacity of the network? It equals the minimum capacity “cut” of the graph. A cut is a set of edges which a flow must pass through one of. 9 1 2 3 5 7 4 A B Cut 1Cut 2 Cut 3 Maximum flow 6 1 1

24 Other things Graph Theory can help with Finding the distribution of flow in interconnected networks with resistances and inputs/outputs. Calculating whether graph lines, e.g. railways, need to cross. Calculating the number of rearrangements possible between vertices on a graph. The maximum number of different paths between two places. Timetabling (using rooms and people as components). How many colours it takes to colour a zonal map. How long it takes to do a number of parallel tasks. Magic squares. Arranged marriages.

25 Summary Graph theory encapsulates the mathematics of networks. Eulerian graphs are those where you can visit all the edges one and end up at the start. Hamiltonian graphs are those where you can visit all the vertices once and end up at the start. The rules for these graphs help us design network systems.

26 Summary By giving weights to edges we can model real dynamic systems. We can find out optimal paths. We can work out transport loads.


Download ppt "Programming for Geographical Information Analysis: Advanced Skills Online mini-lecture: Introduction to Networks Dr Andy Evans."

Similar presentations


Ads by Google