Upload
prakashshr
View
232
Download
0
Embed Size (px)
Citation preview
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
1/31
FUNDAMENTAL PROBLEMS
AND
ALGORITHMS
Graph Theory and Combinational
Giovanni De Micheli
Stanford University
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
2/31
Shortest/Longest path problem
Single-source shortest path problem.
Model:
Directed graph G(V, E)with Nvertices.
Weightson each edge.
A sourcevertex.
Single-source shortest path problem.
Find shortest path from the source to any vertex.
Inconsistent problem:
Negative-weighted cycles.
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
3/31
Shortest path problem
Acyclic graphs: Topological sort O(N 2 ).
-
All positive weights:
Dijkstras algorithm.
Bellmans equations:
G(V, E)with Nvertices
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
4/31
Dijkstras algorithm
DI JKSTRA(G(V, E, W))
{s 0=0;
for (i =1 to N)
si= w 0,i,
repeat {
select unmarked vqsuch that sqis minimal;
mark vq;
foreach (unmarked vertex v i)si= min {si, (sq+w q, i)},
}
until (all vertices are marked)
}
Apply to
Koreas map,
robot tour, etc
G(V, E)with Nvertices
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
5/31
Bellman-Fords
algorithmBELLMAN_FORD(G(V, E, W))
{
s10= 0;
for (i = 1 to N)
s 1i =w 0, i;
for (j =1 to N){for (i =1 to N){
s j+1i = min {sji, (s
jk+w q, i)},
}
if (s j+1i == sji i ) return (TRUE) ;
}
return (FALSE)
}
ki
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
6/31
Longestpath problem
Use shortest path algorithms:by reversing signson weights.
Modify algorithms:
by changing minwith max.
Remarks:
Dijkstras algorithm is not relevant.Inconsistent problem:
Positive-weighted cycles.
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
7/31
ExampleBellman-Ford
Iteration 1:l 0=0, l 1=3, l 2= 1, l 3=.
Iteration 2:l 0=0, l 1=3, l 2=2, l 3=5.
Iteration 3:l 0=0, l 1=3, l 2=2, l 3=6.
Use shortest path algorithms:
by reversing signson
weights.
source
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
8/31
Liao-Wongs
algorithm
LIAO WONG(G( V, EF, W))
{
for ( i = 1 to N)
l 1i= 0;
for ( j = 1 to |F|+ 1) {
foreach vertex vi
l j+1i= longest pathin G( V, E,W E) ;
flag = TRUE;
foreach edge ( v p, v q) F {
if ( lj+1 q < lj+ 1
p+ w p,q){
flag = FALSE;
E = E ( v0 , v q) with weight ( lj+ 1p+ w p,q)
}
}
if ( flag ) return (TRUE) ;
}
return (FALSE)
adjust
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
9/31
ExampleLiao-Wong
Iteration 1:l0= 0, l 1= 3, l 2= 1, l 3= 5.
Adjust:add edge (v 0, v 1) with weight 2.
Iteration 2:l 0= 0, l 1= 3, l 2= 2, l 3= 6.
Only positive
edges from (a)
(b) adjusted by
adding longest
path from node0 to node 2
Looking for longest path
from node 0 to node 3
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
10/31
Vertexcover
Given a graph G(V, E)Find a subset of the vertices
covering all the edges.
Intractable problem.
Goals:
Minimum cover.Irredundant cover:
No vertex can be removed.
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
11/31
Example
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
12/31
Heuristic algorithm vertex based
VERTEX_COVERV(G(V; E)){
C = ;
while (E ) do {select a vertex vV;
delete vfrom G(V, E) ;
C=C {fv} ;
}
}
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
13/31
Heuristic algorithm edge based
VERTEX_COVERE(G(V, E))
{
C = ;
while (E ) do {
select an edge {u, v} E;
C=C {u, v};
delete from G(V, E) any edge incidentto either uor v;
}
}
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
14/31
Graph coloring
Vertex labeling (coloring):No edge has end-point with the same label.
Intractable on general graphs.
Polynomial-time algorithms for chordal(and
interval) graphs:
Left-edge algorithm.
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
15/31
Graph coloring heuristic algorithm
VERTEX_COLOR(G(V, E))
{for (i =1 to |V|) {
c =1
while (a vertex adjacent to viwith color c) do {
c = c +1;
color v iwith color c ;}
}
}
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
16/31
Graph
coloring
exact
algorithm
EXACT_COLOR( G( V, E) , k)
{
repeat {
NEXT VALUE( k) ;
if ( c k== 0)
return ;
if ( k == n)
c is a proper coloring;
else
EXACT COLOR( G( V, E) , k+ 1)
}
}
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
17/31
Graph
coloring
exact
algorithm
NEXT VALUE( k)
{repeat {
c k= ck+ 1;
if ( there is no adjacent vertex to v kwith the same color ck)
return ;
}until ( c k =maximum number of colors ) ;
c k= 0;
}
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
18/31
Intervalgraphs
Edges represent interval intersections.
Example:
Restricted channel routing problem with no
vertical constraints.
Possible to sort the intervals by left edge.
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
19/31
Example
E l
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
20/31
Example
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
21/31
Left-edge
algorithmLEFT EDGE( I){
Sort elements of Iin a list L with ascending order of li;
c = 0;
while (Some interval has not been colored ) do {
S =;
repeat {
s = first element in the listLwhose left edge
ls is higher than the rightmost edge in S.
S= S { s};
}until ( an element s is found );c = c + 1;
color elements of S with color c;
delete elements of Sfrom L;
}
}
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
22/31
Clique partitioning and covering
A clique partition is a cover. A clique partition can be derived from a cover by
making the vertex subsets disjoint.
Intractable problem on general graphs. Heuristics:
Search for maximal cliques.
Polynomial-time algorithms for chordal graphs.
HeuristicCLIQUEPARTITION( G( V E) )
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
23/31
Heuristic
algorithm
CLIQUEPARTITION( G( V, E) )
{
=;
while ( G( V, E) not empty ) do {
compute largest clique C V in G( V, E) ;
=C;
delete C from G( V, E) ;
}
}
CLI QUE( G( V, E) )
{
C = seed vertex;
repeat {
select vertex v V , vCand adjacent to all vertices of C;
if (no such vertex is found) return
C = C {v} ;
}
}
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
24/31
Covering and Satisfiability
Covering problems can be cast as satisfiability.
Vertex cover.
Ex1:( x 1+ x 2) (x 2+ x 3) (x 3+ x 4) (x 4+ x 5)
Ex2:(x3+ x4) (x1+ x3) (x1+ x2) (x2+ x4) (x4+ x5)
Objective function:
Result:Ex1:x 2= 1, x 4= 1
Ex2:x 1 = 1, x 4= 1
C i bl
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
25/31
Covering problem
Set covering problem:
A set S.
A collection C of subsets.
Select fewest elements of C to cover S. Intractable.
Exact method:
Branch and bound algorithm.
Heuristic methods.
E l
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
26/31
Example
vertex-cover of a graph
Example
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
27/31
Example
edge-cover of a hypergraph
M i i
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
28/31
Matrix representation
Boolean matrix: A.
Selection Boolean vector: x. Determine x such that:
A x 1.
Select enough columns to cover all rows.
Minimize cardinality of x.
B h d b d l i h
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
29/31
Branch and bound algorithm
Tree search of the solution space:
Potentially exponential search.
Use bounding function:
If the lower bound on the solution cost that can be
derived from a set of future choices exceeds the cost ofthe best solution seen so far:
Kill the search.
Good pruning may reduce run-time.
Branch andBRANCH AND BOUND{
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
30/31
Branch and
bound
algorithm
_ _ {
Current best = anything;
Current cost = 1;
S= s 0;
while (S6 = ; ) do {
Select an element in s 2S;
Remove s from S ;
Make a branching decision based on s
yielding sequences f s i ; i= 1; 2; ...; mg ;
for ( i = 1 to m) {
Compute the lower bound b i of si ;
if ( b i Current cost) Kill si;else {
if ( s i is a complete solution ) {
Current best = s i,
Current cost = cost of s i,
}
elseAdd s i to set S;
}
}
}
}
Example
8/13/2019 AUXILIARY 2 Graph Coloring Hypergraphs
31/31
Example