Graph Theory
N O M A N I S L A M
Outline
Introduction
Graph Models in Communication and Operating Systems
Representing Graphs in Computers
Graph Coloring
Spanning Trees
Other Problems in Graph Theory
Graph
A graph G(V,E) is mathematical
structure usually represented as a diagram consisting of
points/nodes/vertices V joined by lines/edges E
Vertices may correspond to chemical
elements, towns, terminals)
Edges may correspond to chemical
bonds, roads, wires
Graph theory has applications in
Terminologies
directed & undirected
graph
simple and multigraph vertex and edge
adjacency
in and out-degree
(valency)
bipartite graph path, circuit, loop connected graph complete graph K
n and
Terminologies (contd)
weighted graph
Euler cycle and
Hamiltonean cycle
tree and forest
spanning tree
Weighted Graph with Hamiltonean Cycle
A,B,C,D,E,A
Spanning Trees of K
Euler Cycle
Graph in Communication
Interconnection network for five processors (a complete graph)
Graph in Operating Systems
New Ready Running
Exit
Blocked
Admit Dispatch
Timeout Release
Event
Occurs Event
Wait
Graph in Operating Systems
0 1 2 3 4
5
Eulerian and Hamiltonean Type
Problems
Eulerian Type Problems
– Diagrams Tracing Puzzles – Mazes
Hamiltonean Type Problems
– Gray Codes
– Traveling Sales Man Problem
A sales person wants to minimize the total traveling cost
to visit all the cities in a territory and return to the starting point. Other applications include routing trucks for
Exercise
Draw the digraphs whose vertices and arcs are as follows.
In each case say if the digraph is a simple digraph.
– a) V = {u, v, w, x}, A = {vw, wu, wv, wx, xu}
– b) V = {1, 2, 3, 4, 5, 6, 7, 8}, A = {12, 22, 23, 24, 34, 35, 67,
68, 78}
– c) V = {n, p, q, r, s, t}, A = {np, nq, nt, rs, rt, st, pq, tp}
Which of the following graphs are Eulerian and/or
Representing Graphs
Adjacency Matrix
aij = 1 if {vi,vj} is an edge of G 0 otherwise
Incidence Matrix
mij = 1 if edge eJ is incident with vi 0 otherwise
0 1 0 1
1 0 1 1
0 1 0 0
1 1 1 0
1 2
4 3
1 0 0 1 0
1 1 0 0 1
0 1 1 0 0
0 0 1 1 1
1
4 5 2
3
Exercise
Write down the
adjacency and
incidence matrices of the following graphs and digraphs:
Draw the digraphs
Exercise
How many edges are there in a complete
graph on 5 vertices?
How many edges are there in general in a
Shortest Path Algorithm
In a weighted graph, what is the shortest
path between two given vertices?
In computer network for example, what are
the set of telephone lines that for connecting
Karachi and London gives the least cost or
the fastest communication (Circuit Switching)
Graph Coloring
Assignment of colors to each vertex of graph
so that adjacent vertices have different colors
Least number of colors needed to color a
graph is called chromatic number
Graph Coloring Applications
Scheduling Final Exams
– How can the final exams be scheduled so that no
students has two exams at the same time
– The nodes of graph corresponds to the courses
and there will be links between two nodes if the exam of the two courses can’t be taken
simultaneously
Graph Coloring Applications
Frequency Assignments
– Assigning frequencies to mobile radios and other
users of the electromagnetic spectrum
– Two customers that are sufficiently close must
be assigned different frequencies, while those that are distant can share frequencies
– The nodes of graphs are mobile and there will be
links between two nodes if they can’t use the same frequencies
– The problem of minimizing the number of
Graph Coloring Applications
Register Allocation
– Assign variables of a program to a limited number
of hardware registers during program execution
– The goal is to assign variables that do not conflict
so as to minimize the use of non-register memory.
– Create a graph where the nodes represent
Graph Coloring Applications
Aircraft Scheduling
– We have k aircrafts and we have to assign n-flights
– If two flights overlap, we can’t assign same aircraft to both
flights
– Vertices of graph corresponds to flights, two vertices are
connected if corresponding time intervals overlap
– Assignment of colors means assignment of aircrafts
– Graph Coloring will then try to minimize the number of
Graph Coloring Algorithms
Graph Coloring is NP-Complete problem
Sequential Coloring – Always colors the next
vertex with the minimum acceptable color
(i.e. the minimum color not already assigned
to a vertex adjacent to v
i)
Sequential Color Interchange
Spanning Tree
A sub-graph of a graph that is a tree
containing every vertex of G
Spanning Tree Applications
IP Multicasting
– Unicasting, Multicasting, Broadcasting
– Multicasting means to send data from on
computer to a set of other computers
– Instead of unicasting to each source individually,
Exercise
Find all the spanning trees in each of the two
graphs shown:
Prove that any tree is bipartite
Show that any tree can be colored with two
Some Other Graph Problems
Vertex Cover Problem – A subset of vertices such
that each edge is incident upon some vertex in C
(what is the minimum number of sentries that can be posted at intersections such that all corridors are
monitored)
Clique Problem – A subset of vertices K such that
every pair of distinct vertices in K is joined by an edge of G
Some Other Graph Problems
C
C C
I
I
I
K
K
K
Vertex Cover Independent Set
References
URLs
– ‘Graph Theory Glossary’, http://www.utm.edu
– ‘Graph Theory Glossary’, http://exchange.manifold.net
– ‘Graph coloring applications’, http://mat.gsia.cmu.edu
/COLOR
– http://www.personal.kent.edu/~rmuhamma/GraphTheory/gr
aphTheory.htm