Graphs & Combinatorial Problems Graphs: - Formal Definition
Graphs & Combinatorial Problems Graphs: - Formal Definition
• A new part of the course – will cover the more • Formal Definition:
theoretical aspects required in later lectures – A graph G is a finite nonempty set V together with an
[irreflexive], symmetric relation E on V
– Graphs, cliques, and colouring
• The relation E relates vertices to other vertices and is known
– Algorithms and intractability as the edge relation, or “edge set”
– Linear programming and integer linear programming • If relation E is symmetric, it means that
– Shortest and longest path algorithms • (a,b)∈E ⇒ (b,a)∈E
• This lecture covers • an edge has no concept of “direction”
• In mathematics, an edge relation is usually considered
– Definition of graph (revision), clique, and clique number
irreflexive:
– Graph colouring, chromatic number • ¬∃a : (a,a)∈E
– Interval graphs – engineers often relax this constraint (hence the brackets)
∑ s(a) = ∑ s(a)
a∈ A ' a∈ A− A '
1/15/2007 Lecture6 gac1 15 1/15/2007 Lecture6 gac1 16
Proving Hardness Example: Scheduling is NP-hard
• An example instance of “partition”: • To finish off, we’ll prove the NP-hardness of an
example problem (a simple form of scheduling)
– A = {v1, v2, v3} with s(v1) = 1, s(v2) = 2, • Our simple scheduling problem has no data
s(v3) = 1 dependencies and only one type of operation
– for this instance, the answer is clearly “yes”:
• A’ = {v2} or A’ = {v1, v3} • Remember that you won’t be asked to do such a
proof for an unseen problem, but this proof has
been included
– for completeness
– to give a more “practical” end to a highly theoretical
lecture
– to justify past and future comments about scheduling
being a “hard” task to perform
1/15/2007 Lecture6 gac1 17 1/15/2007 Lecture6 gac1 18
⎩a∈A' a∈ A− A ' ⎭ 2 a∈A • But this is the “partition” problem. So “partition” is a special
case of our problem and hence our problem is NP-hard
1/15/2007 Lecture6 gac1 21 1/15/2007 Lecture6 gac1 22
Summary
• This lecture has covered
– The definition of an “algorithm”
– Polynomial-time and intractability
– P and NP
– Polynomial reduction, NP-completeness and NP-
hardness
• Next lecture we will look at the (NP-hard!) problem
of Integer Linear Programming (ILP) and how we
can use ILP solving software to help us optimize
our hardware
1/15/2007 Lecture6 gac1 23
[Integer] Linear Programming Mathematical Programming
• Part of our 4-lecture “theory break” • Mathematical “programming” is the name given to
– Graphs, cliques, and colouring
the branch of mathematics that considers the
following optimization problem:
– Algorithms and intractability
– Linear programming and integer linear programming max f ( x), x ∈ S ⊆ R n
– Shortest and longest path algorithms
• Here Rn represents the set of n-dimensional
• This lecture covers
vectors of real numbers, and f is a real-valued
– Mathematical programming, integer / mixed-integer function defined on S. S is the constraint set and f
programming, and linear programming is the objective function.
– Slack variables
• By choosing f and S appropriately, we can model a
– Application example: Capital budgeting wide variety of real-life problems in this way.
∑a x
j =1
ij j ≤ bi , i = 1,..., m; x j ≤ 1, j = 1,..., n
1/15/2007 Lecture7 gac1 9 1/15/2007 Lecture7 gac1 10
Summary
• This lecture has covered
– Mathematical programming, integer / mixed-
integer programming, and linear programming
– Slack variables
– Application example: Capital budgeting
• Next lecture (the last in our “theory break”),
looks at finding the shortest and longest path
through a graph
0 0
DAG example DAG Example
0 0 2. Find_DAG_Path( G(V,E), 1 )
• Let’s assume the vertices are stored in V
1 2 3 in an arbitrary order – say (4,1,2,3,5,0,6) 3. Find_DAG_Path( G(V,E), 2 )
1 2 4. Find_DAG_Path( G(V,E), 3 )
2
4 • A call to DAG_Longest_Path( G(V,E), 0 )
5
will set s0 = 0, and then follow the following 1. Find_DAG_Path( G(V,E), 0)
2 1 execution profile 2. Calculate s3 = 0
6
5. Find_DAG_Path( G(V,E), 5 )
1. Find_DAG_Path( G(V,E), 4 ) 1. Find_DAG_Path( G(V,E), 3)
1. Find_DAG_Path( G(V,E), 1 ) 2. Calculate s5 = 2
1. Find_DAG_Path( G(V,E), 0 ) 6. Find_DAG_Path( G(V,E), 0 )
2. Calculate s1 = 0 7. Find_DAG_Path( G(V,E), 6 )
2. Find_DAG_Path( G(V,E), 2 ) 1. Find_DAG_Path( G(V,E), 4)
1. Find_DAG_Path( G(V,E), 0 ) 2. Find_DAG_Path( G(V,E), 5)
2. Calculate s2 = 0 3. Calculate s6 = 4
3. Calculate s4 = 2
1/15/2007 Lecture8 gac1 7 1/15/2007 Lecture8 gac1 8
General Longest Path Example Edge Set Partition
• Many algorithms to find the longest path of general • Consider our example graph. If we remove the
graphs have been proposed in the literature edges labelled “-1” and “-6”, we obtain a DAG
• We will consider Liao and Wong’s algorithm as it is v1 v1
very efficient for cases where the graph edge set 3 1 3 1
-1 1 1
E ∪ F can be partitioned into a “forward” edge set E v0 -6 v3 v0 v3
and a feedback edge set F where G(V,E) is a DAG
and |E| >> |F| 1 4 1 4
v2 v2
– this is often the case with graphs arising in synthesis –
we will consider some of these in future lectures • The remaining edges form the set E, whereas the
two we removed form the set F
Suggested Problems
• Find the shortest path through the DAG used as an
example in this lecture (*)
• Try to apply the Liao-Wong algorithm to find the
shortest path through the cyclic graph example.
Does it work? If not, why not? (***)
• In the cyclic example, change the weight of edge
(v3,v0) to –4. Now apply Liao-Wong to the shortest
path problem. (*)