3 Distance in Graphs. Brief outline of this lecture



Similar documents
CSC 505, Fall 2000: Week 8

CHAPTER ONE VECTOR GEOMETRY

value in arriving packet s header routing algorithm local forwarding table header value output link

Covering planar graphs with degree bounded forests

Social Media Mining. Graph Essentials

5 Using Your Verbatim Autodialer

Resource Pricing and Provisioning Strategies in Cloud Systems: A Stackelberg Game Approach

On a Generalized Graph Coloring/Batch Scheduling Problem

On the maximum average degree and the incidence chromatic number of a graph

Global attraction to the origin in a parametrically-driven nonlinear oscillator

Graph-based Simplex Method for Pairwise Energy Minimization with Binary Variables

HOMOTOPY FIBER PRODUCTS OF HOMOTOPY THEORIES

Joint Routing and Scheduling in Multi-hop Wireless Networks with Directional Antennas

Tight Bounds for Randomized Load Balancing on Arbitrary Network Topologies

Cpt S 223. School of EECS, WSU

Manipulating Deformable Linear Objects: Characteristic Features for Vision-Based Detection of Contact State Transitions

Eigenvalues and the Laplacian of a graph

Central Angles, Arc Length, and Sector Area

LINES AND PLANES IN R 3

Network (Tree) Topology Inference Based on Prüfer Sequence

Optimal Trust Network Analysis with Subjective Logic

Fast Approximation of Steiner Trees in Large Graphs

Rotated Ellipses. And Their Intersections With Lines. Mark C. Hendricks, Ph.D. Copyright March 8, 2012

Graph Theory and Complex Networks: An Introduction. Chapter 06: Network analysis. Contents. Introduction. Maarten van Steen. Version: April 28, 2014

Warshall s Algorithm: Transitive Closure

LIMITS IN CATEGORY THEORY

The Goldberg Rao Algorithm for the Maximum Flow Problem

Configuration Management for Software Product Lines

A Layered Architecture for Querying Dynamic Web Content

Vectors. Vector Multiplication

Analysis of Algorithms, I

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Linear Programming. Non-Lecture J: Linear Programming

Graphs without proper subgraphs of minimum degree 3 and short cycles

Graph Theory and Complex Networks: An Introduction. Chapter 06: Network analysis

Approximation Algorithms

On the urbanization of poverty

Online Dominating Set and Variations on. Stephan Eidenbenz. Institute of Theoretical Computer Science, ETH Zurich, Switzerland.

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

Continuity Analysis of Programs

Modeling Roughness Effects in Open Channel Flows D.T. Souders and C.W. Hirt Flow Science, Inc.

WAN Wide Area Networks. Packet Switch Operation. Packet Switches. COMP476 Networked Computer Systems. WANs are made of store and forward switches.

Chapter 21. Epidemics Diseases and the Networks that Transmit Them

Well-Separated Pair Decomposition for the Unit-disk Graph Metric and its Applications

High Availability for Microsoft SQL Server Using Double-Take 4.x

Shortcut sets for plane Euclidean networks (Extended abstract) 1

Regular Specifications of Resource Requirements for Embedded Control Software

The Dot Product. Properties of the Dot Product If u and v are vectors and a is a real number, then the following are true:

PY106 Class13. Permanent Magnets. Magnetic Fields and Forces on Moving Charges. Interactions between magnetic north and south poles.

Using GPU to Compute Options and Derivatives

ASAND: Asynchronous Slot Assignment and Neighbor Discovery Protocol for Wireless Networks

Bonds with Embedded Options and Options on Bonds

Key Stage 2 Mathematics Programme of Study

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

6.852: Distributed Algorithms Fall, Class 2

Leveraging History for Faster Sampling of Online Social Networks

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Stability of Linear Control System

An unbiased crawling strategy for directed social networks

Statistical Image Completion

Applied Algorithm Design Lecture 5

4.12. Using Verilog for Behavioral Specification with Simulation for the 5-Stage Pipeline

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, Chapter 7: Digraphs

Minimum cost maximum flow, Minimum cost circulation, Cost/Capacity scaling

