A (simple) graph is basically a network: it is a (finite) collection of points (called vertices or nodes) combined with a collection of connections between.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Great Theoretical Ideas in Computer Science
Chapter 9 Graphs.
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
TECH Computer Science Graphs and Graph Traversals  // From Tree to Graph  // Many programs can be cast as problems on graph Definitions and Representations.
Introduction This chapter explores graphs and their applications in computer science This chapter explores graphs and their applications in computer science.
Data Structures Using C++
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Applied Discrete Mathematics Week 12: Trees
Graphs and Trees This handout: Trees Minimum Spanning Tree Problem.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Important Problem Types and Fundamental Data Structures
Social Media Mining Graph Essentials.
GRAPH Learning Outcomes Students should be able to:
Data Structures Using C++ 2E
Programming for Geographical Information Analysis: Advanced Skills Online mini-lecture: Introduction to Networks Dr Andy Evans.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
Chapter 2 Graph Algorithms.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Representing and Using Graphs
1 CS104 : Discrete Structures Chapter V Graph Theory.
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9.
Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Data Structures & Algorithms Graphs
Basic Notions on Graphs. The House-and-Utilities Problem.
1 12/2/2015 MATH 224 – Discrete Mathematics Formally a graph is just a collection of unordered or ordered pairs, where for example, if {a,b} G if a, b.
Chapter 10 Graph Theory Eulerian Cycle and the property of graph theory 10.3 The important property of graph theory and its representation 10.4.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Graph Theory and Applications
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Trees Thm 2.1. (Cayley 1889) There are nn-2 different labeled trees
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
Chapter 9: Graphs.
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
1 Data Structures and Algorithms Graphs. 2 Graphs Basic Definitions Paths and Cycles Connectivity Other Properties Representation Examples of Graph Algorithms:
Trees.
Applied Discrete Mathematics Week 14: Trees
Chapter 9 (Part 2): Graphs
Chapter 5 : Trees.
GRAPHS Lecture 16 CS2110 Fall 2017.
Graph theory Definitions Trees, cycles, directed graphs.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Graphs Slides are adopted from “Discrete.
Haim Kaplan and Uri Zwick
Advanced Algorithms Analysis and Design
Enumerating Distances Using Spanners of Bounded Degree
Graphs Chapter 13.
Graphs All tree structures are hierarchical. This means that each node can only have one parent node. Trees can be used to store data which has a definite.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Graph Operations And Representation
Connectivity Section 10.4.
Introduction Wireless Ad-Hoc Network
Chapter 11 Graphs.
ITEC 2620M Introduction to Data Structures
GRAPHS Lecture 17 CS2110 Spring 2018.
Important Problem Types and Fundamental Data Structures
Applied Discrete Mathematics Week 13: Graphs
Chapter 9 Graph algorithms
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

A (simple) graph is basically a network: it is a (finite) collection of points (called vertices or nodes) combined with a collection of connections between those points (called edges or arcs). Set-theoretically, a graph G is described by G = (V,E) where V = {v1, v2, …, vn} is the Vertex Set, and E = {{vi, vj} | vi and vj are connected in G} is the Edge Set. A Digraph (or Directed Graph) is a graph in which each edge is ordered, or has a direction. Graphically this is usually denoted with arrows, and set-theoretically we replace edges {vi, vj} with (vi, vj), ordered pairs (or 2-tuples) of vertices.

Vertices are adjacent if they share an edge, edges are adjacent if they share a vertex. The neighbourhood of a vertex is the set of all adjacent vertices. A walk is a sequence of adjacent edges, e.g. the walk w from 1 to 13: w = ({1,5} , {5,2}, {2,10}, {10,2} {2,11}, {11,12}, {12, 13}). Sometimes walks are a sequence of adjacent vertices. These definitions are nearly equivalent, except for the length of the walk. If a walk does not repeat an edge, it is called a trail. If it does not repeat a vertex, it is called a path. A useful theorem is that if two vertices are connected by a walk, they are also connected by a path with length at most equal to the walk. A walk is closed if it ends on the vertex where it began. A closed trail is called a circuit, and a closed path is called a cycle. If a trail reaches every vertex in a graph, the trail is called Eulerian. If there is an Eulerian circuit, the graph itself is called Eulerian. Any graph with an Eulerian trail can be drawn without taking your pencil off the page.

Graphs can have a multitude of properties: A multigraph can have loops (an edge with the same start and end) and repeated edges (i.e. two vertices can be joined by more than one edge). A connected graph has the property that for any two vertices there exists a walk joining them. A connected component is a maximal subgraph which is connected (a subgraph which is connected and will no longer be connected if any more edges or vertices from the original graph are added).

3) A graph is planar if it can be drawn without edges overlapping except at a vertex. Road networks approximate planar graphs: except for bridges and underpasses, road networks are planar graphs. 4) A forest is a graph which contains no cycles, and a tree is a connected forest (in other words, a forest is made up of trees). Our original graph is a tree if we remove the vertex 9, otherwise it is a forest. A tree is rooted at a specific vertex if that vertex is given an arbitrary priority. A rooted tree has a height which is the longest path in that tree beginning at that root. Rooted trees are used frequently for optimizing search algorithms e.g. binary trees and quadtrees. A vertex in a tree with only one edge is called a leaf. The density of a graph is the measure of how many edges there are per vertex, on average. The higher the density, the more edges there are per vertex. If the density is high, the graph is called dense, and if the density is low it is called sparse. Planar graphs (beyond a small number of vertices) are ALWAYS sparse. The density of a graph is immediately pertinent to computer science with regard to algorithm efficiency.

