Lecture 1

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 50

1

GRAPH-THEORY

Dr. Ilyas Fakhir


Konigsberg Bridge Problem
2

A Rules
.1

B D .2

C
Your solution
33

Did it every time .1


Did it at least once .2
Can’t seem to do it .3
Introduction to Graphs 6.1
Konigsberg Bridge (8th bridge)
44

Introduction to Graphs 6.1


Your solution
55

Did it every time .1


Did it at least once .2
Can’t seem to do it .3
Introduction to Graphs 6.1
Konigsberg Bridge (9 bridge) th

Introduction to Graphs 6.1


Your solution
77

Did it every time .1


Did it at least once .2
Can’t seem to do it .3
Introduction to Graphs 6.1
Cases for Konigsberg 3
8

Bridges (Non-traversable) 7 .1 .1 Picture

Bridges (Euler Path) 8 .2 Picture

Bridges (Euler circuit) 9 .3


Picture
Euler’s View
99

Map Graph

A
B
C

Introduction to Graphs 6.1


You try one
A Graph

River
Island
Island
B C

10 Introduction to Graphs 6.1


Motivation
11

 What is the common link between the following


problems: traffic network design and cancer
research?
 Arranging marriages and scheduling flights?
 Finding cure for mental illness, computer chip
design, architectural floor planning, fighting terror
online?
 Fighting epidemics, e-commerce, designing voting
schemes, job assignment, designing electrical
networks, deciding on facility location,
communication networks etc.
?What is Graph Theory
12

Definition: The mathematical theory of the properties


.and applications of graphs

Used to understand and solve


many of mathematical and path
.problems
Fields of Study
13

The cells of a GSM Mathematical


mobile phone network problem

:Other examples

.Electrical eng •
Biochemistry •
Music Computer science •
Physics •
Applications in computer Science
14
(1)
Since computer science is not a concrete/centralized
.subject, we can introduce graph theory in many areas

But where

…Let’s see some examples


Applications in computer Science
15
(2)
Networks: Graph theory can be used in computer
networks, for security purpose or to schematize network
.topologies, for example
Applications in computer Science
16
(3)
Webpage: can be represented by a directed graph.
The vertices are the web pages available at the
website and a directed edge from page A to page B
.exists if and only if A contains a link to B

Facebook is based in
graph theory
Applications in computer Science
17
(4)
Workflow: It’s sequence of processes through which a
piece of work passes from initiation to completion. Can
.be also represented as directed graph
Applications in computer Science
18
(5)
Neural Networks: A series of algorithms that
attempt to identify underlying relationships in a set
of data by using a process that mimics the way
.the human brain operates
Applications in computer Science
19
(6)
:Google Maps
Graph Operations (1)
20

Basic Operations
Graph Operations (2)

Shortest Path: is the problem of finding a path between


two vertices (or nodes) in a graph such that the sum of
the weights of its constituent edges is minimized. E.g.
Dijkstra’s algorithm
?What is a graph
22

 A set of points and lines joining these points.


 Formally: G=(V,E), V-vertices V(G), E-edges E(G)
 The cardinality of V, is the number of vertices
denoted by n or nG and cardinality of E, is the
number of edged denoted by m or mG.
e6
v1
v4 V2 and v3 are adjacent.
v3 e2 is incident with v2
e1
e2 e3 and V3.
e5
v2
v5
e4
Representation
23

 It is both usual and practical to draw a graph in a


plane in the following manner: the vertices are
represented by dots and the edges by simple
lines (which can be mathematically defined with
precision) connecting two endvertices.
 In previous example V = {v1, v2, v3, v4, v5} and
E = {e1, e2, e3, e4, e5, e6}.
 Vertex v4 is isolated vertex and edge e6 is
associated twice with the vertex v1 (loop)
Terminology
24

 Two edges e and e’ or more may have the same


endvertices x and y; then these edges are said to be
parallel or there may be a multiple edge joining x
and y.
 A graph is simple if it has no loop or multiple
edges, i.e. each edge is identified by its pair of
endvertices, which are different, and denoted by e
= xy.
 A non-simple graph G is sometimes associated with
what is called the underlying simple graph.
Isomorphism
25

 Isomorphism of graph G = (V, E) to a graph H = (W,


F) is two bijection: φ from V onto W and ψ from E to
F, so that for e ∈ E and x, y ∈ V, the edge ψ(e) has
for endvertices φ(x) and φ(y) in H if and only if the
e has x and y as endvertices in G.
 This means that these mappings preserve the
incidence relation of the edges the vertices.
 Two isomorphic graphs are in fact identical in their
graph structure.
Isomorphism
26

 They have exactly the same properties.


 They can only be distinguished by the sets of their
elements, vertices and edges, in more concrete
terms,
by the names or labels given to these elements.
Isomorphism
27

 Next, set f (1) = 1 and try to walk around


clockwise on the star.
2 2

1 1 3
3

5 4 5 4
Presentations of graphs
28

 Drawing v3
e2
v4
e3

e5
 Incidence matrix v2
e4 v5

e1 e6
v1
e6 e5 e4 e3 e2 e1
2 0 0 0 0 1 v1
0 0 1 0 1 1 v2
Degree of a vertex,
0 1 0 1 1 0 v3
Regular graph
0 0 0 0 0 0 v4 Hand shaking lemma
0 1 1 1 0 0 v5
Presentations of graphs
29

 Adjacency matrix v3
e2
v5 v4 v3 v2 v1 v4
0 0 0 1 2 v1 e3

