1 / 15

Graphs

Graphs. Contents. Graph Types of Graphs Data Structures to Store Graphs Graph Definitions. Graph. A graph is a pictorial representation of data. A graph connects different vertices and provides a flow of data. Back. Types of Graphs. Definition (undirected, unweighted ):

rufin
Download Presentation

Graphs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphs

  2. Contents.. • Graph • Types of Graphs • Data Structures to Store Graphs • Graph Definitions

  3. Graph • A graph is a pictorial representation of data. • A graph connects different vertices and provides a flow of data. Back

  4. Types of Graphs • Definition (undirected, unweighted): • A Graph G, consists of • a set of vertices, V • a set of edges, E • where each edge is associated with a pair of vertices. • We write: G = (V, E)

  5. Directed Graph: • Same as above, but where each edge is associated with an ordered pair of vertices.

  6. Weighted Graph: • Same as above, but where each edge also has an associated real number with it, known as the edge weight. Back

  7. Data Structures to Store Graphs • Adjacency Matrix Structure • Certain operations are slow using just an adjacency list because one does not have quick access to incident edges of a vertex. • We can add to the Adjacency List structure: • a list of each edge that is incident to a vertex stored at that vertex. • This gives the direct access to incident edges that speeds up many algorithms.

  8. Adjacency Matrix • The standard adjacency matrix stores a matrix as a 2-D array with each slot in A[i][j] being a 1 if there is an edge from vertex i to vertex j, or storing a 0 otherwise. Back

  9. Graph Definitions • A complete undirected unweighted graph • is one where there is an edge connecting all possible pairs of vertices in a graph. The complete graph with n vertices is denoted as Kn. • A graph is bipartite • if there exists a way to partition the set of vertices V, in the graph into two sets V1 and V2 • where V1 V2 = V and V1 V2 = , such that each edge in E contains one vertex from V1 and the other vertex from V2.

  10. Complete bipartite graph • A complete bipartite graph on m and n vertices is denoted by Km,n and consists of m+n vertices, with each of the first m vertices is connected to all of the other n vertices, and no other vertices.

  11. A weighted graph • A weighted graph associates a label (weight) with every edge in the graph. • The weight of a path or the weight of a tree in a weighted graph is the sum of the weights of the selected edges. • The function dist(v,w) • The function dist(v, w), where v and w are two vertices in a graph, is defined as the length of the shortest weight path from v to w. • dist(b,e) = 8

  12. A subgraph • A graph G'= (V', E') is a subgraph of G = (V, E) if V'  V, E'  E, and for every edge e'  E', if e' is incident on v' and w', then both of these vertices are contained in V'.

  13. A simple path • A simple path is one that contains no repeated vertices. • A cycle • A path of non-zero length from and to the same vertex with no repeated edges. • A simple cycle • A cycle with no repeated vertices except for the first and last ones. 6 5 4 1 3 2

  14. A path • A path of length n from vertex v0 to vertex vn is an alternating sequence of n+1 vertices and n edges beginning with vertex v0 and ending with vertex vn in which edge eiincident upon vertices vi-1 and vi. • (The order in which these are connected matters for a path in a directed graph in the natural way.) • A connected graph • A connected graph is one where any pair of vertices in the graph is connected by at least one path Back

  15. THANK YOU Back

More Related