1 / 60

Graphs

Graphs. Ed. 2. and 3.: Chapter 12 Ed. 4.: Chapter 13. Graphs Graph ADT - What is a graph? - Graph methods Data structure for graphs - Edge list structure, adjacency list structure, adjacency matrix Graph Traversal - Depth-first search - Breadth-first search Directed graphs.

Sophia
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 • Ed. 2. and 3.: Chapter 12 • Ed. 4.: Chapter 13

  2. Graphs • Graph ADT • - What is a graph? • - Graph methods • Data structure for graphs • - Edge list structure, adjacency list • structure, adjacency matrix • Graph Traversal • - Depth-first search • - Breadth-first search • Directed graphs

  3. The Graph Abstract Data Type

  4. (u, v) u v (Toronto) (Winnipeg) (v, u)

  5. u v (New York) (Winnipeg) (v, u)

  6. self-loop

  7. Graph Methods

  8. Data Structure Exercises 20.1

  9. Data Structure for Graphs

  10. element c1 c2 rank c3

  11. Edge Objects The edge object for an edge e storing element o has data fields for A reference to o · A Boolean indicator of whether e is directed or not · · References to the vertex objects in V associated with the endpoint vertices of e (if the edge e is undir ected) or to the origin and destination vertices of e (if the edge e is directed) · A reference to the position of the edge - object in container E Note: The last data field is the rank of the edge object in the container E if E is a vector.

  12. element With an edge list, some methods (edge - based) are fast while others need some efforts. For example, methods endVertices(), origin(), and destination() are fast because we can access edges directly. end vertex 1 or 0 end vertex

More Related