graphs - Graphs Graphs 1 Chapter Outline Graph Terminology...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
Graphs 1 Graphs
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs 2 Chapter Outline Graph Terminology The Graph ADT and Edge Class Implementing the Graph ADT Traversals of Graphs Application of Graph Traversals Algorithms Using Weighted Graphs
Background image of page 2
Graphs 3 What is a Graph A graph is a set of vertices and a set of edges that connect pairs of distinct vertices. Mathematically we say: G = ( V , E ) where E V × V A graph may be directed or undirected. In an undirected graph, ( u , v ) E iff ( v , u ) E   This implies that there are two edges ( u , v ) and ( v , u ) in an undirected graph. This is not correct, instead the edges of an undirected graph are simply pairs, not ordered pairs. Visually we represent the vertices as points (or labeled circles) and the edges as lines joining the vertices.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs 4 Example V = {A, B, C, D, E} E = {{A, B}, {A, D}, {C, E}, {D, E}}
Background image of page 4
Graphs 5 A Directed Graph V = {A, B, C, D, E} E = {(A, B), (B, A), (B, E), (D, A), (E, A), (E, D), (E, C)}
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs 6 Weighted Graph
Background image of page 6
Graphs 7 Disconnected Graph
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs 8 Equivalence of Graphs The numbering of the vertices, and their physical arrangement are not important. The following is the same graph as the previous slide.
Background image of page 8
Graphs 9 Graph Definitions Path A sequence of vertices in which each successive vertex is adjacent to its predecessor. A simple path the vertices and edges are distinct. A cycle is a simple path in which the first and final vertices are the same. Connected graph A graph if there is a path from every vertex to every other vertex. A graph that is not connected, consists of connected components.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs 10 Example of a Path
Background image of page 10
Graphs 11 Example of a Cycle
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs 12 Relationship Between Graphs and Trees A tree is a special case of a graph. Any connected graph which does not contain cycles can be considered a tree. Any node can be chosen to be the root.
Background image of page 12
Graphs 13 Application of Graphs Determine network connectivity. Schedule courses in accordance with prerequisite requirements. Finding the shortest (or least cost) path. Network routing Travel planning
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs 14 Abstract Representation of a Graph We will consider the vertices to be the integers from 0 to | V |-1. Operations on a graph: Create a graph of n vertices. Insert an edge Remove an edge Query the existence of an edge Iterate over the vertices adjacent to a given vertex.
Background image of page 14
Graphs 15 Design of the Graph class Function Behavior int get_num_v() const  Return the number of vertices. bool is_directed() const  Return true if this is a directed graph. Insert a new edge into the graph. virtual bool is_edge(int source,  
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 77

graphs - Graphs Graphs 1 Chapter Outline Graph Terminology...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online