L Graph I
L Graph I
Lecture Outline
• Graphs
– Undirected Graph
– Directed Graph
– Graph Models
– Graph Terminologies
– Degree of a vertex
• Graph
– Directed
– Undirected
Graphs
• Graph
• Directed Edge Un-directed
Edge
a b a b
terminal
Initial
vertex
vertex
Ordered pair Un-ordered pair
( a, b) {a, b}
7
Definition - Graphs
– A graph G = (V, E) is defined by a set of vertices V , and a set of
edges E consisting of ordered or unordered pairs of vertices
from V.
– Thus a graph G = (V, E)
• V = set of vertices
• E = set of edges = subset of V V
8
Graphs
Graphs
Simple Graphs
– Represent whether two people know each other, that is, whether
they are acquainted.
– Each person in a particular group of people is represented by a
vertex.
– Undirected edge is used to connect two people when these people
know each other.
– No multiple edges are used.
– Usually no loops are used. (If we want to include the notion of self-
knowledge, we would include loops.)
Example
Graph Models: An Influence Graph
A3
A4
Graph Models: Precedence graph
• Each statement is represented by a vertex
• There is an edge from one statement to a second
statement if the second statement cannot be executed
before the first statement.
Graph Terminologies
– Adjacent:
Let G be an undirected graph with edge set E. Let e ∈ E be (or map
to) the pair {u,v}. Then we say:
deg(a) = 3
deg(b) = 5
deg(c) = 5
deg(d) = 5
deg(e) = 0 (isolated vertex)
G1
Example
• What is the degree of each vertex of the following graph?
A1 A2
A3
A4
deg(A1) = 2 deg(a) = 4
deg(A2) = 3 deg(b) = 6
deg(A3) = 2 deg(c) = 1
deg(A4) = 3 deg(d) = 5
deg(e) =6
Handshaking Theorem
– Let G be an undirected (simple, multi-, or pseudo-) graph with
vertex set V and edge set E. Then
deg(v) 2 E
vV
deg(a) = 3 deg(a) = 4
deg(b) = 5 deg(b) = 6
deg(c) = 5 deg(c) = 1
deg(d) = 5 deg(d) = 5
deg(e) =0 deg(e) =6
deg
(v) deg (v) E
• The first
vV
sum countsvVthe number of incoming
edges over all vertices and the second sum
counts the number of outgoing edges over all
vertices Both sums must be |E|.
Chapter Exercise
• Chapter # 10
Topic # 10.1
• Q – 1,3,4,5,6,7,8,9,13,16,19,21,22
Topic # 10.2
• Q -1,2,3,4,7,8,9,10,21,22,23,24,27