Degree Hypergroupoids Associated with Hypergraphs

Every manufacturer is confronted with the problem

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

PHY2061 Enriched Physics 2 Lecture Notes Relativity 4. Relativity 4

Seminar. Path planning using Voronoi diagrams and B-Splines. Stefano Martina

Chapter 2 Solutions. 4. We find the average velocity from

2 2 Matrices. Scalar multiplication for matrices. A2 2matrix(pronounced 2-by-2matrix )isasquareblockof4numbers. For example,

Load balancing Static Load Balancing

2.3 Convex Constrained Optimization Problems

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory

Chapter 14. Three-by-Three Matrices and Determinants. A 3 3 matrix looks like a 11 a 12 a 13 A = a 21 a 22 a 23

Finding and counting given length cycles

FINANCIAL FITNESS SELECTING A CREDIT CARD. Fact Sheet

Large induced subgraphs with all degrees odd

12.5 Equations of Lines and Planes

An Energy-Efficient Communication Scheme in Wireless Cable Sensor Networks

SHARP BOUNDS FOR THE SUM OF THE SQUARES OF THE DEGREES OF A GRAPH

Adaptive behaviour in a predator-prey model leads to multiple equilibrium states. A. Pimenov, A. Korobeinikov, D. Rachinskii

ARLib: A C++ Augmented Reality Software Development Kit. Masters Thesis

Basic Linear Algebra

Key Stage 3 Mathematics Programme of Study

Chapter Consider an economy described by the following equations: Y = 5,000 G = 1,000

Spectrum Balancing for DSL with Restrictions on Maximum Transmit PSD

Efficient Euclidean Distance Transform Using Perpendicular Bisector Segmentation

Guessing Game: NP-Complete?

High Availability for Internet Information Server Using Double-Take 4.x

Midterm Practice Problems

Load Balancing and Termination Detection

7 Gaussian Elimination and LU Factorization

Target Tracking with Monitor and Backup Sensors in Wireless Sensor Networks

Introduction to Scheduling Theory

Exact moments of generalized order statistics from type II exponentiated log-logistic distribution

Load Balancing and Termination Detection

Shortest Inspection-Path. Queries in Simple Polygons

Transcription:

Distance in Graphs While the preios lectre stdied jst the connectiity properties of a graph, now we are going to inestigate how long (short, actally) a connection in a graph is. This natrally leads to the concept of graph distance, which has two ariants: the simple one considering only the nmber of edges, while the weighted one haing a length for each edge. a b c Brief otline of this lectre d x Distance in a graph, basic properties, triangle ineqality. Graph metrics: all-pairs shortest distances. Dijkstra s algorithm for the shortest weighted distance in a graph. Rote planning: a sketch of some adanced ideas. Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

. Graph distance (nweighted) Recall that a walk of length n in a graph G is an alternating seqence of ertices and edges, e,, e,,...,e n, n sch that each e i has the ends i, i. Definition.. Distance d G (, ) between two ertices, of a graph G is defined as the length of the shortest walk between and in G. If there is now walk between,, then we declare d G (, ) =. Informally and natrally, the distance between, eqals the least possible nmber of edges traersed from to. Specially d G(, ) =. Recall, moreoer, that the shortest walk is always a path Theorem.. Fact: The distance in an ndirected graph is symmetric, i.e. d G (, ) = d G (, ). Lemma.. The graph distance satisfies the triangle ineqality:,, w V (G) : d G (, ) + d G (, w) d G (, w). Proof. Easily; starting with a walk of length d G (, ) from to, and appending a walk of length d G (, w) from to w, reslts in a walk of length d G (, ) + d G (, w) from to w. This is an pper bond on the real distance from to w. Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

