graphs

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

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

Graphs 1 Graphs

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

View Full Document
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
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.

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

View Full Document
Graphs 4 Example V = {A, B, C, D, E} E = {{A, B}, {A, D}, {C, E}, {D, E}}
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)}

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

View Full Document
Graphs 6 Weighted Graph
Graphs 7 Disconnected Graph

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

View Full Document
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.
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.

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

View Full Document
Graphs 10 Example of a Path
Graphs 11 Example of a Cycle

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

View Full Document
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.
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

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

View Full Document
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.
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,

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## 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
Ask a homework question - tutors are online