A graph can be represented by its adjacency matrix or by linked lists. Storing graphs: A graph can be represented by its adjacency matrix or by linked lists. In an adjacency matrix, if the ith vertex is directly connected to the jth vertex by k distinct edges, then the (i,j)-th entry of the matrix is k. In a linked list, every vertex is paired with a list of all the vertices it is connected to. Because linked lists require storing a vertex twice for every edge it occurs in, they require greater space for denser graphs. Because adjacency matrices require the value k = 0 (or k = infinity) whenever two vertices are not connected, they require more space for sparse graphs. 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 Linked List 1 | 5 2 | 3, 4, 5, 10, 11 3 | 2 4 | 2 5 | 1, 2 6 | 7 7 | 6, 8 8 | 7, 13 9 | 10 | 2 11 | 2, 12 12 | 11, 13 13 | 8, 12 Adjacency Matrix

A graph can have a weighting and a colouring. A weighting assigns to each vertex (or an edge-weighting to each edge) a real number, called a weight. A colouring (or ambiguously labelling) assigns to each vertex (or an edge-colouring to each edge) a value chosen from a (finite) set of distinct values. A planar graph drawn in a metric space can use the coordinates of each point, and the metric of the space (e.g. Euclidean) to assign an edge-weighting. A graph is properly coloured (or has a proper colouring) if any path in the graph does not have sequential nodes with the same colour. A walk in a weighted graph can have the weight of the sum of the weights of all the vertices/edges which it traverses. A combination of a weighting and an edge-weighting can be used, for example, to calculate the energy expenditure of moving the location of a point e.g. breaking an atom away from a lattice or molecule.

A Voronoi diagram is a “partition” of a surface with respect to a metric (A.K.A. a distance function) and a set of n sites called generators into n distinct polygons (called Voronoi polygons) whereby every point on the surface is in the polygon corresponding to the generator to which the point is closest. It is not a proper partition because border points (i.e. points on the edges of the polygons) can be equidistant to multiple generators. A network Voronoi diagram is a partitioning of the vertices of an edge-weighted graph with respect to a specific subset of vertices (still called generators) in terms of the weight/distance of the shortest path from the vertex to the nearest generator (i.e. the generator with the least distance from the vertex). Inward- and outward- network Voronoi diagrams are the analogue on digraphs with respect to inward- and outward- distances. Image found at http://home.csis.u-tokyo.ac.jp/~atsu/sanet/GVDN/Slide04.gif Here each vertex has a number added to the distance between points, which is subtracted from the distance to alter the polygons slightly. Different colours represent different polygons. Image found at http://upload.wikimedia.org/wikipedia/commons/8/80/Euclidean_Voronoi_Diagram.png The black spots are the generators.

The Voronoi Nearest Neighbours Algorithm and its groundwork: To run the algorithm on a road network, a network Voronoi diagram is required along with every border point on the network stored and the distance from every point on the network to all of its polygon’s border points saved. Currently (12/01/2015) I (try to) colour every vertex with its generator, then store the vertices in a quadtree. The quadtree should divide a node into four leaves if there exist two non-border-point vertices in it with distinct colours. The vertices are saved with their network distances (i.e. the weights of the shortest paths) to their polygon’s border points. The leaves are indexed with a sequence of bits representing the path to it from the tree’s root vertex. The border points are generated when constructing the Voronoi diagram by checking if adjacent vertices have a different colour and, if so, adding a new vertex on the edge joining them which would be on the border of the Voronoi polygons. Finally, calling the Vnnn algorithm queries the quadtree with an upper bound that determines which leaves to return, then finds the distance to all the generators (i.e. transport stops) in the section of the graph called back by recursively summing the weights between border points and finding the minimal weight from the query point to each generator. The moment the weight surpasses the upper bound, the algorithm stops. This works because traversing between polygons requires crossing a border point.

Stealing the image from before, the Vnnn-algorithm can be visualized as follows: First it takes an input of a query point, at X, and a maximum walking distance.

Then it immediately returns the generator by which the input vertex is coloured.

Then it turns to a batch called from the quadtree of points within the Euclidean (“straight line”) distance of the maximum walking distance from X. In practice, because the nodes of the quadtree are square, we would really be returning the smallest node containing this circle. This works because the straight line distance provides an upper bound for how far the user is interested in extending the query from the query point X i.e. any point on the network within the maximum walking distance will be within this circle.

The Vnnn-algorithm then lists all the generators within the batch called from storage, and proceeds to calculate the network distance to them.

Calculating the network distance to a point outside of X’s Voronoi polygon is done by calculating the minimum of the distance from X to a border point of X’s polygon plus the distance from said border point to the generator.

This distance calculation is defined recursively so that, for example, on our edited map, finding the distance from X to Y, Vnnn-Algorithm finds the minimum distance of the paths going from X to a border point of its polygon plus paths going from said border point to a border point of Y’s polygon plus the distance from the latter border point to Y.

Creating the quadtree is done by labelling each vertex in the graph with an ID representing which leaf of the tree it is in. The ID is found by subdividing the map into quadrants and appending the ID of the vertices in each quadrant accordingly. The subdivisions reiterate until the quadrants (the leaves of the quadtree) are small enough or until all the vertices in the quadrant which are not border points have the same generator. (Currently (12/01/2015) because of the method being slow and/or having an infinite loop, and because of not needing it, the latter criterion is not being assessed in ID construction.)

If a vertex is in the upper-left corner of a division of a quadrant, its ID is appended with 00 at the right end; similarly 01 for upper-right, 10 for lower-left, and 11 for lower-right.