How to find the distance Theorem.. Let,, w be ertices of a connected graph G sch that d G (, ) < d G (, w). Then the breadth-first search algorithm on G, starting from, finds the ertex before w. Proof. We apply indction on the distance d G (, ): If d G (, ) =, i.e. =, then it is triial that is fond first. So let d G (, ) = d > and be a neighbor of closer to, which means d G (, ) = d. Analogosly choose w a neighbor of w closer to. Then d G (, w ) d G (, w) > d G (, ) = d G (, ), and so has been fond before w by the indctie assmption. Hence has been stored into U before w, and (cf. FIFO) the neighbors of ( among them, bt not w) are fond before the neighbors of w (sch as w). Corollary.. The breadth-first search algorithm on G correctly determines graph distances from the starting ertex. Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

Other related terms Definition. Let G be a graph. We define, with respect to G, the following notions: The excentricity of a ertex exc() is the largest distance from to another ertex; exc() = max x V (G) d G (, x). The diameter diam(g) of G is the largest excentricity oer its ertices, and the radis rad(g) of G is the smallest excentricity oer its ertices. The center of G is the sbset U V (G) of ertices sch that their excentricity eqals rad(g). Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

. All-pairs shortest distances Definition: The metrics of a graph is the collection of distances between all pairs of its ertices. In other words, the metrics is a matrix d[,] sch that d[i,j] is the distance from i to j. Method.. Dynamic programming for all-pairs distances in a graph G on the ertex set V (G) = {,,..., N }. Initially, let d[i,j] be (alternatiely, the edge length of { i, j }), or if i, j are not adjacent. After step t let it hold that d[i,j] is the shortest length of a walk between i, j sch that its internal ert. are from {,,..., t } (empty for t = ). Moing from step t to t +, we pdate all the distances as: Either d[i,j] from the preios step is still optimal (the ertex t does not help to obtain a shorter walk from i to j ), or there is a shorter i to j walk sing (also) the ertex t which is, by the assmption at step t, of length d[i,t]+d[t,j] d[i,j]. Theorem.6. Method. correctly comptes the distance d[i,j] between each pair of ertices i, j in N = V (G) steps. Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

Remark: In a practical implementation we may se, say, MAX INT/ in place of. Algorithm.7. Floyd Warshall algorithm (cf..) inpt < the adjacency matrix G[,] of an N-ertex graph, sch that the ertices of G are indexed as...n-, and G[i,j]= if i, j adjacent and G[i,j]= otherwise; for (i=; i<n; i++) for (j=; j<n; j++) d[i,j] = (i==j?: (G[i,j]? : MAX INT/)); for (t=; t<n; t++) { for (i=; i<n; i++) for (j=; j<n; j++) d[i,j] = min(d[i,j], d[i,t]+d[t,j]); } retrn The distance matrix d[,] ; Notice that this Algorithm.7 is extremely simple and relatiely fast it needs abot N steps to get the whole distance matrix. Its only problem is that all-pairs distances mst be compted at the same time, een if we need to know jst one distance... Petr Hliněný, FI MU Brno 6 FI: MA: Distance in Graphs

. Weighted distance in graphs Definition: A weighted graph is a graph G together with a weighting w of the edges by real nmbers w : E(G) R (edge lengths in this case). A positiely weighted graph G, w is sch that w(e) > for all edges e. Definition.8. (Weighted distance) Consider a positiely weighted graph G, w. The length of the weighted walk S =, e,, e,,..., e n, n in G is the sm d w G(S) = w(e ) + w(e ) + + w(e n ). The weighted distance in G, w between a pair of ertices, is d w G (, ) = min{dw G (S) : S is a walk from to }. All these terms natrally extend from graphs to directed graphs. Analogosly to Section. we get: Fact: The shortest walk in a positiely weighted (di)graph is always a path. Lemma.9. The weighted distance in a positiely weighted (di)graph satisfies the triangle ineqality. Petr Hliněný, FI MU Brno 7 FI: MA: Distance in Graphs

See an example... a b c The distances between a c and between b c are. What abot the a b distance? Is it 6? No, the distance from a to b in the graph is (traerse the pper path ). Petr Hliněný, FI MU Brno 8 FI: MA: Distance in Graphs

Negatie edge-lengths? What is the reason we are aoiding negatie edge lengths? x y Hence, what is the x y distance this graph? Say, or? No, it is, precisely by Definition.8, and this answer does not sond nice... Hence we hae got a good reason not to consider negatie edges in general. Petr Hliněný, FI MU Brno 9 FI: MA: Distance in Graphs

