introduction to graph algorithms - cs.ust.hk fileintroduction to graph algorithms version of...
TRANSCRIPT
![Page 1: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/1.jpg)
Introduction to Graph Algorithms
Version of September 23, 2016
Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20
![Page 2: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/2.jpg)
Graphs
Extremely useful tool in modeling problems
Consist of:
VerticesEdges
D
AC
E
B
FVertex
Edge
Vertices can be considered as“sites” or locations.
Edges represent connections.
Version of September 23, 2016 Introduction to Graph Algorithms 2 / 20
![Page 3: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/3.jpg)
Graphs
Extremely useful tool in modeling problems
Consist of:
VerticesEdges
D
AC
E
B
FVertex
Edge
Vertices can be considered as“sites” or locations.
Edges represent connections.
Version of September 23, 2016 Introduction to Graph Algorithms 2 / 20
![Page 4: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/4.jpg)
Graph Application
Air flight system
Each vertex represents a city
Each edge represents a direct flight between two cities
A query on direct flight = a query on whether an edge exists
A query on how to get to a location = does a path exist fromA to B
We can even associate costs to edges (weighted graphs), thenask “what is the cheapest path from A to B”
Version of September 23, 2016 Introduction to Graph Algorithms 3 / 20
![Page 5: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/5.jpg)
Graph Application
Air flight system
Each vertex represents a city
Each edge represents a direct flight between two cities
A query on direct flight = a query on whether an edge exists
A query on how to get to a location = does a path exist fromA to B
We can even associate costs to edges (weighted graphs), thenask “what is the cheapest path from A to B”
Version of September 23, 2016 Introduction to Graph Algorithms 3 / 20
![Page 6: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/6.jpg)
Graph Application
Air flight system
Each vertex represents a city
Each edge represents a direct flight between two cities
A query on direct flight = a query on whether an edge exists
A query on how to get to a location = does a path exist fromA to B
We can even associate costs to edges (weighted graphs), thenask “what is the cheapest path from A to B”
Version of September 23, 2016 Introduction to Graph Algorithms 3 / 20
![Page 7: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/7.jpg)
Graph Application
Air flight system
Each vertex represents a city
Each edge represents a direct flight between two cities
A query on direct flight = a query on whether an edge exists
A query on how to get to a location = does a path exist fromA to B
We can even associate costs to edges (weighted graphs), thenask “what is the cheapest path from A to B”
Version of September 23, 2016 Introduction to Graph Algorithms 3 / 20
![Page 8: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/8.jpg)
Graph Application
Air flight system
Each vertex represents a city
Each edge represents a direct flight between two cities
A query on direct flight = a query on whether an edge exists
A query on how to get to a location = does a path exist fromA to B
We can even associate costs to edges (weighted graphs), thenask “what is the cheapest path from A to B”
Version of September 23, 2016 Introduction to Graph Algorithms 3 / 20
![Page 9: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/9.jpg)
Graph Application
Air flight system
Each vertex represents a city
Each edge represents a direct flight between two cities
A query on direct flight = a query on whether an edge exists
A query on how to get to a location = does a path exist fromA to B
We can even associate costs to edges (weighted graphs), thenask “what is the cheapest path from A to B”
Version of September 23, 2016 Introduction to Graph Algorithms 3 / 20
![Page 10: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/10.jpg)
Graph Application
S
B
L
C
A
H
T
M
P
N
Bahrain
Hong KongCairo
San Francisco
London
Tokyo
original graph simplified graph
Each vertex represents a city
Each edge represents a direct flight between two cities
A query on direct flight = a query on whether an edge exists
A query on how to get to a location = does a path exist fromA to B
We can even associate costs/time to edges (weighted graphs),then ask “what is the cheapest/fastest path from A to B”
Version of September 23, 2016 Introduction to Graph Algorithms 4 / 20
![Page 11: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/11.jpg)
Why Graph Algorithms?
Graphs are a ubiquitous data structure in computer science
Networks: LAN, the Internet, wireless networks
Logistics: transportation, supply chain management
Relationship between objects: online dating, social networks(Facebook!)
Hundreds of interesting computational problems defined ongraphs
We will sample a few basic ones
Version of September 23, 2016 Introduction to Graph Algorithms 5 / 20
![Page 12: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/12.jpg)
Why Graph Algorithms?
Graphs are a ubiquitous data structure in computer science
Networks: LAN, the Internet, wireless networks
Logistics: transportation, supply chain management
Relationship between objects: online dating, social networks(Facebook!)
Hundreds of interesting computational problems defined ongraphs
We will sample a few basic ones
Version of September 23, 2016 Introduction to Graph Algorithms 5 / 20
![Page 13: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/13.jpg)
Why Graph Algorithms?
Graphs are a ubiquitous data structure in computer science
Networks: LAN, the Internet, wireless networks
Logistics: transportation, supply chain management
Relationship between objects: online dating, social networks(Facebook!)
Hundreds of interesting computational problems defined ongraphs
We will sample a few basic ones
Version of September 23, 2016 Introduction to Graph Algorithms 5 / 20
![Page 14: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/14.jpg)
Why Graph Algorithms?
Graphs are a ubiquitous data structure in computer science
Networks: LAN, the Internet, wireless networks
Logistics: transportation, supply chain management
Relationship between objects: online dating, social networks(Facebook!)
Hundreds of interesting computational problems defined ongraphs
We will sample a few basic ones
Version of September 23, 2016 Introduction to Graph Algorithms 5 / 20
![Page 15: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/15.jpg)
Why Graph Algorithms?
Graphs are a ubiquitous data structure in computer science
Networks: LAN, the Internet, wireless networks
Logistics: transportation, supply chain management
Relationship between objects: online dating, social networks(Facebook!)
Hundreds of interesting computational problems defined ongraphs
We will sample a few basic ones
Version of September 23, 2016 Introduction to Graph Algorithms 5 / 20
![Page 16: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/16.jpg)
Why Graph Algorithms?
Graphs are a ubiquitous data structure in computer science
Networks: LAN, the Internet, wireless networks
Logistics: transportation, supply chain management
Relationship between objects: online dating, social networks(Facebook!)
Hundreds of interesting computational problems defined ongraphs
We will sample a few basic ones
Version of September 23, 2016 Introduction to Graph Algorithms 5 / 20
![Page 17: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/17.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, anda set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P,S ,T}E = {(A,C ), (A,H), . . . , (H,P), . . .}
For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 18: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/18.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, and
a set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P,S ,T}E = {(A,C ), (A,H), . . . , (H,P), . . .}
For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 19: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/19.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, anda set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P,S ,T}E = {(A,C ), (A,H), . . . , (H,P), . . .}
For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 20: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/20.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, anda set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P,S ,T}E = {(A,C ), (A,H), . . . , (H,P), . . .}
For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 21: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/21.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, anda set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P,S ,T}E = {(A,C ), (A,H), . . . , (H,P), . . .}
For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 22: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/22.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, anda set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P, S ,T}
E = {(A,C ), (A,H), . . . , (H,P), . . .}For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 23: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/23.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, anda set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P, S ,T}E = {(A,C ), (A,H), . . . , (H,P), . . .}
For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 24: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/24.jpg)
Definition
A graph G = (V ,E ) consists of
a set of vertices V , |V | = n, anda set of edges E , |E | = m
Each edge is a pair of (u, v), where u, v belongs to V
S
B
L
C
A
H
T
M
P
N
V = {A,B,C ,H, L,M,N,P, S ,T}E = {(A,C ), (A,H), . . . , (H,P), . . .}
For directed graph, we distinguish between edge (u, v) andedge (v , u); for undirected graph, no such distinction is made.
Version of September 23, 2016 Introduction to Graph Algorithms 6 / 20
![Page 25: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/25.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 26: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/26.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 27: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/27.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 28: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/28.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 29: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/29.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 30: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/30.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacent
H is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 31: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/31.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 32: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/32.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 33: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/33.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and B
H and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 34: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/34.jpg)
Terminology
S
B
L
C
A
H
T
M
P
N
Each edge has two endpoints
H and B are the endpoints of(H,B)
An edge joins its endpoints
(H,B) joins H and B
Two vertices are adjacent (orneighbors) if they are joined byan edge.
H and B are adjacentH is a neighbor of B
If vertex v is an endpoint of edgee, then the edge e is said to beincident on v . Also, the vertex vis said to be incident on e
(H,B) is incident on H and BH and B are incident on(H,B)
Version of September 23, 2016 Introduction to Graph Algorithms 7 / 20
![Page 35: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/35.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 36: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/36.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 37: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/37.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 38: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/38.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 39: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/39.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0
(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 40: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/40.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 41: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/41.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 42: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/42.jpg)
The Degree of a Vertex
The degree of a vertex v (degree(v)) in a graph is the number ofedges incident on it.
S
B
L
C
A
H
T
M
P
N
X
Vertex H has degree 5
Vertex N has degree 1
Vertex X has degree 0(It is called an isolated vertex)
Lemma ∑v∈V
degree(v) = 2|E |.
Proof.
An edge e = (u, v) in a graph contributes one to degree(u) andcontributes one to degree(v).
Version of September 23, 2016 Introduction to Graph Algorithms 8 / 20
![Page 43: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/43.jpg)
Path
A path in a graph is a sequence 〈v0, v1, v2, . . . , vk〉 of vertices suchthat (vi−1, vi ) ∈ E for i = 1, 2, . . . , k
There is a path from v0 to vk
Length of a path = # of edges onthe path
Path contains the verticesv0, v1, . . . , vk and the edges(v0, v1), (v1, v2), . . . , (vk−1, vk)
For any 0 ≤ i ≤ j ≤ k ,〈vi , vi+1, . . . , vj〉 is its subpath
If there is a path p from u to v , v issaid to be reachable from u
A path is simple if all vertices in thepath are distinct
S
B
L
C
A
H
T
M
P
N
• 〈L,B,M〉 is a path
– length is 2
– 〈B,M〉 is its subpath– M is reachable from L
– a simple path
• 〈N,T,H, S, T, P 〉 is a path
– length is 5
– 〈T,H, S〉 is its subpath– P is reachable from N
– not a simple path
Version of September 23, 2016 Introduction to Graph Algorithms 9 / 20
![Page 44: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/44.jpg)
Path
A path in a graph is a sequence 〈v0, v1, v2, . . . , vk〉 of vertices suchthat (vi−1, vi ) ∈ E for i = 1, 2, . . . , k
There is a path from v0 to vk
Length of a path = # of edges onthe path
Path contains the verticesv0, v1, . . . , vk and the edges(v0, v1), (v1, v2), . . . , (vk−1, vk)
For any 0 ≤ i ≤ j ≤ k ,〈vi , vi+1, . . . , vj〉 is its subpath
If there is a path p from u to v , v issaid to be reachable from u
A path is simple if all vertices in thepath are distinct
S
B
L
C
A
H
T
M
P
N
• 〈L,B,M〉 is a path
– length is 2
– 〈B,M〉 is its subpath– M is reachable from L
– a simple path
• 〈N,T,H, S, T, P 〉 is a path
– length is 5
– 〈T,H, S〉 is its subpath– P is reachable from N
– not a simple path
Version of September 23, 2016 Introduction to Graph Algorithms 9 / 20
![Page 45: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/45.jpg)
Cycle
A path 〈v0, v1, v2, . . . , vk〉 forms a cycle if v0 = vk and all edges onthe path are distinct
A cycle is simple if v1, v2, . . . , vk are distinct
A graph with no cycles is acyclic
S
B
L
C
A
H
T
M
P
N
〈T ,S ,H,T 〉 is a simple cycle
〈A,C , L,P,H,A〉 is a simple cycle
Version of September 23, 2016 Introduction to Graph Algorithms 10 / 20
![Page 46: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/46.jpg)
Cycle
A path 〈v0, v1, v2, . . . , vk〉 forms a cycle if v0 = vk and all edges onthe path are distinct
A cycle is simple if v1, v2, . . . , vk are distinct
A graph with no cycles is acyclic
S
B
L
C
A
H
T
M
P
N
〈T ,S ,H,T 〉 is a simple cycle
〈A,C , L,P,H,A〉 is a simple cycle
Version of September 23, 2016 Introduction to Graph Algorithms 10 / 20
![Page 47: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/47.jpg)
Cycle
A path 〈v0, v1, v2, . . . , vk〉 forms a cycle if v0 = vk and all edges onthe path are distinct
A cycle is simple if v1, v2, . . . , vk are distinct
A graph with no cycles is acyclic
S
B
L
C
A
H
T
M
P
N
〈T ,S ,H,T 〉 is a simple cycle
〈A,C , L,P,H,A〉 is a simple cycle
Version of September 23, 2016 Introduction to Graph Algorithms 10 / 20
![Page 48: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/48.jpg)
Cycle
A path 〈v0, v1, v2, . . . , vk〉 forms a cycle if v0 = vk and all edges onthe path are distinct
A cycle is simple if v1, v2, . . . , vk are distinct
A graph with no cycles is acyclic
S
B
L
C
A
H
T
M
P
N
〈T , S ,H,T 〉 is a simple cycle
〈A,C , L,P,H,A〉 is a simple cycle
Version of September 23, 2016 Introduction to Graph Algorithms 10 / 20
![Page 49: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/49.jpg)
Cycle
A path 〈v0, v1, v2, . . . , vk〉 forms a cycle if v0 = vk and all edges onthe path are distinct
A cycle is simple if v1, v2, . . . , vk are distinct
A graph with no cycles is acyclic
S
B
L
C
A
H
T
M
P
N
〈T , S ,H,T 〉 is a simple cycle
〈A,C , L,P,H,A〉 is a simple cycle
Version of September 23, 2016 Introduction to Graph Algorithms 10 / 20
![Page 50: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/50.jpg)
Cycle
A path 〈v0, v1, v2, . . . , vk〉 forms a cycle if v0 = vk and all edges onthe path are distinct
A cycle is simple if v1, v2, . . . , vk are distinct
A graph with no cycles is acyclic
S
B
L
C
A
H
T
M
P
N
〈T , S ,H,T 〉 is a simple cycle
〈A,C , L,P,H,A〉 is a simple cycle
Version of September 23, 2016 Introduction to Graph Algorithms 10 / 20
![Page 51: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/51.jpg)
Connectivity
Two vertices are connected if there is a path between them
A graph is connected if every pair of vertices is connected;otherwise, the graph is disconnected
The connected components of a graph are the equivalenceclasses of vertices under the “is reachable from” relation
S
B
L
C
A
H
T
M
P
N
1 2 3
654
• connected graph
• one connected component{A,B,C,H,L,M,N, P, S, T}
• disconnected graph
• 3 connected components
– {1, 2, 5}– {3, 6}– {4}
Version of September 23, 2016 Introduction to Graph Algorithms 11 / 20
![Page 52: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/52.jpg)
Connectivity
Two vertices are connected if there is a path between them
A graph is connected if every pair of vertices is connected;otherwise, the graph is disconnected
The connected components of a graph are the equivalenceclasses of vertices under the “is reachable from” relation
S
B
L
C
A
H
T
M
P
N
1 2 3
654
• connected graph
• one connected component{A,B,C,H,L,M,N, P, S, T}
• disconnected graph
• 3 connected components
– {1, 2, 5}– {3, 6}– {4}
Version of September 23, 2016 Introduction to Graph Algorithms 11 / 20
![Page 53: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/53.jpg)
Connectivity
Two vertices are connected if there is a path between them
A graph is connected if every pair of vertices is connected;otherwise, the graph is disconnected
The connected components of a graph are the equivalenceclasses of vertices under the “is reachable from” relation
S
B
L
C
A
H
T
M
P
N
1 2 3
654
• connected graph
• one connected component{A,B,C,H,L,M,N, P, S, T}
• disconnected graph
• 3 connected components
– {1, 2, 5}– {3, 6}– {4}
Version of September 23, 2016 Introduction to Graph Algorithms 11 / 20
![Page 54: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/54.jpg)
Connectivity
Two vertices are connected if there is a path between them
A graph is connected if every pair of vertices is connected;otherwise, the graph is disconnected
The connected components of a graph are the equivalenceclasses of vertices under the “is reachable from” relation
S
B
L
C
A
H
T
M
P
N
1 2 3
654
• connected graph
• one connected component{A,B,C,H,L,M,N, P, S, T}
• disconnected graph
• 3 connected components
– {1, 2, 5}– {3, 6}– {4}
Version of September 23, 2016 Introduction to Graph Algorithms 11 / 20
![Page 55: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/55.jpg)
Subgraph
Graph G ′ = (V ′,E ′) is a subgraph of G = (V ,E ) if V ′ ⊆ Vand E ′ ⊆ E
G ′ is an induced subgraph of G if G ′ is a subgraph of G andevery edge of G connecting vertices of G ′ is an edge of G ′.
S
B
L
C
A
H
T
M
P
N
B
L
H
P
subgraph
not induced subgrap
h
subgraphinduced subgraph
B
L
H
P
Version of September 23, 2016 Introduction to Graph Algorithms 12 / 20
![Page 56: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/56.jpg)
Subgraph
Graph G ′ = (V ′,E ′) is a subgraph of G = (V ,E ) if V ′ ⊆ Vand E ′ ⊆ E
G ′ is an induced subgraph of G if G ′ is a subgraph of G andevery edge of G connecting vertices of G ′ is an edge of G ′.
S
B
L
C
A
H
T
M
P
N
B
L
H
P
subgraph
not induced subgrap
h
subgraphinduced subgraph
B
L
H
P
Version of September 23, 2016 Introduction to Graph Algorithms 12 / 20
![Page 57: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/57.jpg)
Subgraph
Graph G ′ = (V ′,E ′) is a subgraph of G = (V ,E ) if V ′ ⊆ Vand E ′ ⊆ E
G ′ is an induced subgraph of G if G ′ is a subgraph of G andevery edge of G connecting vertices of G ′ is an edge of G ′.
S
B
L
C
A
H
T
M
P
N
B
L
H
P
subgraph
not induced subgrap
h
subgraphinduced subgraph
B
L
H
P
Version of September 23, 2016 Introduction to Graph Algorithms 12 / 20
![Page 58: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/58.jpg)
Trees
A tree is a connected, acyclic, undirected graph
If an undirected graph is acyclic but possibly disconnected, itis a forest
S
B
L
C
A
H
T
M
P
N
S
B
L
C
A
H
T
M
P
N
S
B
L
C
A
H
T
M
P
N
A tree A forest neither a tree nor a forest
Version of September 23, 2016 Introduction to Graph Algorithms 13 / 20
![Page 59: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/59.jpg)
Trees
A tree is a connected, acyclic, undirected graph
If an undirected graph is acyclic but possibly disconnected, itis a forest
S
B
L
C
A
H
T
M
P
N
S
B
L
C
A
H
T
M
P
N
S
B
L
C
A
H
T
M
P
N
A tree A forest neither a tree nor a forest
Version of September 23, 2016 Introduction to Graph Algorithms 13 / 20
![Page 60: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/60.jpg)
Trees
A tree is a connected, acyclic, undirected graph
If an undirected graph is acyclic but possibly disconnected, itis a forest
S
B
L
C
A
H
T
M
P
N
S
B
L
C
A
H
T
M
P
N
S
B
L
C
A
H
T
M
P
N
A tree A forest neither a tree nor a forest
Version of September 23, 2016 Introduction to Graph Algorithms 13 / 20
![Page 61: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/61.jpg)
Properties of Trees
Let G = (V ,E ) be an undirected graph. The following statementsare equivalent.
1 G is a tree
2 Any two vertices in G are connected by a unique simple path
3 G is connected, but if any edge is removed from E , theresulting graph is disconnected
4 G is connected, and |E | = |V | − 1
5 G is acyclic, and |E | = |V | − 1
6 G is acyclic, but if any edge is added to E , the resulting graphcontains a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 14 / 20
![Page 62: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/62.jpg)
Properties of Trees
Let G = (V ,E ) be an undirected graph. The following statementsare equivalent.
1 G is a tree
2 Any two vertices in G are connected by a unique simple path
3 G is connected, but if any edge is removed from E , theresulting graph is disconnected
4 G is connected, and |E | = |V | − 1
5 G is acyclic, and |E | = |V | − 1
6 G is acyclic, but if any edge is added to E , the resulting graphcontains a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 14 / 20
![Page 63: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/63.jpg)
Properties of Trees
Let G = (V ,E ) be an undirected graph. The following statementsare equivalent.
1 G is a tree
2 Any two vertices in G are connected by a unique simple path
3 G is connected, but if any edge is removed from E , theresulting graph is disconnected
4 G is connected, and |E | = |V | − 1
5 G is acyclic, and |E | = |V | − 1
6 G is acyclic, but if any edge is added to E , the resulting graphcontains a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 14 / 20
![Page 64: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/64.jpg)
Properties of Trees
Let G = (V ,E ) be an undirected graph. The following statementsare equivalent.
1 G is a tree
2 Any two vertices in G are connected by a unique simple path
3 G is connected, but if any edge is removed from E , theresulting graph is disconnected
4 G is connected, and |E | = |V | − 1
5 G is acyclic, and |E | = |V | − 1
6 G is acyclic, but if any edge is added to E , the resulting graphcontains a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 14 / 20
![Page 65: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/65.jpg)
Properties of Trees
Let G = (V ,E ) be an undirected graph. The following statementsare equivalent.
1 G is a tree
2 Any two vertices in G are connected by a unique simple path
3 G is connected, but if any edge is removed from E , theresulting graph is disconnected
4 G is connected, and |E | = |V | − 1
5 G is acyclic, and |E | = |V | − 1
6 G is acyclic, but if any edge is added to E , the resulting graphcontains a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 14 / 20
![Page 66: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/66.jpg)
Properties of Trees
Let G = (V ,E ) be an undirected graph. The following statementsare equivalent.
1 G is a tree
2 Any two vertices in G are connected by a unique simple path
3 G is connected, but if any edge is removed from E , theresulting graph is disconnected
4 G is connected, and |E | = |V | − 1
5 G is acyclic, and |E | = |V | − 1
6 G is acyclic, but if any edge is added to E , the resulting graphcontains a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 14 / 20
![Page 67: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/67.jpg)
Properties of Trees
Let G = (V ,E ) be an undirected graph. The following statementsare equivalent.
1 G is a tree
2 Any two vertices in G are connected by a unique simple path
3 G is connected, but if any edge is removed from E , theresulting graph is disconnected
4 G is connected, and |E | = |V | − 1
5 G is acyclic, and |E | = |V | − 1
6 G is acyclic, but if any edge is added to E , the resulting graphcontains a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 14 / 20
![Page 68: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/68.jpg)
Proof
(1) G is a tree⇒ (2) Any two vertices in G are connected by a unique simple path
u
wx
yz
v
p′
p′′
Proof by contradiction
Suppose that vertices u and v are connected by two distinctsimple paths p1 and p2, as shown in the above figure
p1 and p2 first diverge at vertex wp1 and p2 first reconverge at vertex zp′ is the subpath of p1 from w through x to zp′′ is the subpath of p2 from w through y to zThe path obtained by concatenating p′ and the reverse of p′′ isa cycle, which yields the contradiction!
Version of September 23, 2016 Introduction to Graph Algorithms 15 / 20
![Page 69: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/69.jpg)
Proof
(1) G is a tree⇒ (2) Any two vertices in G are connected by a unique simple path
u
wx
yz
v
p′
p′′
Proof by contradiction
Suppose that vertices u and v are connected by two distinctsimple paths p1 and p2, as shown in the above figure
p1 and p2 first diverge at vertex wp1 and p2 first reconverge at vertex zp′ is the subpath of p1 from w through x to zp′′ is the subpath of p2 from w through y to zThe path obtained by concatenating p′ and the reverse of p′′ isa cycle, which yields the contradiction!
Version of September 23, 2016 Introduction to Graph Algorithms 15 / 20
![Page 70: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/70.jpg)
Proof
(1) G is a tree⇒ (2) Any two vertices in G are connected by a unique simple path
u
wx
yz
v
p′
p′′
Proof by contradiction
Suppose that vertices u and v are connected by two distinctsimple paths p1 and p2, as shown in the above figure
p1 and p2 first diverge at vertex wp1 and p2 first reconverge at vertex z
p′ is the subpath of p1 from w through x to zp′′ is the subpath of p2 from w through y to zThe path obtained by concatenating p′ and the reverse of p′′ isa cycle, which yields the contradiction!
Version of September 23, 2016 Introduction to Graph Algorithms 15 / 20
![Page 71: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/71.jpg)
Proof
(1) G is a tree⇒ (2) Any two vertices in G are connected by a unique simple path
u
wx
yz
v
p′
p′′
Proof by contradiction
Suppose that vertices u and v are connected by two distinctsimple paths p1 and p2, as shown in the above figure
p1 and p2 first diverge at vertex wp1 and p2 first reconverge at vertex zp′ is the subpath of p1 from w through x to zp′′ is the subpath of p2 from w through y to z
The path obtained by concatenating p′ and the reverse of p′′ isa cycle, which yields the contradiction!
Version of September 23, 2016 Introduction to Graph Algorithms 15 / 20
![Page 72: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/72.jpg)
Proof
(1) G is a tree⇒ (2) Any two vertices in G are connected by a unique simple path
u
wx
yz
v
p′
p′′
Proof by contradiction
Suppose that vertices u and v are connected by two distinctsimple paths p1 and p2, as shown in the above figure
p1 and p2 first diverge at vertex wp1 and p2 first reconverge at vertex zp′ is the subpath of p1 from w through x to zp′′ is the subpath of p2 from w through y to zThe path obtained by concatenating p′ and the reverse of p′′ isa cycle, which yields the contradiction!
Version of September 23, 2016 Introduction to Graph Algorithms 15 / 20
![Page 73: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/73.jpg)
Proof
(2) Any two vertices in G are connected by a unique simple path⇒ (3) G is connected, but if any edge is removed from E , theresulting graph is disconnected
If any two vertices in G are connected by a unique simplepath, then G is connected
Let (u, v) be any edge in E
This edge is a path from u to v , and so it must be the uniquepath from u to v
If (u, v) is deleted from G , there is no path from u to v , andhence its removal disconnects G
Version of September 23, 2016 Introduction to Graph Algorithms 16 / 20
![Page 74: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/74.jpg)
Proof
(2) Any two vertices in G are connected by a unique simple path⇒ (3) G is connected, but if any edge is removed from E , theresulting graph is disconnected
If any two vertices in G are connected by a unique simplepath, then G is connected
Let (u, v) be any edge in E
This edge is a path from u to v , and so it must be the uniquepath from u to v
If (u, v) is deleted from G , there is no path from u to v , andhence its removal disconnects G
Version of September 23, 2016 Introduction to Graph Algorithms 16 / 20
![Page 75: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/75.jpg)
Proof
(2) Any two vertices in G are connected by a unique simple path⇒ (3) G is connected, but if any edge is removed from E , theresulting graph is disconnected
If any two vertices in G are connected by a unique simplepath, then G is connected
Let (u, v) be any edge in E
This edge is a path from u to v , and so it must be the uniquepath from u to v
If (u, v) is deleted from G , there is no path from u to v , andhence its removal disconnects G
Version of September 23, 2016 Introduction to Graph Algorithms 16 / 20
![Page 76: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/76.jpg)
Proof
(2) Any two vertices in G are connected by a unique simple path⇒ (3) G is connected, but if any edge is removed from E , theresulting graph is disconnected
If any two vertices in G are connected by a unique simplepath, then G is connected
Let (u, v) be any edge in E
This edge is a path from u to v , and so it must be the uniquepath from u to v
If (u, v) is deleted from G , there is no path from u to v , andhence its removal disconnects G
Version of September 23, 2016 Introduction to Graph Algorithms 16 / 20
![Page 77: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/77.jpg)
Proof
(2) Any two vertices in G are connected by a unique simple path⇒ (3) G is connected, but if any edge is removed from E , theresulting graph is disconnected
If any two vertices in G are connected by a unique simplepath, then G is connected
Let (u, v) be any edge in E
This edge is a path from u to v , and so it must be the uniquepath from u to v
If (u, v) is deleted from G , there is no path from u to v , andhence its removal disconnects G
Version of September 23, 2016 Introduction to Graph Algorithms 16 / 20
![Page 78: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/78.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 79: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/79.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 80: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/80.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 81: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/81.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedge
Suppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 82: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/82.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1
Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 83: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/83.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected components
Each component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 84: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/84.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)
Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 85: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/85.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2
Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 86: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/86.jpg)
Proof
(3) G is connected, but if any edge is removed from E , theresulting graph is disconnected⇒ (4) G is connected, and |E | = |V | − 1
By assumption, the graph G is connected
Prove |E | = |V | − 1 by induction
Base (n = 1): A connected graph with one vertex has zeroedgeSuppose that G has n ≥ 2 vertices and that all graphssatisfying (3) with fewer than n vertices also satisfy|E | = |V | − 1Removing an arbitrary edge from G separates the graph into 2connected componentsEach component satisfies (3), or else G would not satisfy (3)Thus, by induction, the number of edges in 2 componentscombined is |V | − 2Adding in the removed edge yields |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 17 / 20
![Page 87: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/87.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 88: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/88.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 89: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/89.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 90: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/90.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 91: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/91.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}
Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 92: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/92.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 93: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/93.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |
Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 94: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/94.jpg)
Proof
(4) G is connected, and |E | = |V | − 1⇒ (5) G is acyclic, and |E | = |V | − 1
Suppose that G is connected and that |E | = |V | − 1
Suppose that G has a cycle containing k vertices v1, v2, . . . , vk , andwithout loss of generality assume that this cycle is simple
Let Gk = (Vk ,Ek) be the subgraph of G consisting of the cycle
Note that |Vk | = |Ek | = k
If k < |V |, there must be a vertex vk+1 ∈ V − Vk that is adjacent tosome vertex vi ∈ Vk , since G is connected
Define Gk+1 = (Vk+1,Ek+1) to be the subgraph of G withVk+1 = Vk ∪ {vk+1} and Ek+1 = Ek ∪ {(vi , vk+1)}Note that |Vk+1| = |Ek+1| = k + 1
If k + 1 < |V |, we can continue, defining Gk+2 in the same manner, andso forth, until we obtain Gn = (Vn,En), where n = |V |,Vn = V , and|En| = |Vn| = |V |Since Gn is a subgraph of G , we have En ⊆ E , and hence |E | ≥ |V |,which contradicts the assumption that |E | = |V | − 1
Version of September 23, 2016 Introduction to Graph Algorithms 18 / 20
![Page 95: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/95.jpg)
Proof
(5) G is acyclic, and |E | = |V | − 1⇒ (6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle
Suppose that G is acyclic and that |E | = |V | − 1
Let k be the number of connected components of G
Each connected component is a free tree by definition, andsince (1) implies (5), the sum of all edges in all connectedcomponents of G is |V | − k
Consequently, we must have k = 1, and G is in fact a tree(That is, (1) holds)
Since (1) implies (2), any two vertices in G are connected bya unique simple path
Thus, adding any edge to G creates a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 19 / 20
![Page 96: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/96.jpg)
Proof
(5) G is acyclic, and |E | = |V | − 1⇒ (6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle
Suppose that G is acyclic and that |E | = |V | − 1
Let k be the number of connected components of G
Each connected component is a free tree by definition, andsince (1) implies (5), the sum of all edges in all connectedcomponents of G is |V | − k
Consequently, we must have k = 1, and G is in fact a tree(That is, (1) holds)
Since (1) implies (2), any two vertices in G are connected bya unique simple path
Thus, adding any edge to G creates a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 19 / 20
![Page 97: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/97.jpg)
Proof
(5) G is acyclic, and |E | = |V | − 1⇒ (6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle
Suppose that G is acyclic and that |E | = |V | − 1
Let k be the number of connected components of G
Each connected component is a free tree by definition, andsince (1) implies (5), the sum of all edges in all connectedcomponents of G is |V | − k
Consequently, we must have k = 1, and G is in fact a tree(That is, (1) holds)
Since (1) implies (2), any two vertices in G are connected bya unique simple path
Thus, adding any edge to G creates a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 19 / 20
![Page 98: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/98.jpg)
Proof
(5) G is acyclic, and |E | = |V | − 1⇒ (6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle
Suppose that G is acyclic and that |E | = |V | − 1
Let k be the number of connected components of G
Each connected component is a free tree by definition, andsince (1) implies (5), the sum of all edges in all connectedcomponents of G is |V | − k
Consequently, we must have k = 1, and G is in fact a tree(That is, (1) holds)
Since (1) implies (2), any two vertices in G are connected bya unique simple path
Thus, adding any edge to G creates a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 19 / 20
![Page 99: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/99.jpg)
Proof
(5) G is acyclic, and |E | = |V | − 1⇒ (6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle
Suppose that G is acyclic and that |E | = |V | − 1
Let k be the number of connected components of G
Each connected component is a free tree by definition, andsince (1) implies (5), the sum of all edges in all connectedcomponents of G is |V | − k
Consequently, we must have k = 1, and G is in fact a tree(That is, (1) holds)
Since (1) implies (2), any two vertices in G are connected bya unique simple path
Thus, adding any edge to G creates a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 19 / 20
![Page 100: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/100.jpg)
Proof
(5) G is acyclic, and |E | = |V | − 1⇒ (6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle
Suppose that G is acyclic and that |E | = |V | − 1
Let k be the number of connected components of G
Each connected component is a free tree by definition, andsince (1) implies (5), the sum of all edges in all connectedcomponents of G is |V | − k
Consequently, we must have k = 1, and G is in fact a tree(That is, (1) holds)
Since (1) implies (2), any two vertices in G are connected bya unique simple path
Thus, adding any edge to G creates a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 19 / 20
![Page 101: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/101.jpg)
Proof
(5) G is acyclic, and |E | = |V | − 1⇒ (6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle
Suppose that G is acyclic and that |E | = |V | − 1
Let k be the number of connected components of G
Each connected component is a free tree by definition, andsince (1) implies (5), the sum of all edges in all connectedcomponents of G is |V | − k
Consequently, we must have k = 1, and G is in fact a tree(That is, (1) holds)
Since (1) implies (2), any two vertices in G are connected bya unique simple path
Thus, adding any edge to G creates a cycle
Version of September 23, 2016 Introduction to Graph Algorithms 19 / 20
![Page 102: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/102.jpg)
Proof
(6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle⇒ (1) G is a tree
Suppose that G is acyclic but that if any edge is added to E ,a cycle is created
We must show that G is connected
Let u and v be arbitrary vertices in G
If u and v are not already adjacent, adding the edge (u, v)creates a cycle in which all edges but (u, v) belong to G
Thus, there is a path from u to v , and since u and v werechosen arbitrarily, G is connected
Version of September 23, 2016 Introduction to Graph Algorithms 20 / 20
![Page 103: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/103.jpg)
Proof
(6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle⇒ (1) G is a tree
Suppose that G is acyclic but that if any edge is added to E ,a cycle is created
We must show that G is connected
Let u and v be arbitrary vertices in G
If u and v are not already adjacent, adding the edge (u, v)creates a cycle in which all edges but (u, v) belong to G
Thus, there is a path from u to v , and since u and v werechosen arbitrarily, G is connected
Version of September 23, 2016 Introduction to Graph Algorithms 20 / 20
![Page 104: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/104.jpg)
Proof
(6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle⇒ (1) G is a tree
Suppose that G is acyclic but that if any edge is added to E ,a cycle is created
We must show that G is connected
Let u and v be arbitrary vertices in G
If u and v are not already adjacent, adding the edge (u, v)creates a cycle in which all edges but (u, v) belong to G
Thus, there is a path from u to v , and since u and v werechosen arbitrarily, G is connected
Version of September 23, 2016 Introduction to Graph Algorithms 20 / 20
![Page 105: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/105.jpg)
Proof
(6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle⇒ (1) G is a tree
Suppose that G is acyclic but that if any edge is added to E ,a cycle is created
We must show that G is connected
Let u and v be arbitrary vertices in G
If u and v are not already adjacent, adding the edge (u, v)creates a cycle in which all edges but (u, v) belong to G
Thus, there is a path from u to v , and since u and v werechosen arbitrarily, G is connected
Version of September 23, 2016 Introduction to Graph Algorithms 20 / 20
![Page 106: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/106.jpg)
Proof
(6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle⇒ (1) G is a tree
Suppose that G is acyclic but that if any edge is added to E ,a cycle is created
We must show that G is connected
Let u and v be arbitrary vertices in G
If u and v are not already adjacent, adding the edge (u, v)creates a cycle in which all edges but (u, v) belong to G
Thus, there is a path from u to v , and since u and v werechosen arbitrarily, G is connected
Version of September 23, 2016 Introduction to Graph Algorithms 20 / 20
![Page 107: Introduction to Graph Algorithms - cs.ust.hk fileIntroduction to Graph Algorithms Version of September 23, 2016 Version of September 23, 2016 Introduction to Graph Algorithms 1 / 20](https://reader030.vdocuments.us/reader030/viewer/2022040123/5e1e21e649f15853123e5e76/html5/thumbnails/107.jpg)
Proof
(6) G is acyclic, but if any edge is added to E , the resultinggraph contains a cycle⇒ (1) G is a tree
Suppose that G is acyclic but that if any edge is added to E ,a cycle is created
We must show that G is connected
Let u and v be arbitrary vertices in G
If u and v are not already adjacent, adding the edge (u, v)creates a cycle in which all edges but (u, v) belong to G
Thus, there is a path from u to v , and since u and v werechosen arbitrarily, G is connected
Version of September 23, 2016 Introduction to Graph Algorithms 20 / 20