0% found this document useful (0 votes)
2 views

Lecture 7 Graphs

This document introduces the basic concepts of graph theory, including the history of graphs and their applications in various fields. It outlines five main categories of graphs: simple graphs, multigraphs, pseudographs, directed graphs, and directed multigraphs, along with their definitions and examples. Additionally, it covers graph terminology, including adjacency, degree of vertices, and theorems related to graph properties.

Uploaded by

nuworsucollins25
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lecture 7 Graphs

This document introduces the basic concepts of graph theory, including the history of graphs and their applications in various fields. It outlines five main categories of graphs: simple graphs, multigraphs, pseudographs, directed graphs, and directed multigraphs, along with their definitions and examples. Additionally, it covers graph terminology, including adjacency, degree of vertices, and theorems related to graph properties.

Uploaded by

nuworsucollins25
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

LECTURE 7

INTRODUCTION TO
GRAPHS

Fall 2002 CMSC 203 - Discrete Structures 1


HISTORY
• Basic ideas were introduced in the eighteenth century
by Leonard Euler (Swiss mathematician)

• Euler was interested in solving the Königsberg bridge


problem (Town of Königsberg is in Kaliningrad, Republic
of Russia)

• Graphs have several applications in many areas:


– Study of the structure of the World Wide Web
– Shortest path between 2 cities in a transportation network
– Molecular chemistry
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 2
of Computer Science, Ch. 8 (part 1): Graphs
KÖNIGSBERG
BRIDGE PROBLEM

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 3
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs
• There are 5 main categories of graphs:

– Simple graph
– Multigraph
– Pseudograph
– Directed graph
– Directed multigraph

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 4
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

– Definition 1

A simple graph G = (V,E) consists of V, a nonempty


set of vertices, and E, a set of unordered pairs of
distinct elements of V called edges.

– Example: Telephone lines connecting computers in


different cities.

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 5
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

– Definition 2:

A multigraph G = (V,E) consists of a set E of


edges, and a function f from E to {{u,v} | u,
v  V, u  v}. The edges e1 and e2 are called
multiple or parallel edges if f(e1) = f(e2).

– Example: Multiple telephone lines


connecting computers in different cities.
Dr. Djamel Bouchaffra
CSE 504 Discrete Structures & Foundations
6
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d
Detroit
Chicago
New York
San Fransisco

Washington

Denver

Los Angeles
A Computer network with multiple lines

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 7
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

– Definition 3:

A pseudograph G = (V,E) consists of a set V of vertices,


a set E of edges, and a function f from E to {{u,v} | u, v
 V}. An edge is a loop if f(e) = {u,u} = {u} for some u 
V.

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 8
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d
Detroit
Chicago
New York
San Fransisco

Washington

Denver

Los Angeles
A Computer network with diagnostic lines

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 9
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

– Definition 4:

A directed graph (V,E) consists of a set of


vertices V and a set of edges E that are
ordered pairs of elements of V.

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 10
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d
Detroit
Chicago
New York
San Fransisco
Host

Washington

Denver

A Communication network with


Los Angeles one-way telephone lines

This example shows that the host computer can only


receive data from other computer, it cannot emit
11
Introduction to Graphs Cont’d

– Definition 5:

A directed multigraph G = (V,E)


consists of a set V of vertices, a set E of
edges, and a function f from E to {{u,v}
| u, v  V}. The edges e1 and e2 are
multiple edges if f(e1) = f(e2).
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 12
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d
Detroit
Chicago
New York
San Fransisco

Washington

Denver

Los Angeles A Computer network with multiple


one-way telephone lines

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 13
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

• Modeling graphs

– Example: Competition between species in


an ecological system can be modeled using
a niche overlap graph.

An undirected edge connect two vertices if


the two species represented by these
vertices compete for food.
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 14
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d
Racoon
Owl
Hawk

Opossum Squirrel

Crow

Mouse
Woodpecker
Shrew

A niche overlap graph


CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 15
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

– Example: Influence of one person in society

• A directed graph called an influence


graph is used to model this behavior

• There is a directed edge from vertex a to


vertex b if the person represented by a
vertex a influences the person
represented by vertex b.
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 16
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

Linda Brian

Deborah Fred Yvonne

An influence graph
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 17
of Computer Science, Ch. 8 (part 1): Graphs
Introduction to Graphs Cont’d

– Example:

The World Wide Web can be modeled


as a directed graph where each web
page is represented by a vertex and
where an edge connects 2 web pages if
there is a link between the 2 pages

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 18
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY
• Basic Terminology

– Goal: Introduce graph terminology in order to further classify


graphs

– Definition 1:

