Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
1
13.1 Introduction to graphs
Graphs can model relations between pairs of objects and are fundamental in Discrete Mathematics.
In the previous lectures we covered directed graphs, now let’s spend some time with undirected graphs!
[Def] A graph G = ( V , E ) consists of a non-empty set of vertices (nodes) V and a set of edges E.
a
b c
da
b c
d
2
13.1 Introduction to graphs
A vertex is usually represented by a dot with a label.
Each edge in E is a set of two vertices from V and is drawn as a line connecting the two vertices.
each edge has either 1 or 2 vertices associated with it, called endpoints
edge connects its endpoints
a
b c
d
a
b c
d
3
13.1 Introduction to graphs
A vertex is usually represented by a dot with a label.
Each edge in E is a set of two vertices from V and is drawn as a line connecting the two vertices.
each edge has either 1 or 2 vertices associated with it, called endpoints
edge connects its endpoints
An infinite graph is a graph withinfinite number of vertices or edges.
A finite graph is a graph with a finite vertex set and a finite edge set.
a
b c
d
a
b c
d
4
13.1 Introduction to graphs
In directed graph (digraph) all edges have direction.edge (a,b) starts at a and ends at b.
a
b c
da
b c
d
directed graphundirected graph
a b
undirected edge {a,b}
a b
directed edge (a,b)
5
13.1 Introduction to graphs
[Def] A simple (directed) graph is a graph in which each edge connects two different vertices (no loops) and where no two edges connect the same pair of vertices
a
b c
d
a
b c
d
a
b c
d
a
b c
d
simple graphs
6
13.1 Introduction to graphs
[Def] A multigraph is an undirected graph in which multiple edges connect the same vertices, but no loops
[Def] A directed multigraph is a directed graph in which multiple edges connect the same vertices, and loops are allowed.
a
b c
d
a
b c
d
a
b c
d
a
b c
d
7
13.1 Introduction to graphs
[Def] A multigraph is an undirected graph in which multiple edges connect the same vertices, but no loops
a
b c
d
a
b c
d
a
b c
dSome authors allow multigraphs to have loops, while others call these pseudographs, reserving the term multigraph for the case with no loops.
a
b c
d
8
13.1 Introduction to graphs
[Def] A multigraph is an undirected graph in which multiple edges connect the same vertices, but no loops
a
b c
da
b c
d
a
b c
d
a
b c
d[Def] A directed multigraph is a directed graph in which multiple edges connect the same vertices, and loops are allowed.
9
13.1 Introduction to graphs
edge of multiplicity m: m different undirected edges are associated to the same pair of different vertices
a
b c
d
edge {b,d} has multiplicity 3
edge {a,c} has multiplicity 2
10
13.1 Introduction to graphs
[Def] A pseudograph is an undirected graph that may include loops, and possibly multiple edges connecting the same pair of vertices or a vertex to itself.
a
b
d
c
11
13.1 Introduction to graphs
[Def] A mixed graph is a graph with both undirected and directed edges.
a
b
d
c
12
13.1 Introduction to graphs
Type Edges Multiple edges
allowed?
Loops allowed?
Simple graph undirected No No
Multigraph undirected Yes No
Pseudograph undirected Yes Yes
Simple directed graph
directed No No
Directed multigraph
directed Yes Yes
Mixed graph both types Yes Yes
Graph terminology:
13
13.1 Introduction to graphs
Graph are used in a wide variety of models. When we build a graph model we need to answer the following three key questions:
● Are the edges directed, undirected, or both?
● If the graph is undirected: are multiple edges or loops present?If the graph is directed: are multiple edges present?
● Are loops present?
14
13.1 Introduction to graphs
Social Networks
Graphs are uses to model social structures based on different kinds of relationships between people or groups of people.
vertices: individuals (organizations)edges: relationships between individuals(organizations)
15
13.1 Introduction to graphs
Social Networks: Acquaintanceship / friendship graphs
vertices: individualsedges: friendship/acquantanceship between individuals
Alex
Samantha
Maria
Luis
Julia
Tom
Juan Olivia
16
13.1 Introduction to graphs
Social Networks: Acquaintanceship / friendship graphs
● no loops (not including self-knowledge) / loops (including)● no multiple edges
vertices: individualsedges: friendship/acquantanceship between individuals
Alex
Samantha
Maria
Luis
Julia
Tom
Juan Olivia
17
13.1 Introduction to graphs
Social Networks: Collaboration graphs
vertices: individualsedges: between individuals who work together in a particular way
MariaFred
Tom
Juan Olivia
18
13.1 Introduction to graphs
Social Networks: Collaboration graphs
● no loops ● no multiple edgesi.e. simple graph
vertices: individualsedges: between individuals who work together in a particular way
MariaFred
Tom
Juan Olivia
19
13.1 Introduction to graphs
Social Networks: Collaboration graphs
The Hollywood graph is a collaboration graph that represents actors by vertices and connects two actors if they the have worked together on a movie or TV show.
It is a huge graph with > 1.5 million vertices (as of 2011)
20
13.1 Introduction to graphs
Communication Networks
Different communications networks can be modeled by graphs using vertices to represent devices and edges for particular type of communications links of interest.
21
13.1 Introduction to graphs
Communication Networks
Different communications networks can be modeled by graphs using vertices to represent devices and edges for particular type of communications links of interest.
vertices: data centersedges: communication links
Los Angeles
San FranciscoChicago
Detroit
Denver
New York
Washington
Computer network with diagnostic links
feedback for diagnostic purposes
22
13.1 Introduction to graphs
Communication Networks
Different communications networks can be modeled by graphs using vertices to represent devices and edges for particular type of communications links of interest.
vertices: data centersedges: communication links
Los Angeles
San FranciscoChicago
Detroit
Denver
New York
Washington● loops ● multiple edgesi.e. pseudograph
Computer network with diagnostic links
23
13.1 Introduction to graphs
Transportation Networks
Graphs can be used to model road, air, rail, shipping ...etc networks.
Airline routes:
vertices: airportsedge: direct flight (and back) – usually both ways
undirected multigraph
24
Delta Airlines routes
Source: https://blogs.cornell.edu/info2040/2015/09/11/an-analysis-of-delta-route-maps/
25
Connected World: Untangling the Air Traffic Network
Source: http://www.martingrandjean.ch/connected-world-air-traffic-network/
26
13.1 Introduction to graphs
Transportation Networks
Graphs can be used to model road, air, rail, shipping ...etc networks.
Road networks:
vertices: intersectionsedges: roads
One-way roads: directed edgesTwo-way roads: undirected edges
mixed graph
27
Topology of a Network Data Model
Source: https://people.hofstra.edu/geotrans/eng/methods/nettopology.html
28
13.1 Introduction to graphs
Tournaments
Graphs can be used to model different kinds of tournaments
vertices: players / teamsedges: one round of play / tournament
directed / undirected edges: depends
If directed: shows who won
29
13.1 Introduction to graphs
Tournaments: single-elimination tournament
vertices: players / teamsedges: one roundundirected: each contestant is eliminated after one loss
Team 1
Team 2
Team 3
Team 4
Team 1
Team 4
Team 1
Team 5
Team 6
Team 7
Team 8
Team 6
Team 7
Team 7
Team 7
30
13.1 Introduction to graphs
Tournaments: single-elimination tournament
vertices: players / teamsedges: one roundundirected: each contestant is eliminated after one loss
● no loops● no multiple edges i.e. simple graph
Team 1
Team 2
Team 3
Team 4
Team 1
Team 4
Team 1
Team 5
Team 6
Team 7
Team 8
Team 6
Team 7
Team 7
Team 7
31
[Def] Two vertices u and v in an undirected graph G are called adjacent (neighbors) in G if u and v are endpoints of an edge e of G.Such an edge is called incident with vertices u and v, and is said to connect u and v.
a
b c
d
adjacent vertices
incident with vertices a and c
connects b and d
13.1 Introduction to graphs
32
[Def] neighborhood of v, N(v), is the set of all neighbors of v.
a
b c
d
adjacent vertices
13.1 Introduction to graphs
33
[Def] neighborhood of v, N(v), is the set of all neighbors of v.
a
b c
d
adjacent vertices
neighborhood of a: N(a) = {b,c} ,neighborhood of b: N(b) = {a,d} ,neighborhood of c: N(c) = {a} ,neighborhood of d: N(d) = {b} ,
13.1 Introduction to graphs
34
[Def] the degree of a vertex in 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.
denotaion: deg(v)
a
b c
d
13.1 Introduction to graphs
35
[Def] the degree of a vertex in 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.
denotaion: deg(v)
a
b c
d
deg(a) = 2 deg(c) = 1deg(b) = 2+2 = 4 deg(d) = 1
13.1 Introduction to graphs
36
[Def] the degree of a vertex in 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.
denotaion: deg(v)
a
b c
d
A vertex of degree 0 is called isolated.A vertex of degree 1 is called pendant.
pendant
pendant
13.1 Introduction to graphs
37
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or2m=∑v∈V
deg(v)
13.1 Introduction to graphs
∑v∈V
deg(v)=2|E|
38
a
b c
dm = 4deg(a) = 2, deg(b) = 4, deg(c) = 1, deg(d) = 12 4 = 2 + 4 + 1 + 1 8 = 8
13.1 Introduction to graphs
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
39
Why is it so?
13.1 Introduction to graphs
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
40
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or
Why is it so?
● each non-loop edge contributes 2 to the sum of the degrees ( 1 for each of adjacent vertices)
● each loop contributes 2 to the sum of the degrees (only for one vertex)
2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
13.1 Introduction to graphs
41
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or
[Theorem] An undirected graph has an even number of vertices of odd degree.
2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
13.1 Introduction to graphs
42
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or
[Theorem] An undirected graph has an even number of vertices of odd degree.
Proof: Let V1 and V
2 be the set of vertices of even
degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m
13.1 Introduction to graphs
2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
43
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or
[Theorem] An undirected graph has an even number of vertices of odd degree.
Proof: Let V1 and V
2 be the set of vertices of even
degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m
2m=∑v∈V
deg(v)=∑v∈V 1
deg(v)+∑v∈V 2
deg(v)
13.1 Introduction to graphs
2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
44
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or
[Theorem] An undirected graph has an even number of vertices of odd degree.
Proof: Let V1 and V
2 be the set of vertices of even
degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m
2m=∑v∈V
deg(v)=∑v∈V 1
deg(v)+∑v∈V 2
deg(v)even
even
13.1 Introduction to graphs
2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
45
[Theorem] The Handshaking TheoremLet G = (V,E) be an undirected graph with m edges.
Then or
[Theorem] An undirected graph has an even number of vertices of odd degree.
Proof: Let V1 and V
2 be the set of vertices of even
degree and odd degree respectively, in a undirected graph G = (V,E) with m edges. |E| = m
2m=∑v∈V
deg(v)=∑v∈V 1
deg(v)+∑v∈V 2
deg(v)even
must be even q.e.d.
even
13.1 Introduction to graphs
2m=∑v∈V
deg(v) ∑v∈V
deg(v)=2|E|
46
We can take a directed graph and convert to to undirected graph by ignoring the directions.Such a graph is called underlying undirected graph.
The directed graph and its underlying undirected graph have the same number of edges.
a
b c
d a
b c
d
13.1 Introduction to graphs
47
Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?
b) What does the neighborhood of a vertex represent?
c) What do isolated and pendant vertices represent?
13.1 Introduction to graphs
48
Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?
the degree of a vertex represents the number of times the actor worked together with other actors on a movie or a TV show
b) What does the neighborhood of a vertex represent?
c) What do isolated and pendant vertices represent?
13.1 Introduction to graphs
49
Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?
b) What does the neighborhood of a vertex represent?
N(a) represents the list of all actors actor a worked with on a movie or a TV show.
c) What do isolated and pendant vertices represent?
13.1 Introduction to graphs
50
Example: recall Hollywood graph.a) What does the degree of a vertex represent in the Hollywood graph?
b) What does the neighborhood of a vertex represent?
c) What do isolated and pendant vertices represent?
Isolated vertices represent actors who didn't work with any other actor (present in the graph) on a movie or a TV show.Pendant vertices represent only actors with one collaboration only.
13.1 Introduction to graphs
51
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
13.1 Introduction to graphs
52
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.
13.1 Introduction to graphs
53
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.
deg(v1) = 0, deg(v
2) = 0
v1 v
2
2 vertices:
13.1 Introduction to graphs
54
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.
deg(v1) = 1, deg(v
2) = 1
v1 v
2
2 vertices:
13.1 Introduction to graphs
55
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.
deg(v1) = 0, deg(v
2) = 0, deg(v
3) = 0,
v1 v
2
3 vertices:
v3
13.1 Introduction to graphs
56
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.
deg(v1) = 1, deg(v
2) = 1, deg(v
3) = 0,
v1 v
2
3 vertices:
v3
13.1 Introduction to graphs
57
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.
deg(v1) = 2, deg(v
2) = 1, deg(v
3) = 1,
v1 v
2
3 vertices:
v3
13.1 Introduction to graphs
58
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
Solution: recall that simple graphs are undirected graphs that have no loops, no multiple edges.
deg(v1) = 2, deg(v
2) = 2, deg(v
3) = 2,
v1 v
2
3 vertices:
v3
13.1 Introduction to graphs
59
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
v1 v
2
v1 v
2
v1 v
2
v3
v1 v
2
v3
v1 v
2
v3
v1 v
2
v3
...
...
...
13.1 Introduction to graphs
60
Example: show that in a simple graph with at least two vertices there must be two vertices that have the same degree.
v1 v
n+1
...
13.1 Introduction to graphs
vn
v1 v
n+1v
n
v1 v
n+1v
n
v1 v
n+1v
n
61
[Def]: A graph with all the vertices of the same degree is called a regular graph.
In a d-regular graph, all the vertices have degree d.
13.1 Introduction to graphs
3-regular graphs
62
[Def]: A graph H = (VH, E
H) is a subgraph of a graph G =
(VG, E
G) if V
H V
G and E
H E⊆
G.
Note: graph G is a subgraph of itself
13.1 Introduction to graphs
a
b c
d
G
b c
d
H
63
[Def]: A graph H = (VH, E
H) is a subgraph of a graph G =
(VG, E
G) if V
H V
G and E
H E⊆
G.
Note: graph G is a subgraph of itself
13.1 Introduction to graphs: common graphs
a
b c
d
G
b c
d
H
64
Special Simple Graphs
- complete graphs ( Kn, for n Z+ )
- cycles ( Cn, for n Z+ and n 3)
- wheels ( Wn, for n Z+ and n 3)
- n-cubes ( Qn, for n Z+ )
13.1 Introduction to graphs: common graphs
65
Special Simple Graphs: Complete graphs
A complete graph Kn on n vertices is a simple graph
that contains exactly one edge between each pair of distinct vertices.n = 1, 2, 3, 4, …
Sometimes Kn is called clique of size n or n-clique.
K1 K
2 K3 K
4K
5
13.1 Introduction to graphs: common graphs
66
Special Simple Graphs: Cycles
A cycle Cn on n vertices consists on n vertices v
1, v
2, …,
vn and edges {v
1,v
2}, {v
2,v
3},..., and {v
n-1,v
n}.
n = 3, 4, 5, ...
C3 C
4C
5 C6
13.1 Introduction to graphs: common graphs
67
Special Simple Graphs: Wheels
A wheel Wn can be obtained from cycle C
n by adding
an additional vertex and connecting this new vertex with each of the n vertices in C
n.
n = 3, 4, 5, ...
W3 W
4W
5W
6
13.1 Introduction to graphs: common graphs
68
Special Simple Graphs: n-Cubes
Graph of Qn has 2n vertices
Q1 Q
2 Q3
13.1 Introduction to graphs: common graphs
69
Special Simple Graphs: n-Cubes
Graph of Qn has 2n vertices
n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...
Q1 Q
2 Q3
13.1 Introduction to graphs: common graphs
70
Special Simple Graphs: n-Cubes
Graph of Qn has 2n vertices
n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...
Q1 Q
2
10Q
1
Q3
13.1 Introduction to graphs: common graphs
71
Special Simple Graphs: n-Cubes
Graph of Qn has 2n vertices
n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...
Q1 Q
2
Q2
10Q
1 00 01
10 11
2nd place
1st place
Q3
13.1 Introduction to graphs: common graphs
72
Special Simple Graphs: n-Cubes
Graph of Qn has 2n vertices
n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...
Q1 Q
2
Q2
10Q
1 00 01
10 11
2nd place
1st place
111110
000 001
011100
3rd place
1st place
2nd place
Q3
Q3
13.1 Introduction to graphs: common graphs
73
Special Simple Graphs: n-Cubes
Graph of Qn has 2n vertices
n-Cubes can represent bit strings of length nn = 1, 2, 3, 4, ...
Q1 Q
2 Q3
Q2
10Q
1 00 01
10 11
2nd place
1st place
111110
000 001
011100
3rd place
1st place
2nd place
010101
Q3
13.1 Introduction to graphs: common graphs