This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: ENGG1007 oundations of Computer Science Foundations of Computer Science Graphs Graphs Prof. Francis Chin, Dr SM Yiu November 4/5, 2010 (Chapter 9) 1 ENGG1007 FCS hat is a Graph? hat is a Graph? What is a Graph? What is a Graph? A simple graph simple graph G = ( V , E ) consists of the set of ertices (nodes points) ertices (nodes points) and ¾ V , the set of vertices (nodes, points) vertices (nodes, points) , and ¾ E , the set of edges (lines edges (lines) Undirected graphs Undirected graphs are graphs where edges have no d direction ( unordered pairs of V ). Example: = {a, b, c, d, e} a c V {a, b, c, d, e} E = {{a,b}, {a, c}, {c, d}, {c, e}, {d, e}} Directed graphs Directed graphs are graphs where edges have directions, b e i.e., E consists of ordered pairs of V Example: = {u x y z} x y 2 V {u, x, y, z} E = {(x, y), (x, z), (y, u), (z, x), (z, u)} z u ENGG1007 FCS imple imple raphs and raphs and ultigraphs ultigraphs Simple Simple Graphs and Graphs and Multigraphs Multigraphs Simple graphs Simple graphs at most one edge between any pair of ertices vertices. Multi Multigraphs graphs having multiple edges between the same pair of vertices, or even with selfloops. Examples: ¾ Multiple roads between same pair of cities x y If x , y are two vertices, and e = { x , y } is in E , then ¾ x and y are adjacent adjacent ¾ e is incident incident with x and y ¾ x and y are the endpoints endpoints of e Degree ( v ) = number of edges incident with vertex v z u 3 g ( ) g ¾ deg ( y ) = 2 , deg ( u ) = 2 , deg ( x ) = 3 , deg ( z ) = 5 ENGG1007 FCS raph properties: Degrees raph properties: Degrees Graph properties: Degrees Graph properties: Degrees By pigeon hole principle, there exist two vertices with the ame degree same degree. For an undirected graph G = ( V , E ): x y e.g. sum of degrees = 3+2+5+2 = 12,  E  = 6   2 ) deg( E v V v = ∑ ∈ z u Proof: every edge is counted twice in counting degrees. Fact: Any undirected graph has an even number of odd degree vertices (as the sum of degrees is even) For a directed graph G = ( V , E ): 4   ) ( deg ) ( deg E v v V v V v = = ∑ ∑ ∈ + ∈ − ENGG1007 FCS ther Applications ther Applications raph Models raph Models Other Applications Other Applications Graph Models Graph Models Acquaintanceship vertices = people edges = two people know each other Competition (tournaments) vertices = teams edges = matches (directed edges to show winners and losers) Game tree vertices = state of the game dge ove 5 Edge = move ENGG1007 FCS ame tree ame tree ic ic c e Game tree Game tree Tic Tic tac tac toe toe Vertices = state of the game s 1 s 2 s 3 represented by (position, whose move) position = (s 1 , s 2 , s 3 , s 4 , s 5 , s 6 , s 7 , s 8 , s 9 ), where s ∈ { x, 0,  } s 4 s 5 s 9 s 6 s 8 s 7 i Example: initial state, v 0 = ( ( , , , , , , , ,  ), 0 ) ( ( x 0 0 0 x x ) X v 5 = ( ( x, , 0, 0, 0, , x, ,  ), x ) What are valid vertices? Assuming 0 is the first move, X say v i = ( ( x, , x, 0, 0, , x, ,  ), x ) ?= ( ( x, , x, 0, 0, , x, ,  ), x ) ?...
View
Full
Document
This note was uploaded on 02/10/2011 for the course ENGG 1007 taught by Professor Unknown during the Spring '11 term at HKU.
 Spring '11
 Unknown
 Computer Science

Click to edit the document details