Two vertices u and v in an undirected graph G are called


adjacent (or neighbors) in G if {u,v} is an edge of G. If e = {u,v},
the edge e is called incident with the vertices u and v. The edge
e is also said to connect u and v. The vertices u and v are called
endpoints of the edge {u,v}.
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 19
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY CONT’D

– Definition 2:

The degree of a vertex in an undirected


graph is the number of edges incident
with it, except that a loop at a vertex
contributes twice to the degree of that
vertex. The degree of the vertex v is
denoted by deg(v).
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 20
of Computer Science, Ch. 8 (part 1): Graphs
– Example: What are the degrees of the vertices in the
graphs G and H?
b c d a b c

a f e g e d

G H

deg(a)  2
Solution: deg(b) deg(c) deg(f) 4 deg(a) 4
 deg(b) deg(e) 6

In G deg(d) 1 In H 
deg(e)  3 deg(c) 1
 deg(d) 5
deg(g) 0
GRAPH TERMINOLOGY CONT’D
– Theorem 1:

The handshaking theorem


Let G = (V,E) be an undirected graph with e edges.
Then
2 e   deg( v ).
vV

(Note that this applies even if multiple edges &


loops are present.)
(WHY?) Every edge connects 2 vertices

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 22
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY CONT’D

– Example: How many edges are there in


a graph with ten vertices each of
degree 6 ?

Solution: Since the sum of the degrees


of the vertices is 6*10 = 60  2e = 60.
Therefore, e = 30
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 23
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY CONT’D
– Theorem 2:

An undirected graph has an even number of vertices of odd degree.

Proof: Let V1 and V2 be the set of vertices of even degree and the set
of vertices of odd degree, respectively, in an undirected graph
G = (V,E). Then 2 e  deg( v )  deg( v ) 
   deg( v ).
vV vV1 vV2

Since deg(v) is even for v  V1, the first term in the right-hand side of
the last equality is even. Furthermore, the sum of the two terms on
the right-hand side of the last equality is even, since this sum is 2e.
Hence, the second term in the sum is also even. Since all the terms in
this sum are odd, there must be an even number of such terms. Thus,
there are an even number of vertices of odd degree.
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 24
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY CONT’D

– Definition 3:

When (u,v) is an edge of the graph G with


directed edges, u is said to be adjacent to v
and v is said to be adjacent from u. The
vertex u is called the initial vertex of (u,v),
and v is called the terminal or end vertex of
(u,v). The initial vertex and terminal vertex of
a loop are the same.
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 25
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY CONT’D

– Definition 4:
In a graph with directed edges the in-degree of
a vertex v, denoted deg-(v), is the number of
edges with v as their terminal vertex. The out-
degree of v, denoted by deg+(v), is the number
of edges with v as their initial vertex.
(Note that a loop at a vertex contributes 1 to
both the in-degree and the out-degree of this
vertex)
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 26
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY CONT’D
– Example: Find the in-degree and the out-degree of each
vertex in the graph G
a b c

e f

Solution: The in-degree of G are: deg-(a) = 2, deg-(b) = 2, deg-


(c) = 3, deg-(d) = 2, deg-(e) = 3, and deg-(f) = 0.
The in-degree of G are: deg+(a) = 4, deg+(b) = 1, deg+(c) = 2,
deg+(d) = 2, deg+(e) = 3, and deg+(f) = 0

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 27
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH TERMINOLOGY CONT’D

– Theorem 3:

Let G = (V,E) be a graph with directed


edges. Then

 deg
vV

( v )  ( v ) | E | .
deg 

vV

CSE 504 Discrete Structures & Foundations


Dr. Djamel Bouchaffra 28
of Computer Science, Ch. 8 (part 1): Graphs
GRAPH - TREE

– TREE:
• Connected graph without circuits is called a tree
• Graph is called a forest when it does not have circuits
• A vertex of degree 1 is called a terminal vertex or a leaf, the
other vertices are called internal nodes
• Decision tree
• Syntactic derivation tree
• Any tree with more than one vertex has at least one vertex of
degree 1
• Any tree with n vertices has n – 1 edges
• If a connected graph with n vertices has n – 1 edges, then it is a
tree
CSE 504 Discrete Structures & Foundations
Dr. Djamel Bouchaffra 29
of Computer Science, Ch. 8 (part 1): Graphs
SUMMARY
• Graph Theory
• Simple Graph
• Connected / Unconnected Graph
• Pseudo
Contact

Phone:
Email:
[email protected] ssamnot@
hotmail.com
Skype: snorteygtuc
Website: gtuc.edu.gh

....Linking Learners Everywhere © 2013 All Rights Reserved

You might also like