. Single-sorce shortest paths problem This section deals with the more specific problem of finding the shortest distance between one pair of terminals in a graph (or, from a single sorce to all other ertices). Remark: The coming Dijkstra s algorithm is, on one hand, slightly more inoled than Algorithm.7, bt it is significantly faster in the comptation of single-sorce shortest distances, on the other hand. Dijkstra s algorithm: Is a ariant of graph searching (related to BFS), in which eery discoered ertex carries a ariable keeping its temporary distance the length of the shortest so far discoered walk reaching this ertex from the starting ertex. We always pick from the depository the ertex with the shortest temporary distance. This is becase no shorter walk may reach this ertex (assming nonnegatie edge lengths). At the end of processing, the temporary distances become final shortest distances from the starting ertex (cf. Theorem.). Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

Algorithm.. Compting the single-sorce shortest paths (Dijkstra), i.e. finding the shortest walk from to, or from to all other ertices. inpt < N-ertex graph gien by adjacency mat. G[,] and cor. lengths len[,]; inpt <,, where is the starting ertex and the destination; // state[i] records the ertex processing state, dist[i] is the temporary distance for (i=; i<n; i++) { dist[i] = MAX INT; state[i] = init ; } dist[] = ; depository D = {}; while (state[]!= processed ) { if (D== ) retrn No path ; select m D with minimal dist[m]; // now pdating all neighbors of m and their temporary distances for (i=; i<n; i++) if (G[m,i]) { D = D {i}; if (dist[m]+len[m,i]<dist[i]) { income[i] = m; dist[i] = dist[m]+len[m,i]; } } state[m] = processed ; D = D \ {m}; } retrn A - path of length dist[], stored in incm[] reersely ; Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs Remark: Notice that Algorithm. works as-is also in directed graphs. Example.. An illstration rn of Dijkstra s Algorithm. from to in the following graph.

Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs 7 7 7 6

Fact: The nmber of steps performed by Algorithm. to find the shortest path from to is abot N when N is the nmber of ertices (not so good...). On the other hand, with a better implementation of the depository, one can achiee on sparse graphs rntime almost linear in the nmber of edges. Theorem.. Eery iteration of Algorithm. (since jst after finishing the first while() loop) maintains an inariant that dist[i] is the length of a shortest path from to i sing only those internal ertices x of state[x]== processed. Proof: Briefly sing mathematical indction: In the first iteration, the first ertex m= is picked and processed, and its neighbors receie the correct straight distances (edge lengths). In eery next iteration, the picked ertex m is the nearest nprocessed one to the starting ertex. Assming nonnegatie costs len[,], this certifies that no shorter walk from to m may exist in the graph. On the other hand, any improed path from to an nfinished ertex i passing throgh m has mi as the last edge (since the distance of m is not smaller than of the other finished ertices). Hence dist[i] is pdated correctly in the algorithm. Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs

. Adanced rote planning In some sitations, there is a better alternatie to ordinary Dijkstra s algorithm the Algorithm A which ses a sitable potential fnction to direct the search towards the destination. Wheneer we hae a good sense of direction (e.g. in a topo-map naigation), A can perform mch better! Algorithm A It re-implements Dijkstra with sitably modified edge costs. Let p (x) be a potential fnction giing an arbitrary lower bond on the distance from x to the destination. E.g., in a map naigation, p (x) may be the Eclidean distance from x to. Each directed(!) edge xy of the weighted graph G, w gets a new cost w (xy) = w(xy) + p (y) p (x). The potential p is admissible when all w (xy), i.e. w(xy) p (x) p (y). The aboe Eclidean potential is always admissible. The modified length of any - walk S then is d w G (S) = dw G (S)+p () p (), which is a constant difference from d w G (S)! Hence some S is optimal for the weighting w iff S is optimal for w. Here the Eclidean potential strongly prefers edges in the dest. direction. Petr Hliněný, FI MU Brno FI: MA: Distance in Graphs