Download presentation
Presentation is loading. Please wait.
Published byHelen Simon Modified over 6 years ago
1
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.
2
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.
3
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).
4
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.
5
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. 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
6
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.
7
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 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 The black spots are the generators.
8
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.
9
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.
10
Then it immediately returns the generator by which the input vertex is coloured.
11
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.
12
The Vnnn-algorithm then lists all the generators within the batch called from storage, and proceeds to calculate the network distance to them.
13
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.
14
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.
15
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.)
16
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.