let@token GRAPH ALGORITHMS 0.3cm Week 3 @let

GRAPH ALGORITHMS
Week 3 (17-22 October 2016)
C. Croitoru
[email protected]
FII
October 16, 2016
1 / 57
OUTLINE
Graph Theory Vocabulary
1
2
3
4
5
6
7
8
9
Definition of a Graph
Variations in the Definition of a Graph
Degrees
Subgraphs
Graph Operations
Graph Classes
Paths and Circuits
Associated Matrices
Data Structures
Path Problems in (Di)Graphs
1
2
3
(Di)Graph Traversal
Shortest Paths Problems
Connectivity
Exercises for the next week Seminar (24-29 October 2016)
2 / 57
Vocabulary – 8. Associated Matrices
Adjacency Matrix
Let G = ({v1 , . . . , vn }, {e1 , . . . , em }) be a graph with a fixed ordering of
vertex/edge set. The adjacency matrix of G is the matrix A = (aij )n×n ,
where
(
1 if vi and vj are adjacent
aij =
0 otherwise.
Example. A graph and its adjacency matrix.
5
1
5
1 7 2 3 4
6
2
4
3

0
1

A=
1
0
0
1
0
0
1
1
1
0
0
1
1
0
1
1
0
1

0
1

1

1
0
4 / 57
Vocabulary – 8. Associated Matrices
Incidence Matrix
Let G = ({v1 , . . . , vn }, {e1 , . . . , em }) be a graph with a fixed ordering of
vertex/edge set. The incidency matrix of G is the matrix B = (bij )n×m ,
where
(
1 if ej is incident with vi and ej
bij =
0 otherwise.
Example. A graph and its incidency matrix.
5
1
5
1 7 2 3 4
6
2
4
3

0
1

B=
0
0
1
0
0
1
0
1
0
1
0
1
0
0
0
1
1
0
0
0
0
1
1
1
0
1
0
0

1
1

0
.
0
0
6 / 57
Vocabulary – 8. Associated Matrices
Digraphs
For digraphs, similar matrices can be defined with entries in {−1, 0, 1} in
order to point out the direction of edges.
Spectral theory
The eigenvalues, eigenvectors and the characteristic polynomial of the
adjacency matrix are called eigenvalues, eigenvectors, respectively
characteristic polynomial of the graph.
8 / 57
Vocabulary – 9. Data Structures
Adjacency matrix
Let G = (V , E ) be a (di)graph with V = {1, 2, . . . , n} and |E | = e.
If A = (aij )n×n is the adjacency matrix of G then, representing it as a
2-dimensional array, we need O(n2 ) time for initialization.
Hence any algorithm that represents G with the adjacency matrix has
Ω(n2 ) time (and space) complexity.
Testing if two vertices are adjacent is done in O(1) time, but passing
through the set of neighbors NG (v ) (or NG+ (v )), for an arbitrary vertex
v ∈ V , needs Ω(n) time – unpractical in large sparse (di)graphs.
9 / 57
Vocabulary – 9. Data Structures
Adjacency List
Let G = (V , E ) be a (di)graph with V = {1, 2, . . . , n} and |E | = e.
Every vertex v ∈ V has a list A(v ) of its neighbors in G .
If G is a graph then A(v ) contains NG (v ) = {w |w ∈ V and vw ∈ E } and
if G is a digraph then A(v ) contains NG+ (v ) = {w |w ∈ V and vw ∈ E }.
If G is a graph then each edge vw ∈ E generates 2 nodes in the adjacency
lists (one in A(v ) and the other in A(w )): the space needed is O(n + 2e).
If G is a digraph then the space needed is O(n + e).
Adjacency lists can be implemented using linked lists or using arrays.
Testing if a vertex v is adjacent to another vertex w in G needs Ω(dG (v ))
time, but passing through the set of neighbors NG (v ) (or NG+ (v )), for an
arbitrary vertex v ∈ V , can be done in Ω(dG (v )) time (and not in O(n)
time as in the case of adjacency matrix).
10 / 57
Vocabulary – 9. Data Structures
Adjacency List
Example. Adjacency list representation of the digraph below.
3
2
3 A(2)
5
3
A(3)
6
1
2
5
A(1)
6
A(5)
A(6)
11 / 57
PATH PROBLEMS IN (DI)GRAPHS
12 / 57
Path Problems – Graph traversal
Graph traversal
Graph traversal or graph search is an algorithmic paradigm specifying a
systematic method to pass through the set of vertices reachable by paths
starting from a specified vertex in a (di)graph.
Given a (di)graph G = ({1, . . . , n}, E ) and s ∈ V (G ), generate
”efficiently” the set
S = {v |v ∈ V (G ) and there is a path from s to v }.
G is represented with adjacency lists, because, during the visiting process,
we need to handle in a efficient way the set of neighbors of the current
vertex.
13 / 57
Path Problems – Graph traversal
BFS – Breadth-First Search
G = ({1, . . . , n} ( d i ) graph , s ∈ {1, . . . , n}
Each vertex v has an integer label label(v ) < 0
label(s) ← 0 ; parent(s) ← 0 ;
create queue Q containing s ;
while Q 6= ∅ do
{ let v be the top vertex in the queue Q ;
delete the top vertex in Q ;
for w ∈ A(v ) do
if label(w ) < 0 then
{ label(w ) ← label(v ) + 1 ;
parent(w ) ← v ;
insert w into the queue Q }
}
14 / 57
Path Problems – Graph traversal
BFS – Breadth-First Search
Properties. It is not difficult to prove that:
S = {v ∈ V |label(v ) ≥ 0}.
∀v ∈ V label(v ) = dG (s, v ) (distance in G from s to v );
Variable parent defines the bfs-tree associated to the search from s:
if G is a graph then the bfs-tree is a spanning tree of the connected
component containing s; if G is a digraph then the bfs-tree is an
arborescence (directed rooted tree in which all edges point away
from the root s).
The time complexity of BFS(s) is O(nS + mS ), where
nS = |S| ≤ |V | = n, and mS = |E ([S]G )| ≤ |E | (this follows easily by
observing that each node in the adjacency list of a vertex from S is
accessed exactly once).
15 / 57
Path Problems – Graph traversal
BFS – Breadth-First Search
Example:
3
2
3 A(2)
5
3
A(3)
6
1
2
5
A(1)
6
2 0
0 1
1 3
1 2
2 6
2 5
5 1 3 1
6
2
A(5)
A(6)
16 / 57
Path Problems – Graph traversal
DFS – Depth-First Search
G = ({1, . . . , n} ( d i ) graph , s ∈ {1, . . . , n}
Each vertex v has an integer label label(v ) < 0
Each adjacency list A(v ) will be traversed using an iterator next[A(v )]
label(s) ← 0 ; parent(s) ← 0 ;
create stack S containing s ; nS ← 0 ;
while S 6= ∅ do
{ let v be the top vertex in the stack S ; w ← next[A(v )] ;
if w exists then
if label(w ) < 0 then
{ label(w ) ← nS ; nS ++ ;
parent(w ) ← v ;
insert w into the stack Q }
else NOP
can be used !!
else delete v from (the top of) S
the search from v is finished
}
17 / 57
Path Problems – Graph traversal
DFS – Depth-First Search
Properties. It is not difficult to prove that:
{v ∈ V |label(v ) ≥ 0} is exactly the set S of the vertices reachable by
paths from s in G .
∀v ∈ V label(v ) = visiting time of v (s has visiting time 0);
Variable parent defines the dfs-tree associated to the search from s.
The time complexity of DFS(s) is O(nS + mS ), where
nS = |S| ≤ |V | = n, and mS = |E ([S]G )| ≤ |E | (this follows easily by
observing that each node in the adjacency list of a vertex from S is
accessed exactly once).
18 / 57
Path Problems – Graph traversal
DFS – Depth-First Search
Example:
3
2
3 A(2)
5
3
A(3)
6
1
2
5
A(1)
6
2 0
0 1
1 3
3 2
2 6
4 5
51 32
6
3
A(5)
A(6)
19 / 57
Path Problems – Shortest Paths
Notations
Let G = (V , E ) be a digraph, with V = {1, . . . , n}. Each directed edge
e ∈ E has associated a cost a(e) ∈ R (weight, length, . . .).
If G is represented with adjacency lists, then a(ij) is a field in the node of
adjacency list of i (reprenting ij). For ease of notation we will use the
representation of G with the cost-adjacency matrix A = (aij )n×n ,
(
a(ij) if ij ∈ E
aij =
∞
otherwise
Here, ∞ denotes a big real number with respect to actual edge costs (e.g.,
∞ > n × maxij∈E a(ij)) and we suppose that ∞ ∓ a = ∞, ∞ + ∞ = ∞.
(It is also possible to use ∞ as an unsuccessful access to the data
structure used to represent the matix A).
20 / 57
Path Problems – Shortest Paths
Notations
For i, j ∈ V , the set of all paths in G from i to j is denoted by Pij :
Pij = {Pij | Pij path in G from i to j}.
If Pij ∈ Pij , Pij : (i =)v0 , v0 v1 , v1 , . . . , vr −1 , vr −1 vr , vr (= j), its set of
vertices is V (Pij ) = {v0 , v1 , . . . , vr } and its set of arcs (directed edges) is
E (Dij ) = {v0 v1 , v1 v2 , . . . , vr −1 vr }.
Any vertex k ∈ V (Pij ), k =
6 i, j, splits Pij in two paths Pik ∈ Pik and
Pkj ∈ Pkj . We denote Pij = Pik ◦ Pkj .
The cost of a path Pij ∈ Pij is
a(Pij ) = 0 +
X
auv .
uv ∈E (Pij )
In particular, we have a(Pii ) = 0.
21 / 57
Path Problems – Shortest Paths
Main Shortest Path Problems
Single-pair shortest path problem.
P1: Given G digraph; a : E (G ) → R; s, t ∈ V (G ), s 6= t.
Find Pst∗ ∈ Pst , such that a(Pst∗ ) = min{a(Pst ) | Pst ∈ Pst }.
Single-source shortest path problem.
P2: Given G digraph; a : E (G ) → R; s ∈ V (G ).
Find Psi∗ ∈ Psi , ∀i ∈ V (G ), such that a(Psi∗ ) = min{a(Psi ) | Psi ∈ Psi }.
All-pairs shortest path problem.
P3: Given G digraph; a : E (G ) → R.
Find Pij∗ ∈ Pij ∀i, j ∈ V (G ), such that a(Pij∗ ) = min{a(Pij ) | Pij ∈ Pij }.
22 / 57
Path Problems – Shortest Paths
Main Shortest Path Problems
Remarks.
1
The cost-adjacency matrix representation of the pair G , a implies that
Pij 6= ∅ ∀i, j ∈ V : if a(Pij ) < ∞ then Pij is a true path in G and if
a(Pij ) = ∞ then Pij is not a path in G but it is a path in the
complete symmetric digraph obtained from G by adding all missing
arcs (with ∞ costs).
It follows that all sets over which a minimum cost element is required
in the problems P1-P3 are non-empty and finite and all minimum
paths required are well-defined.
2
The algorithms for solving the problem P1 are obtained from those
solving the problem P2 by adding an (obvious) stopping test.
3
The problem P3 can be solved by iterating any algorithm for the
problem P2. We’ll see that there are more efficient solutions.
23 / 57
Path Problems – Shortest Paths
Applications
1. Communication Networks. The digraph G = (V , E ) represents a
communication network between the nodes in V and with E modeling the
set of directed links between nodes.
If a(e) ≥ 0 (for all e ∈ E ) represents the length of the direct connection
between the extremities of e, then the problems P1-P3 are natural
shortest paths problems.
If a(e) ≥ 0 (for all e ∈ E ) represents the time needed for the direct
connection between the extremities of e, then the problems P1-P3 are
natural fastest paths problems.
If a(e) ∈ (0, 1] (for all e ∈ E ) represents the probability that the direct
connection between the extremities of e works properly, and we suppose
that edges works properly independent of each other, then the problems
P1-P3 become most reliable paths problems:
24 / 57
Path Problems – Shortest Paths
Applications
If Pij ∈ Pij for some pair i, j ∈ V , then the probability that this path
works properly is (by the independence assumption)
Y
Prob(Pij ) =
a(e).
e∈E (Pij )
By taking a0 (e) := − log(a(e)),
log(Prob(Pij )) = log(
Y
e∈E (Pij )
a(e)) = −
X
a0 (e).
e∈E (Pij )
By the monotony of the log function it follows that the problems P1-P3,
with costs a0 , give the most reliable paths in the communication network.
25 / 57
Path Problems – Shortest Paths
Applications
2. PERT Networks – Critical Path Method (CPM).
PERT (Project Evaluation and Review Technique) is a method to analyze
(especially) the completion time of each task in a given complex project.
Let P = {A1 , . . . , An } be the set of atomic activities of a large project P (n
is big). (P, <) is a partially ordered set, where Ai < Aj if i 6= j and activity
Aj can be started only after the activity Ai was finished. For each activity
Ai , its completion time ti is given (estimated). Find a scheduling of the
activities of the project to minimize its total completion (calendar) time.
We can associate a directed acyclic graph to the problem in this way: to
each activity Ap (p ∈ {1, . . . , n} we add an arc ip jp with cost a(ip jp ) = tp .
The node ip corresponds to the beginning event of Ap and the node jp is
associated to the finishing event of it. If an activity Ak can start
immediately after the activity Ap we add the arc jp ik (dummy activity).
26 / 57
Path Problems – Shortest Paths
Applications
The construction of digraph is finished after adding a node s corresponding
to the start event of the project linked by arcs sip for each activity Ap
with no incoming arcs, and a node t corresponding to the terminal event
of the project linked by arcs jp t for each activity Ap with no outgoing arcs.
In the digraph obtained, the maximum cost of a path from s to t is equal
to the minimum completion time of the project. A maximum cost path is
called a critical path since any delay of an activity on this path infers a
delay of the whole project.
A4: t4
0
0
A1: t1
A8: t8
0
A5: t5
0
0
0
0
0
End
A2: t2
Start
A9: t9
0
0
A6: t6
A3: t3
0
0
0
0
0
A10:t10
A7: t7
0
27 / 57
Path Problems – Shortest Paths
Applications
Knapsack Problem (0-1) We are given a knapsack of size b ∈ Z+ , and n
objects of sizes a1 , . . . , an ∈ Z+ . Also is known the profit pi ∈ Z+ of
inserting the object i (i ∈ {1, . . . , n} into the knapsack. We are asked to
choose a filling of the knapsack of maximum total profit.
Let xi ∈ {0, 1}, for i ∈ {1, . . . , n}, be a boolean variable having the
meaning that xi = 1 if and only if the object i is inserted into the
knapsack. Then the knapsack problem can be stated as
n
n
X
X
max
pi xi |
ai xi ≤ b, xi ∈ {0, 1}∀i = 1, n .
i=1
i=1
Let G = (V , E ) the digraph with V = {s} ∪ V1 ∪ V2 ∪ . . . ∪ Vn ∪ {t},
where the set Vi = {i 0 , i 1 , . . . , i b } is associated to object i, i = 1, n.
28 / 57
Path Problems – Shortest Paths
Applications
The arcs of G and their costs are:
s10 and s1a1 with a(s10 ) = 0 and a(s1a1 ) = p1 ( either the object 1 is
inserted in the knapsack with profit p1 and filling level a1 , or it is not
inserted, with the profit and fitting level 0).
∀i = 2, n ∀j = 0, b: (i − 1)j i j with a((i − 1)j i j ) = 0 (the object i is not
inserted into knapsack: from the filling with the first i − 1 objects and filling
level j, we pass to a filling with the first i objects, without object i; the
filling level remains j and the additional profit is 0).
j−ai i j with
If j − ai ≥ 0 then
we have also the arc (i − 1)
j−a
j
a (i − 1) i i = pi (we can arrive at the filling level j by inseting the
object i to a filling with the first i − 1 objects, with the filling level j − ai ).
∀j = 0, b: nj t with a(nj t) = 0.
29 / 57
Path Problems – Shortest Paths
Applications
Remark. Each path from s to t in G corresponds to a subset of objects
with the filling level ≤ b and with the total profit equal to the cost of the
path. Since, conversely, to each filling of the knapsack corresponds a path
from s to t in G , it follows that the knapsack problem can be solved by
finding a path of maximum cost in the directed acyclic graph G .a
0
s
0
1:0
2:0
n:0
2:1
n:1
2:a2
n:2
0
p2
p1
1:1
0
0
0
t
0
1:a1
2:a1
p2
0
2:a1+a2
0
1:b
a
2:b
n:b
The static description given above for G can be transformed into a procedural one,
giving the usual dynamic programming solution. Note that the problem is NP-hard
(the order of G could be exponential in the input size of the problem).
30 / 57
Path Problems – Shortest Paths
Solving P2
P2: Given G digraph; a : E (G ) → R; s ∈ V (G ).
Find Psi∗ ∈ Psi , ∀i ∈ V (G ), s.t. a(Psi∗ ) = min{a(Psi ) | Psi ∈ Psi }.
Theorem 1.
Let G = (V , E ) be a digraph, V = {1, . . . , n}, s ∈ V and a : E → R, s.t.
(I )
a(C ) > 0, for all C circuit in G .
Then, (u1 , . . . , un ) is a solution of the nonlinear system of equations
(
(B)
us = 0
ui = min (uj + aji )
j6=i
∀i 6= s.
if and only if
∀i ∈ V , ∃Psi∗ ∈ Psi s.t. a(Psi∗ ) = ui and a(Psi∗ ) = min{a(P) | P ∈ Psi }.
32 / 57
Path Problems – Shortest Paths
Proof of Theorem 1.
”⇐” Let Psi∗ optimal solutions of P2 and ui = a(Psi∗ ) (i ∈ V ).
The hypothesis (I) implies that us = 0, i.e. the first equation of the
system (B) is satisfied. For i 6= s, the path Psi∗ has a penultimate vertex j.
If Psj is the path from s to j determined on Psi∗ by j, we have
ui = a(Psi∗ ) = a(Psj ) + aji ≥ a(Psj∗ ) + aji = uj + aji .
We show that ui = uj + aji . Suppose that ui > uj + aji , i.e. a(Psj ) > a(Psj∗ ).
Case 1. i 6∈ V (Psj∗ ). Then P 1 = Psj∗ ◦ (j, ji, i) ∈ Psi and
a(P 1 ) = a(Psj∗ ) + aji < a(Psj ) + aji = a(Psi∗ ), a contradiction (Psi∗ is a
shortest path).
Dsj
j
i
s
D*
sj
33 / 57
Path Problems – Shortest Paths
Proof of Theorem 1.
Case 2. i ∈ V (Psj∗ ). Let Psj∗ = Psi ◦ Pij the two paths determined by the
vertex i on Psj∗ . Then the cost of the circuit C = Pij ◦ (j, ji, i) is
a(C ) = a(Pij ) + aji = a(Psj∗ ) − a(Psi ) + aji = uj + aji − a(Psi ) ≤
uj + aji − a(Psi∗ ) = uj + aji − ui < 0, a contradiction (the hypothesis (I) is
Dij
violated).
Dsj
C
j
i
s
D*
sj
Hence the ⇐ part of the theorem is proved.
Remark. We proved above that if j is the vertex before i on a shortest
path from s to i, then the path from s to j determined by j on this
shortest paths is a shortest path from s to j. Inductively, it follows:
Bellman’s Principle of Optimality: If Psi∗ is a shortet path from s to i,
then ∀j ∈ V (Psi∗ ), if dacă Psi∗ = Psj ◦ Pji then Psj (respectively Pji ) is a
shortest path from s to j (respectively from j to i).
34 / 57
Path Problems – Shortest Paths
Proof of Theorem 1.
”⇒” We show that if (u1 , . . . , un ) is a solution of (B), then
(a) ∃Psi ∈ Psi such that ui = a(Psi ), ∀i ∈ V .
(b) ∀i ∈ V , ui = min{a(P) | P ∈ Psi }(= a(Psi∗ )).
(a) If i = s, then us = 0 and the path Pss satisfies a(Pss ) = 0 = us .
If i 6= s, let us consider the following algorithm
v ← i; k ← 0;
while v 6= s do
{ find w such that uv = uw + awv ;// ∃w since uv satisfies (*)
ik ← v ; k + +; v ← w
}
ik ← s
The algorithm find the path P : (s =)ik+1 , ik+1 ik , . . . , i1 , i1 i0 , i0 (= i) with
P ∈ Psi and a(P) = a(ik+1 ik ) + · · · + a(i1 i0 ) = (uik − uik+1 ) + (uik−1 − uik )
+ · · · + (ui0 − ui1 ) = ui0 − uik+1 = ui − us = ui . In each while iteration
w 6∈ {i0 , . . . , ik−1 } (else we get a circuit of cost 0, violating the hypothesis (I)).
35 / 57
Path Problems – Shortest Paths
Proof of Theorem 1.
Note that (with the notations in the above algorithm ) we have ui = ui1 + ai1 i .
(b) Let u i = a(Psi∗ ) ∀i ∈ V . By the part ”⇐” of the proof, u i , i = 1, n,
satisfy the system of equations (B).
Suppose that u = (u1 , . . . , un ) 6= u = (u 1 , . . . , u n ).
Since us = u s = 0, it follows that there is i 6= s such that ui 6= u i and
∀j ∈ V (Psi ), j 6= i, uj = u j , where Psi is the path constructed in (a) for
u i . Then ui > u i = u i1 + ai1 i = ui1 + ai1 i ≥ ui ( the first inequality holds
by the choice of i, the second holds since ui satisfies (B)).
The contradiction found shows that u = u, that is the components of u
are shortest paths costs.
36 / 57
Path Problems – Shortest Paths
Remarks
From the above proof it follows that for solving P2 is sufficiently to
found a solution of the system of equations (B). The corresponding
shortest paths can be obtained as in part (a) of the proof: if we have
ui = uk + aki then k is the vertex before i on the shortest path from s
to i (of cost ui ). In the algorithm that solves (B) we maintain an
array before[1..n] with entries from V ∪ {0, } with the final meaning
before[i]= the vertex before i on the shortest path from s to i. The
vertices of this path can be found in O(n) time by constructing the
sequence i, before[i], before[before[i]], . . ., s.
If the algorithms solving the system of equations (B) circumvent (by
the maintenance of the array before) 0-cost circuits, then the
problem P2 is solved, even the unicity of the solution is lost. Hence
these algorithms will solve P2 in the hypothesis
(I 0 )
a(C ) ≥ 0, ∀C circuit in G .
37 / 57
Path Problems – Shortest Paths
Remarks
If, in the problems P1-P3, G is a graph and not a digraph, we can use the
algorithms for digraphs by replacing each (undirected) edge of G with a
symmetric pair of arcs, each having the cost of the edge. Note that this
approach works only for non-negative costs of the edges (if an edge has
negative cost, then the 2-circuit formed by the two symmetric arcs replacing
the edge has negative cost, hence hypothesis (I’) is not satisfied).
Since the sets Dij are finite (and non-empty), we can consider
problems similar to P1-P3 by replacing min with max.
The use of the obvious relation maxx∈A x = −(minx∈A (−x)), by
replacing the costs aij by −aij , works only for digraphs in which, for
each circuit C , we have a(C ) ≤ 0 (in particular, this approach works
for digraphs without circuits). If the digraph has circuits, longest
path problems are in general NP-hard.
38 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
Most of the exercises for this seminar are very easy, their purpose is solely
for practicing the terminology introduced in the lecture.
1
Let us consider three graphs, G1 , G2 , G3 , such that G1 ∼
6 G2 and G2 ∼
6 G3 .
=
=
∼
True or false: G1 =
6 G3 ? You must provide a proof for the answer true
or a counterexample for the answer no.
2
Are the two graphs below isomorphic? (justify your answer)
39 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
3
Prove that if G is a connected graph having exactly one circuit then
|G | = |E (G )|.
4
Find the stability number, α(G ), of the graph G below (justify your
answer).
5
Let G be a connected graph with |G | > 1 and without leaf vertices. Prove
that |E (G )| ≥ |G |.
40 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
6
Let G = (V , E ) be a connected graph with |G | ≥ 2. Prove that there is at
least one vertex v0 ∈ V that is not a cut vertex.
7
There are graphs having just one spanning tree? There are graphs having
exactly 2 spanning trees? (justify your answers)
8
Draw the graph L(L(G )), where G is:
41 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
9
If G is the graph below, is its line graph, L(G ), a Hamiltonian graph?
(justify your answer)
10
Find the chromatic number, χ(G ), of the complement of the above graph.
11
Find the vertex conectivity number, k(G ), of the graph G in the exercise 9.
42 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
12
Is the graph below self-complementary? (justify your answer)
13
Has the above graph two spanning trees without common edges? (justify
your answer)
14
Find the number of spanning trees of the complement of the graph in
exercise 12. (justify your answer)
43 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
15
Find the maximum cardinality of a stable set in the graph K2 × G , where
G is the graph depicted in the exercise 12.
16
If G is the graph below, is L(G ) a Hamiltonian graph? (justify your
answer)
17
For the above graph, G , find the chromatic number χ(G ). (justify your
answer)
44 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
18
Is the graph from exercise 16 isomorphic with its complement? (justify
your answer)
19
Find the vertex connectivity number of the graph in exercise 16. (justify
your answer)
20
Find the diameter of the graph in exercise 16. (justify your answer)
21
Find the chromatic index of the graph in exercise 16. (justify your answer)
45 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
22
Prove that if G is the line graph of a graph H (G = L(H)) then G is a
K1,3 -free graph.
23
Draw the graph P4 × K2 and find its chromatic number. (justify your
answer)
24
Is it true that α(G ) ≤ k(G ) for the graph G below? (justify your answer)
46 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
25
Let G be a connected graph with the property that the dfs and bfs trees
starting from the same root vertex are equal. Can G have citcuits? (justify
your answer)
26
Prove that if NG (u) ∪ NG (v ) = V (G ) for all u, v ∈ V (G ), u 6= v , then G
is a complete graph.
27
Prove that if a graph G has exactly 2 odd degree vertices, then there is in
G a path between these 2 vertices.
28
Let G = (V , E ) be a graph with the property that dG (v ) + dG (w ) ≥ |V | − 1,
∀ v , w ∈ V , v 6= w . Prove that the diameter of G is not greater than 2.
47 / 57
Exercises for Next week (24 Oct - 29 Oct) Seminar
29
Let G = (V , E ) be a connected graph with all vertices of even degree.
Prove that the graph G − e is connected, ∀e ∈ E .
30
Let G = (V , E ) be a graph with at least 3 vertices. Prove that G is
connected if and only if there are two vertices u, v ∈ V (u 6= v ) such that
the graphs G − u and G − v are connected.
31
If H = (V (H), E (H) is a graph, we denote by e(H) the size of H
(e(H) = |E (H)|).
Prove that for every graph G with at least 3 vertices we
P
have e(G ) =
e(G −v )
.
|V (G )|−2
v ∈V (G )
48 / 57