Lecture_10_-_Graph

# Lecture_10_-_Graph - Graphs 1 Outline What is a graph...

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

1 Graphs

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

View Full Document
2 2 Outline b What is a graph? b Graph’s applications b Terminology b Graph’s implementation b Breadth first search b Depth first search b Topological sort
3 3 Readings b Textbook s [Carrano] ch13

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

View Full Document
4 4 Linked list 1 parent 1 child
5 5 Tree 1 parent multiple children

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

View Full Document
6 6 Directed graph vertex (node) edge 1 parent 1 child multiple parents multiple children
7 7 Example: travel planning shopping mall direct route 5 cost

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

View Full Document
8 8 Weighted directed graph 5 3 -2 5 1 0
9 9 Undirected graph edges are bidirectional

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

View Full Document
10 10 Complete graph •every pair of vertices has an edge between them •The number of edges : n(n-1)/2 = O(n 2 )
11 11 Path a c d e b A path between two vertices is a sequence of edges that begin at one vertex and end at another. The length of a path p is the number of edges in p. A simple path never visits the same vertex more than once.

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

View Full Document
12 12 Cycle a c g d e b f A cycle is a path that begins and ends at the same vertex. Simple cycle is a simple path that is a cycle. Note that the definition of path and cycle applies to directed graph as well
13 13 Disconnected graph Connected graph : there is a path between every pair of nodes This graph is Disconnected . It has two connected components .

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

View Full Document
14 Applications
15 15 Travel Planning shopping mall direct route 5 cost

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

View Full Document
16 Question b What is the shortest way to travel between A and B? SHORTEST PATH PROBLEM b How to minimize the cost of visiting n cities such that we visit each city exactly once, and finishing at the city where we start from? “TRAVELING SALESMAN PROBLEM
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/02/2011 for the course CS 3211 taught by Professor Dunnowho during the Spring '11 term at National University of Singapore.

### Page1 / 76

Lecture_10_-_Graph - Graphs 1 Outline What is a graph...

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

View Full Document
Ask a homework question - tutors are online