SlideShare une entreprise Scribd logo
1  sur  25
1
Graph Coloring and Applications
2
Overview
• Graph Coloring Basics
• Planar/4-color Graphs
• Applications
• Chordal Graphs
• New Register Allocation Technique
3
Basics
• Assignment of "colors" to certain objects in a
graph subject to certain constraints
– Vertex coloring (the default)
– Edge coloring
– Face coloring (planar)
4
Not Graph Labeling
• Graph coloring
– Just markers to keep track of adjacency or
incidence
• Graph labeling
– Calculable problems that satisfy a numerical
condition
5
Vertex coloring
• In its simplest form, it is a way of coloring the
vertices of a graph such that no two adjacent
vertices share the same color
• Edge and Face coloring can be transformed
into Vertex version
6
Vertex Color example
• Anything less results in adjacent vertices with
the same color
– Known as “proper”
• 3-color example
7
Vertex Color Example
1
2 4
5
3
8
Vertex Color Example
1
2 4
5
3
9
Chromatic Number
• χ - least number of colors needed to color a
graph
– Chromatic number of a complete graph:
χ(Kn) = n
10
Properties of χ(G)
• χ(G) = 1 if and only if G is totally disconnected
• χ(G) ≥ 3 if and only if G has an odd cycle (equivalently, if G is
not bipartite)
• χ(G) ≥ ω(G) (clique number)
• χ(G) ≤ Δ(G)+1 (maximum degree)
• χ(G) ≤ Δ(G) for connected G, unless G is a complete graph or
an odd cycle (Brooks' theorem).
• χ(G) ≤ 4, for any planar graph
– The “four-color theorem”
11
Four-color Theorem
• Dates back to 1852 to Francis Guthrie
• Any given plane separated into regions may be
colored using no more than 4 colors
– Used for political boundaries, states, etc
– Shares common segment (not a point)
• Many failed proofs
12
Algorithmic complexity
• Finding minimum coloring: NP-hard
• Decision problem:
“is there a coloring which uses at most k colors?”
• Makes it NP-complete
13
Coloring a Graph - Applications
• Sudoku
• Scheduling
• Mobile radio frequency assignment
• Pattern matching
• Register Allocation
14
Register Allocation with Graphs
Coloring
• Register pressure
– How determine what should be stored in registers
– Determine what to “spill” to memory
• Typical RA utilize graph coloring for underlying
allocation problem
– Build graph to manage conflicts between live
ranges
15
Chordal Graphs
• Each cycle of four or more nodes has a chord
• Subset of perfect graphs
• Also known as triangulated graphs
16
Chordal Graph Example
• Removing a green edge will make it non-chordal
17
RA with Chordal Graphs
• Normal register allocation was an NP-
complete problem
– Graph coloring
• If program is in SSA form, it can be
accomplished in polynomial time with chordal
graphs!
– Thereby decreasing need for registers
18
Quick Static Single Assignment Review
• SSA Characteristics
– Basic blocks
– Unique naming for variable assignments
– Φ-functions used at convergence of control flows
• Improves optimization
– constant propagation
– dead code elimination
– global value numbering
– partial redundancy elimination
– strength reduction
– register allocation
19
RA with Chordal Graphs
• SSA representation needs fewer registers
• Key insight: a program in SSA form has a
chordal interference graph
– Very Recent
20
RA with Chordal Graphs cont
• Result is based on the fact that in strict-
SSA form, every variable has a single
contiguous live range
• Variables with overlapping live ranges
form cliques in the interference graph
21
RA with Chordal Graphs cont
• Greedy algorithm can color a chordal graph in
linear time
• New SSA-elimination algorithm done without
extra registers
• Result:
– Simple, optimal, polynomial-time algorithm for
the core register allocation problem
22
Chordal Color Assignment
• Algorithm: Chordal Color Assignment
• Input: Chordal Graph G = (V, E), PEO σ
• Output: Color Assignment f : V → {1… χG}
For Integer : i ← 1 to |V| in PEO order
Let c be the smallest color not assigned to a vertex
in Ni(vi)
f(vi) ← c
EndFor
23
Conclusion
• Graph Coloring
• Chordal Graphs
• New Register Allocation Technique
– Polynomial time
24
References
• http://en.wikipedia.org
• Engineering a Compiler, Keith D. Cooper and Linda Torczon,
2004
• http://www.math.gatech.edu/~thomas/FC/fourcolor.html
• An Optimistic and Conservative Register Assignment Heuristic
for Chordal Graphs, Philip Brisk, et. Al., CASES 07
• Register Allocation via Coloring of Chordal Graphs, Jens
Palsberg, CATS2007
25
Questions?
• Thank you

Contenu connexe

Tendances

Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell AlgorithmGraph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell AlgorithmPriyank Jain
 
Edge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloringEdge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloringDr. Abdul Ahad Abro
 
Dijkstra’S Algorithm
Dijkstra’S AlgorithmDijkstra’S Algorithm
Dijkstra’S Algorithmami_01
 
Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theoryTech_MX
 
Graph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxGraph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxHome
 
Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Adwait Hegde
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringSaurabh Kaushik
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applicationsManikanta satyala
 
Graph Coloring and Its Implementation
Graph Coloring and Its ImplementationGraph Coloring and Its Implementation
Graph Coloring and Its ImplementationIJARIIT
 
CS6702 Unit III coloring ppt
CS6702   Unit III coloring pptCS6702   Unit III coloring ppt
CS6702 Unit III coloring pptAbilaasha Ganesan
 
Color model in computer graphics
Color model in computer graphicsColor model in computer graphics
Color model in computer graphicsPuja Dhakal
 
Dijkstra algorithm a dynammic programming approach
Dijkstra algorithm   a dynammic programming approachDijkstra algorithm   a dynammic programming approach
Dijkstra algorithm a dynammic programming approachAkash Sethiya
 

Tendances (20)

Graph coloring Algorithm
Graph coloring AlgorithmGraph coloring Algorithm
Graph coloring Algorithm
 
Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell AlgorithmGraph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
 
Graph Coloring
Graph ColoringGraph Coloring
Graph Coloring
 
Edge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloringEdge Coloring & K-tuple coloring
Edge Coloring & K-tuple coloring
 
Dijkstra’S Algorithm
Dijkstra’S AlgorithmDijkstra’S Algorithm
Dijkstra’S Algorithm
 
Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theory
 
Graph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxGraph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptx
 
Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
 
Graph theory
Graph theory Graph theory
Graph theory
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applications
 
Lecture-9.pptx
Lecture-9.pptxLecture-9.pptx
Lecture-9.pptx
 
Graph Coloring and Its Implementation
Graph Coloring and Its ImplementationGraph Coloring and Its Implementation
Graph Coloring and Its Implementation
 
MATCHING GRAPH THEORY
MATCHING GRAPH THEORYMATCHING GRAPH THEORY
MATCHING GRAPH THEORY
 
CS6702 Unit III coloring ppt
CS6702   Unit III coloring pptCS6702   Unit III coloring ppt
CS6702 Unit III coloring ppt
 
Color model in computer graphics
Color model in computer graphicsColor model in computer graphics
Color model in computer graphics
 
Maxflow
MaxflowMaxflow
Maxflow
 
Bipartite graph
Bipartite graphBipartite graph
Bipartite graph
 
Dijkstra algorithm a dynammic programming approach
Dijkstra algorithm   a dynammic programming approachDijkstra algorithm   a dynammic programming approach
Dijkstra algorithm a dynammic programming approach
 
graph.ppt
graph.pptgraph.ppt
graph.ppt
 

En vedette

Algorithms for Graph Coloring Problem
Algorithms for Graph Coloring ProblemAlgorithms for Graph Coloring Problem
Algorithms for Graph Coloring ProblemShengyi Wang
 
Graph theory in Practise
Graph theory in PractiseGraph theory in Practise
Graph theory in PractiseDavid Simons
 
Graph theory and life
Graph theory and lifeGraph theory and life
Graph theory and lifeMilan Joshi
 
Application of graph theory in drug design
Application of graph theory in drug designApplication of graph theory in drug design
Application of graph theory in drug designReihaneh Safavi
 
Football and graph theory
Football and graph theoryFootball and graph theory
Football and graph theoryUmang Aggarwal
 
Applications of graphs
Applications of graphsApplications of graphs
Applications of graphsTech_MX
 
CS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf bookCS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf bookappasami
 
introduction to graph theory
introduction to graph theoryintroduction to graph theory
introduction to graph theoryChuckie Balbuena
 
the bike map - a look into a practical application of graph theory
the bike map - a look into a practical application of graph theorythe bike map - a look into a practical application of graph theory
the bike map - a look into a practical application of graph theoryCharlie Hsu
 
Graph theory 1
Graph theory 1Graph theory 1
Graph theory 1Tech_MX
 
Graph theory
Graph theoryGraph theory
Graph theoryKumar
 
backtracking algorithms of ada
backtracking algorithms of adabacktracking algorithms of ada
backtracking algorithms of adaSahil Kumar
 
Graphs - CH10 - Discrete Mathematics
Graphs - CH10 - Discrete MathematicsGraphs - CH10 - Discrete Mathematics
Graphs - CH10 - Discrete MathematicsOmnia A. Abdullah
 

En vedette (20)

Algorithms for Graph Coloring Problem
Algorithms for Graph Coloring ProblemAlgorithms for Graph Coloring Problem
Algorithms for Graph Coloring Problem
 
Graph theory in Practise
Graph theory in PractiseGraph theory in Practise
Graph theory in Practise
 
Graph theory and life
Graph theory and lifeGraph theory and life
Graph theory and life
 
Application of graph theory in drug design
Application of graph theory in drug designApplication of graph theory in drug design
Application of graph theory in drug design
 
Football and graph theory
Football and graph theoryFootball and graph theory
Football and graph theory
 
Applications of graphs
Applications of graphsApplications of graphs
Applications of graphs
 
graph theory
graph theory graph theory
graph theory
 
Backtracking
BacktrackingBacktracking
Backtracking
 
CS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf bookCS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf book
 
introduction to graph theory
introduction to graph theoryintroduction to graph theory
introduction to graph theory
 
Graph Coloring using Peer-to-Peer Networks
Graph Coloring using Peer-to-Peer NetworksGraph Coloring using Peer-to-Peer Networks
Graph Coloring using Peer-to-Peer Networks
 
The four color theorem
The four color theoremThe four color theorem
The four color theorem
 
the bike map - a look into a practical application of graph theory
the bike map - a look into a practical application of graph theorythe bike map - a look into a practical application of graph theory
the bike map - a look into a practical application of graph theory
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Graph
GraphGraph
Graph
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Graph theory 1
Graph theory 1Graph theory 1
Graph theory 1
 
Graph theory
Graph theoryGraph theory
Graph theory
 
backtracking algorithms of ada
backtracking algorithms of adabacktracking algorithms of ada
backtracking algorithms of ada
 
Graphs - CH10 - Discrete Mathematics
Graphs - CH10 - Discrete MathematicsGraphs - CH10 - Discrete Mathematics
Graphs - CH10 - Discrete Mathematics
 

Similaire à Graph coloring and_applications

Graph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.pptGraph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.pptssuseraf60311
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxB.T.L.I.T
 
141222 graphulo ingraphblas
141222 graphulo ingraphblas141222 graphulo ingraphblas
141222 graphulo ingraphblasMIT
 
141205 graphulo ingraphblas
141205 graphulo ingraphblas141205 graphulo ingraphblas
141205 graphulo ingraphblasgraphulo
 
Extended online graph edge coloring
Extended online graph edge coloringExtended online graph edge coloring
Extended online graph edge coloringijcsa
 
Graph Coloring Algorithms on Pregel Model using Hadoop
Graph Coloring Algorithms on Pregel Model using HadoopGraph Coloring Algorithms on Pregel Model using Hadoop
Graph Coloring Algorithms on Pregel Model using HadoopNishant Gandhi
 
Prestation_ClydeShen
Prestation_ClydeShenPrestation_ClydeShen
Prestation_ClydeShenClyde Shen
 
Farhna shaikh webinar_graphcoloring
Farhna shaikh webinar_graphcoloringFarhna shaikh webinar_graphcoloring
Farhna shaikh webinar_graphcoloringFarhana Shaikh
 

Similaire à Graph coloring and_applications (13)

coloring_Graph.ppt
coloring_Graph.pptcoloring_Graph.ppt
coloring_Graph.ppt
 
coloring.pptx
coloring.pptxcoloring.pptx
coloring.pptx
 
coloring.ppt
coloring.pptcoloring.ppt
coloring.ppt
 
Graph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.pptGraph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.ppt
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
 
Graph Coloring
Graph ColoringGraph Coloring
Graph Coloring
 
141222 graphulo ingraphblas
141222 graphulo ingraphblas141222 graphulo ingraphblas
141222 graphulo ingraphblas
 
141205 graphulo ingraphblas
141205 graphulo ingraphblas141205 graphulo ingraphblas
141205 graphulo ingraphblas
 
Extended online graph edge coloring
Extended online graph edge coloringExtended online graph edge coloring
Extended online graph edge coloring
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Graph Coloring Algorithms on Pregel Model using Hadoop
Graph Coloring Algorithms on Pregel Model using HadoopGraph Coloring Algorithms on Pregel Model using Hadoop
Graph Coloring Algorithms on Pregel Model using Hadoop
 
Prestation_ClydeShen
Prestation_ClydeShenPrestation_ClydeShen
Prestation_ClydeShen
 
Farhna shaikh webinar_graphcoloring
Farhna shaikh webinar_graphcoloringFarhna shaikh webinar_graphcoloring
Farhna shaikh webinar_graphcoloring
 

Graph coloring and_applications

  • 1. 1 Graph Coloring and Applications
  • 2. 2 Overview • Graph Coloring Basics • Planar/4-color Graphs • Applications • Chordal Graphs • New Register Allocation Technique
  • 3. 3 Basics • Assignment of "colors" to certain objects in a graph subject to certain constraints – Vertex coloring (the default) – Edge coloring – Face coloring (planar)
  • 4. 4 Not Graph Labeling • Graph coloring – Just markers to keep track of adjacency or incidence • Graph labeling – Calculable problems that satisfy a numerical condition
  • 5. 5 Vertex coloring • In its simplest form, it is a way of coloring the vertices of a graph such that no two adjacent vertices share the same color • Edge and Face coloring can be transformed into Vertex version
  • 6. 6 Vertex Color example • Anything less results in adjacent vertices with the same color – Known as “proper” • 3-color example
  • 9. 9 Chromatic Number • χ - least number of colors needed to color a graph – Chromatic number of a complete graph: χ(Kn) = n
  • 10. 10 Properties of χ(G) • χ(G) = 1 if and only if G is totally disconnected • χ(G) ≥ 3 if and only if G has an odd cycle (equivalently, if G is not bipartite) • χ(G) ≥ ω(G) (clique number) • χ(G) ≤ Δ(G)+1 (maximum degree) • χ(G) ≤ Δ(G) for connected G, unless G is a complete graph or an odd cycle (Brooks' theorem). • χ(G) ≤ 4, for any planar graph – The “four-color theorem”
  • 11. 11 Four-color Theorem • Dates back to 1852 to Francis Guthrie • Any given plane separated into regions may be colored using no more than 4 colors – Used for political boundaries, states, etc – Shares common segment (not a point) • Many failed proofs
  • 12. 12 Algorithmic complexity • Finding minimum coloring: NP-hard • Decision problem: “is there a coloring which uses at most k colors?” • Makes it NP-complete
  • 13. 13 Coloring a Graph - Applications • Sudoku • Scheduling • Mobile radio frequency assignment • Pattern matching • Register Allocation
  • 14. 14 Register Allocation with Graphs Coloring • Register pressure – How determine what should be stored in registers – Determine what to “spill” to memory • Typical RA utilize graph coloring for underlying allocation problem – Build graph to manage conflicts between live ranges
  • 15. 15 Chordal Graphs • Each cycle of four or more nodes has a chord • Subset of perfect graphs • Also known as triangulated graphs
  • 16. 16 Chordal Graph Example • Removing a green edge will make it non-chordal
  • 17. 17 RA with Chordal Graphs • Normal register allocation was an NP- complete problem – Graph coloring • If program is in SSA form, it can be accomplished in polynomial time with chordal graphs! – Thereby decreasing need for registers
  • 18. 18 Quick Static Single Assignment Review • SSA Characteristics – Basic blocks – Unique naming for variable assignments – Φ-functions used at convergence of control flows • Improves optimization – constant propagation – dead code elimination – global value numbering – partial redundancy elimination – strength reduction – register allocation
  • 19. 19 RA with Chordal Graphs • SSA representation needs fewer registers • Key insight: a program in SSA form has a chordal interference graph – Very Recent
  • 20. 20 RA with Chordal Graphs cont • Result is based on the fact that in strict- SSA form, every variable has a single contiguous live range • Variables with overlapping live ranges form cliques in the interference graph
  • 21. 21 RA with Chordal Graphs cont • Greedy algorithm can color a chordal graph in linear time • New SSA-elimination algorithm done without extra registers • Result: – Simple, optimal, polynomial-time algorithm for the core register allocation problem
  • 22. 22 Chordal Color Assignment • Algorithm: Chordal Color Assignment • Input: Chordal Graph G = (V, E), PEO σ • Output: Color Assignment f : V → {1… χG} For Integer : i ← 1 to |V| in PEO order Let c be the smallest color not assigned to a vertex in Ni(vi) f(vi) ← c EndFor
  • 23. 23 Conclusion • Graph Coloring • Chordal Graphs • New Register Allocation Technique – Polynomial time
  • 24. 24 References • http://en.wikipedia.org • Engineering a Compiler, Keith D. Cooper and Linda Torczon, 2004 • http://www.math.gatech.edu/~thomas/FC/fourcolor.html • An Optimistic and Conservative Register Assignment Heuristic for Chordal Graphs, Philip Brisk, et. Al., CASES 07 • Register Allocation via Coloring of Chordal Graphs, Jens Palsberg, CATS2007