Download - Discrete Structure Chapter 7 Graphs
-
8/10/2019 Discrete Structure Chapter 7 Graphs
1/42
1
GRAPH
Learning Outcomes
Students should be able to:
Explain basic terminology of a graph
Identify Euler and Hamiltonian cycle
Represent graphs using adjacency matrices
-
8/10/2019 Discrete Structure Chapter 7 Graphs
2/42
2
Contents
Introduction Paths and circuits
Matrix representations of graphs
-
8/10/2019 Discrete Structure Chapter 7 Graphs
3/42
3
Introduction to Graphs
DEF: A simple graphG= (V,E) consistsof a non-empty set Vof vertices(ornodes) and a set E(possibly empty) of
edgeswhere each edge is associated witha set consisting of either one or twovertices called its endpoints.
Q: For a set Vwith n elements, how manypossible edges there?
-
8/10/2019 Discrete Structure Chapter 7 Graphs
4/42
4
Terminology
Loop, parallel edges, isolated, adjacent Loop - an edge connects a vertex to itself
Two edges connect the same pair of
vertices are said to be parallel. Isolated vertexunconnected vertex.
Two vertices that are connected by an
edge are called adjacent.An edge is said to be incident on each of
its end points.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
5/42
5
Example of a graph
Vertex set = {u1, u2, u3} Edge set = {e1, e2, e3, e4}
e1, e2, e3 are incident on u1
u2 and u3 are adjacent to u1 e4is a loop
e2and e3are parallel
-
8/10/2019 Discrete Structure Chapter 7 Graphs
6/42
618 November 2014 Graphs and Trees 6
Types of Graphs
Directedordercounts whendiscussing edges
Undirected(bidirectional)
Weightedeach
edge has a valueassociated with it
Unweighted
-
8/10/2019 Discrete Structure Chapter 7 Graphs
7/42
718 November 2014 Graphs and Trees 7
Examples
http://richard.jones.name/google-hacks/google-cartography/google-cartography.htm
-
8/10/2019 Discrete Structure Chapter 7 Graphs
8/42
818 November 2014 Graphs and Trees 8
Special Graphs
Simpledoes not have any loops or paralleledges Complete graphsthere is an edgebetween
every possible tuple of vertices
Bipartite graphV can be partitioned into V1and V2, such that: (x,y)E (xV1 yV2) (xV2 yV1)
Sub graphs G1 is a subset of G2 iff
Every vertex in G1 is in G2 Every edge in G1 is in G2
Connected graphcan get from any vertex toanother via edges in the graph
-
8/10/2019 Discrete Structure Chapter 7 Graphs
9/42
9
Complete Graphs
there is an edgebetween every possibletuple of vertices. |e| = C(n,2) = n. (n-1)/2
-
8/10/2019 Discrete Structure Chapter 7 Graphs
10/42
10
Bipartite graph
A graph is bipartiteif its vertices can bepartitioned into two disjoint subsets U and
V such that each edge connects a vertex
from U to one from V.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
11/42
11
Complete bipartite
A bipartite graph is a complete bipartitegraph if every vertex in U is connected to everyvertex in V. If U has melements and V has n,then we denote the resulting complete bipartite
graph by Km,n. The illustration shows K3,2
-
8/10/2019 Discrete Structure Chapter 7 Graphs
12/42
1218 November 2014 Graphs and Trees 12
Degree of Vertex
Defined as the number of edges attached(incident) to the vertex. A loop is counted twice.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
13/42
1318 November 2014 Graphs and Trees 13
Handshake Theorem
If Gis any graph, then the sum of thedegrees of all the vertices of Gequalstwice the number of edges of G.
Specifically, if the vertices of Gare v1, v2,, v
n, where nis a nonnegative integer,
then:
The total degree of G= d(v1)+d(v2)++d(vn)= 2 (the number of edges of G)
-
8/10/2019 Discrete Structure Chapter 7 Graphs
14/42
1418 November 2014 Graphs and Trees 14
Total degree of a graph is even
Prove that the total of the degrees of allvertices in a graph is even.
Since the total degree equals 2 times of
edges, which is an integer, the sum of alldegree is even.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
15/42
15
Whether certain graphs exist
Draw a graph with the specified propertiesor show that no such graph exists.
(a) A graph with four vertices of degrees
1,1,2, and 3(b) A graph with four vertices of degrees
1,1,3 and 3
(c) A simple graph with four vertices ofdegrees 1,1,3 and 3
-
8/10/2019 Discrete Structure Chapter 7 Graphs
16/42
1618 November 2014 Graphs and Trees 16
Even no. of vertices with odd degree
In any graph, there are an even numberof vertices with odd degree
Is there a graph with ten vertices of
degrees 1,1,2,2,2,3,4,4,4, and 6?
-
8/10/2019 Discrete Structure Chapter 7 Graphs
17/42
17
Learning Outcomes
Students should be able to:Explain basic terminology of a graph
Identify Euler and Hamiltonian cycle
Represent graphs using adjacency matrices
-
8/10/2019 Discrete Structure Chapter 7 Graphs
18/42
1818 November 2014 Graphs and Trees 18
Seven Bridges of Knigsberg
Is it possible for a person to take a walk aroundtown, starting and ending at the same location andcrossing each of the seven bridges exactly once?
-
8/10/2019 Discrete Structure Chapter 7 Graphs
19/42
1918 November 2014 Graphs and Trees 19
Definitions
Terminology - Walk, path, simple path,circuit, simple circuit.
Walk from two vertices is a finite alternating
sequence of adjacent vertices and edges Trivial walk from v to v consists of single vertex
v0e1v1e2envn
-
8/10/2019 Discrete Structure Chapter 7 Graphs
20/42
20
Path
Patha walk that does not contain arepeated edge (may have a repeatedvertex)
v0e1v1e2envn where all the ei are distinct Simple patha path that does not contain
a repeated vertex
v0e1v1e2envn where all the ei and vjaredistinct. e1is represented by {v0,v1}.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
21/42
21
Example - path
Path
v
Simple path
w
-
8/10/2019 Discrete Structure Chapter 7 Graphs
22/42
22
Circuit
Closed walkstarts and ends at samevertex
Circuita closed walk without repeatededge
Simple circuita circuit with no repeatedvertex except first and last
-
8/10/2019 Discrete Structure Chapter 7 Graphs
23/42
23
Examples
Cuircuit
Simple circuit
-
8/10/2019 Discrete Structure Chapter 7 Graphs
24/42
24
Connectedness
Connectednessif there is a walk fromone to the other
Let G be a graph. Two vertices v and w of
G are connected if, and only if, there is awalk from v to w.
The graph G is connected if, and only if,
given any two vertices v and w in G, thereis a walk from v to w.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
25/42
25
Examples
-
8/10/2019 Discrete Structure Chapter 7 Graphs
26/42
2618 November 2014 Graphs and Trees 26
Euler Circuits
A circuit that contains every vertex andevery edge of G.
A sequence of adjacent vertices and edges
that starts and ends at the same vertex, uses every vertex of G at least once, and
uses every edge of G exactly once.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
27/42
2718 November 2014 Graphs and Trees 27
If every vertex of a graph has even degree
then the graph has an Euler circuit.
Contrapositive: if the graph does not havean Euler circuit, then, some vertices havean odd degree.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
28/42
2818 November 2014 Graphs and Trees 28
If every vertex of nonempty graphhas even degree and if graph is
connected, then the graph has anEuler circuit.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
29/42
2918 November 2014 Graphs and Trees 29
Euler Circuit
A graph G has an Euler circuit if, and onlyif, G is connected and every vertex of Ghas even degree.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
30/42
3018 November 2014 Graphs and Trees 30
Hamiltonian Path
A path in an undirected graph which visitseach vertex exactly once.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
31/42
3118 November 2014 Graphs and Trees 31
Hamiltonian Circuit
A simple circuit that includes every vertexof G.
A sequence of adjacent vertices and
distinct edges in which every vertex of Gappears exactly once, except for the firstand last, which are the same.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
32/42
32
Hamiltonian circuit
An Euler circuit for a graph G may not bea Hamiltonian circuit.
An Hamiltonian circuit may not be an Euler
circuit.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
33/42
3318 November 2014 Graphs and Trees 33
Hamiltonian Circuit
Proved simple criterion for determiningwhether a graph has an Euler circuit
No analogous criterion for determining
whether a graph has a Hamiltonian circuit Nor is there an efficient algorithm for
finding such an algorithm
-
8/10/2019 Discrete Structure Chapter 7 Graphs
34/42
34
Hamiltonian Circuit
Finding Hamiltonian circuits
-
8/10/2019 Discrete Structure Chapter 7 Graphs
35/42
3518 November 2014 Graphs and Trees 35
Traveling Salesman Problem
http://en.wikipedia.org/wiki/Traveling_Salesman_Problem
http://en.wikipedia.org/wiki/Traveling_Salesman_Problemhttp://en.wikipedia.org/wiki/Traveling_Salesman_Problemhttp://en.wikipedia.org/wiki/Traveling_Salesman_Problemhttp://en.wikipedia.org/wiki/Traveling_Salesman_Problem -
8/10/2019 Discrete Structure Chapter 7 Graphs
36/42
36
Learning Outcomes
Students should be able to:
Explain basic terminology of a graph
Identify Euler and Hamiltonian cycle
Represent graphs using adjacency matrices
-
8/10/2019 Discrete Structure Chapter 7 Graphs
37/42
3718 November 2014 Graphs and Trees 37
Matrix Representations of Graphs
-
8/10/2019 Discrete Structure Chapter 7 Graphs
38/42
38
Matrices and Digraph
Let G be a directed graph with orderedvertices v1,v2,,vn. The adjacency matrixof G is the n x n matrix A =(aijover the
set of nonnegative integers such thataij= the numbers of arrows from vito vjfor all i,j = 1,2,,n.
-
8/10/2019 Discrete Structure Chapter 7 Graphs
39/42
3918 November 2014 Graphs and Trees 39
Matrices and Connected Components
-
8/10/2019 Discrete Structure Chapter 7 Graphs
40/42
4018 November 2014 Graphs and Trees 40
Counting Walks of Length n
Matrix multiplication
-
8/10/2019 Discrete Structure Chapter 7 Graphs
41/42
4118 November 2014 Graphs and Trees 41
How do these graphs relate?
=
-
8/10/2019 Discrete Structure Chapter 7 Graphs
42/42
Summary