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

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

View Full Document Right Arrow Icon
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
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
Background image of page 2
3 3 Readings b Textbook s [Carrano] ch13
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 4 Linked list 1 parent 1 child
Background image of page 4
5 5 Tree 1 parent multiple children
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 6 Directed graph vertex (node) edge 1 parent 1 child multiple parents multiple children
Background image of page 6
7 7 Example: travel planning shopping mall direct route 5 cost
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 8 Weighted directed graph 5 3 -2 5 1 0
Background image of page 8
9 9 Undirected graph edges are bidirectional
Background image of page 9

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

View Full DocumentRight Arrow Icon
10 10 Complete graph •every pair of vertices has an edge between them •The number of edges : n(n-1)/2 = O(n 2 )
Background image of page 10
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.
Background image of page 11

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

View Full DocumentRight Arrow Icon
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
Background image of page 12
13 13 Disconnected graph Connected graph : there is a path between every pair of nodes This graph is Disconnected . It has two connected components .
Background image of page 13

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

View Full DocumentRight Arrow Icon
14 Applications
Background image of page 14
15 15 Travel Planning shopping mall direct route 5 cost
Background image of page 15

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

View Full DocumentRight Arrow Icon
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
Background image of page 16
Image of page 17
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 Right Arrow Icon
Ask a homework question - tutors are online