1 0 1 0 1 v2 e4 e5
v5
v2
2 0 0 1 0 v3
e1 e6
v1
0 0 0 0 0 v4

0 0 2 1 0 v5
Directed Graphs
30

e2 v3
v4
 Adjacency matrix e3

v5 v4 v3 v2 v1 e4 e5
v5
0 0 0 0 1 v2
v1
e1 e6
0 0 1 0 1 v2 v1

1 0 0 0 0 v3

0 0 0 0 0 v4

0 0 1 1 0 v5
Weighted Graphs
31

2 v3
v4
 Adjacency matrix 2
5
v5 v4 v3 v2 v1 3 v5
0 0 0 0 3 v2
v1
1 3
0 0 2 0 1 v2 v1

2 0 0 0 0 v3

0 0 0 0 0 v4

0 0 5 3 0 v5
Graphs as models
32

 Networks: transportation, roadmaps, computer,


electrical, etc.
Graphs as models
33

 Personnel
assignment
problems.
(assigning people to
jobs, arranging
weddings, finding
appropriate
roommates, etc.)
 Social networks.
Graphs as models
34

 Personnel assignment problems. (assigning people to


jobs, arranging weddings, finding appropriate
roommates, etc.)
 Social networks.
 VLSI chip design. (Planar graphs, visibility,…)
 Geometric polyhedra (Rigidity of structures,)
 Chemistry
 Biology
Graphs as models (cont.)
35

 Ecosystems (food web…)


 Scheduling and timetabling problems
 Puzzles and games
 Many others
Matching Problem
36

women men
w1 m1

w2 m2

w3 m3

w4 m4

w5 m5

Definition: A matching is a set of disjoint edges


in a graph. A matching is perfect if it meets every
vertex in the graph..
Matching Problem
37

women men

w1 m1

w2 m2

w3 m3

w4 m4

w5 m5

Is this a maximum matching?


Assignment Problem
38

workers machines

w1 1 m1
3
1
w2 2 m2
1.5
2
w3 2 m3

1.7 4
w4 m4
3
2
w5 m5

Find a minimum (maximum) cost


assignment of workers to machines
Stable Marriage Problem
39

women men

w1 1 m1
1
1 Does there exist a
w2 2 m2 stable marriage?
1.5
2
w3 2 m3

1.7 4
w4 m4
3
2
w5 m5

W2 prefers m5 to her spouse and m5


prefers w2 to his spouse.
Applications
40

 Assigning doctors to hospitals.


 Assigning people to jobs.
 Assigning students to dormitories.
 Assigning pairs of drivers to trucks.
 Etc.
Timetabling problems
41

 m teachers, n classes.
T1 C1
 Teacher i is required to teach
class j for Pij periods. T2 C2
 In a given period a teacher can
be in at most 1 class, and a C3
class can have at most 1
teacher.
 Design a timetable with
Cn
minimum no. of periods.
 Tractable! Tm
Timetabling problems
42

 m teachers, n classes.
T1 C1
 Teacher i is required to teach
class j for Pij periods. T2 C2
 In a given period a teacher can
be in at most 1 class, and a C3
class can have at most 1
teacher.
 Design a timetable with
Cn
minimum no. of periods.
 Tractable! Tm
 Properly color the edges of G
with as few colors as possible.
Edge coloring of graphs
43

 Definition: A proper k- edge coloring of a graph


G=(V,E) is a mapping
 c: E {1,2,…,k} such that adjacent edges
receive distinct colors.
 If the maximum degree is  then clearly k ≥ 
 Theorem (Vizing): Any graph has either a
-coloring or a (+1)-coloring.
 Designing a time-table is a proper edge coloring of
a graph.
 Theorem A bipartite graph has a -coloring
Timetabling problems –
44
complications
 A limited number of classroom are available.
 If there are l lessons scheduled in a p-period
timetable, then how many rooms are needed?
 At least {l/p} rooms are needed.
 It is possible to arrange l lessons in p periods where
at most {l/p} rooms are occupied in any one period.
 More complications: teachers are not available for
every period, they need their tea breaks, etc. etc.
Connector problem
45

 Design a railway network


connecting a number of
cities, with a minimum
possible construction cost.
 Or electrical network, cable
TV, gas, etc.
Connector problem
46

 Design a railway network


connecting a number of cities,
with a minimum possible
construction cost.
 Or electrical network, cable
TV, gas, etc.
 Problem is Tractable
 A variation of it is intractable!
Connector problem: Graph-theory
47

 Definition: A tree is a connected acyclic graph.


 Connected = between any 2 vertices there is a path.
Acyclic = contains no cycles.
 Spanning = contains all the vertices in the graph.
 Connector problem: Given a weighted graph G:
Find a minimum weight spanning tree of G.
Travelling salesman problem
48

Lahore

Intractable!

Faisalabad Hyderabad

Karachi Islamabad

Peshawar

A salesperson begins in Karachi, has to visit all the


cities, and return to Karachi in a shortest possible
distance. (or time, or cost)
Tractable and Intractable
49

 Tractable Problem: a problem that is solvable by a


polynomial-time algorithm. The upper bound is
polynomial.
 Intractable Problem: a problem that cannot be
solved by a polynomial-time algorithm. The lower
bound is exponential.
Travelling salesman problem-
50
Graph Theory
 Given a graph (or a directed
graph), does there exist a cycle
in the graph that contains each
vertex once? (i.e. a Hamilton
cycle)?
 Given a complete weighted
graph, find a Hamilton cycle
of minimum weight.

You might also like