260 likes | 274 Views
This online mini-lecture provides an introduction to networks in geographic information analysis, covering graph theory, types of networks, path analysis, flow analysis, and more. Learn how to efficiently analyze and improve networks to better understand complex relationships between variables in spatial-temporal, socio-economic, and vehicle/distribution contexts.
E N D
Programming for Geographical Information Analysis:Advanced Skills Online mini-lecture: Introduction to Networks Dr Andy Evans
This lecture Introduction. Graph theory. Types of Networks. Path analysis. Flow analysis.
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.
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?
What is a graph? Combination of (potentially disconnected) Vertices and Edges. Can be Directional (sometimes called digraphs)
What is a graph? 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.
Representing networks Note that it is only the connections that matter, not how they’re drawn. E.g. contiguousness in maps. 1 2 3 4 5 6 1 1 0 1 1 1 0 0 2 1 0 1 0 1 0 3 1 1 0 1 1 1 2 3 4 1 0 1 0 1 0 4 5 0 1 1 0 0 1 5 6 6 0 0 1 1 1 0
Planar graphs can be redrawn without crossing. Tree Types of graph Complete: each vertex is connected to all the others. Regular: each vertex has the same number of edges. Simple: no loops or multiple paths.
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.
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 D B C
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.
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… • As you go through each edge, mark it as taboo. • If you create isolated vertices, mark them as taboo. • Only use a bridge as a last resort. A bridge is an edge connecting two otherwise disconnected graphs…
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.
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 1 1 3 Path length = 5 2 3
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)?
5 9 5 5 3 2 A B 2 1 1 9 Shortest Path Problem Find the shortest path across a weighted graph.
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 8 9 9 5 5 3 3 14 3 0 0 A A 2 2 1 1 2 2
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.
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 1016 such possible paths. One solution is to use a Minimum Connector.
The Minimum Connector Problem Work out the smallest sub-network to connect a set of vertices on a weighted network – a spanning tree. • Choose the smallest weighted edge. • Continue picking the next smallest connected edges but not using edges that form cycles with the ones already picked. 3 3 3 2 2 2 1 6 6 6 1 1 5 5 5
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… • Remove a vertex from the graph, and its associated edges. • Form the minimum connector for the rest of the graph. • 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.
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
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. Maximum flow 6 1 5 1 9 7 2 B A 1 4 3 Cut 3 Cut 1 Cut 2
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.
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.
Summary By giving weights to edges we can model real dynamic systems. We can find out optimal paths. We can work out transport loads.